Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
226 changes: 113 additions & 113 deletions src/datasource/catmaid/api.spec.ts

Large diffs are not rendered by default.

423 changes: 239 additions & 184 deletions src/datasource/catmaid/api.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/datasource/catmaid/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export class CatmaidSkeletonSourceBackend extends WithParameters(
}

async download(chunk: SkeletonChunk, signal: AbortSignal) {
const skeletonId = Number(chunk.objectId);
const skeletonId = chunk.objectId;
const nodes = await this.client.getSkeleton(skeletonId, { signal });
const packed = packCatmaidSkeletonNodes(nodes);

Expand Down
9 changes: 5 additions & 4 deletions src/datasource/catmaid/frontend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import {
normalizeInlineSegmentPropertyMap,
} from "#src/segmentation_display_state/property_map.js";
import type {
SpatialSkeletonId,
SpatialSkeletonConfidenceConfiguration,
SpatialSkeletonGridCellIndex,
SpatiallyIndexedSkeletonMetadata,
Expand Down Expand Up @@ -154,13 +155,13 @@ export class CatmaidSpatiallyIndexedSkeletonSource extends WithParameters(
}

getSkeleton(
skeletonId: number,
skeletonId: SpatialSkeletonId,
options?: { signal?: AbortSignal },
): Promise<SpatiallyIndexedSkeletonNode[]> {
return this.client.getSkeleton(skeletonId, options);
}

listSkeletons(): Promise<number[]> {
listSkeletons(): Promise<SpatialSkeletonId[]> {
return this.client.listSkeletons();
}

Expand Down Expand Up @@ -188,7 +189,7 @@ export class CatmaidSpatiallyIndexedSkeletonSource extends WithParameters(
);
}

getSkeletonRootNode(skeletonId: number) {
getSkeletonRootNode(skeletonId: SpatialSkeletonId) {
return this.client.getSkeletonRootNode(skeletonId);
}
}
Expand Down Expand Up @@ -469,7 +470,7 @@ export class CatmaidDataSourceProvider implements DataSourceProvider {
// Create SegmentPropertyMap
const ids = new BigUint64Array(skeletonIds.length);
for (let i = 0; i < skeletonIds.length; ++i) {
ids[i] = BigInt(skeletonIds[i]);
ids[i] = skeletonIds[i];
}

const propertyMap = new SegmentPropertyMap({
Expand Down
26 changes: 13 additions & 13 deletions src/datasource/catmaid/skeleton_packing.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,24 @@ describe("datasource/catmaid/skeleton_packing", () => {
it("packs vertex, segment, index, and pick-node data", () => {
const nodes: SpatiallyIndexedSkeletonNodeBase[] = [
{
nodeId: 1,
nodeId: 1n,
parentNodeId: undefined,
position: new Float32Array([1, 2, 3]),
segmentId: 10,
segmentId: 10n,
sourceState: { revisionToken: "node-1" },
},
{
nodeId: 2,
parentNodeId: 1,
nodeId: 2n,
parentNodeId: 1n,
position: new Float32Array([4, 5, 6]),
segmentId: 10,
segmentId: 10n,
sourceState: { revisionToken: "node-2" },
},
{
nodeId: 3,
parentNodeId: 99,
nodeId: 3n,
parentNodeId: 99n,
position: new Float32Array([7, 8, 9]),
segmentId: 11,
segmentId: 11n,
},
];

Expand All @@ -33,9 +33,9 @@ describe("datasource/catmaid/skeleton_packing", () => {
expect(packed.vertexPositions).toEqual(
Float32Array.of(1, 2, 3, 4, 5, 6, 7, 8, 9),
);
expect(packed.segmentIds).toEqual(Uint32Array.of(10, 10, 11));
expect(packed.segmentIds).toEqual(BigUint64Array.of(10n, 10n, 11n));
expect(packed.indices).toEqual(Uint32Array.of(1, 0));
expect(packed.nodeIds).toEqual(Int32Array.of(1, 2, 3));
expect(packed.nodeIds).toEqual(BigUint64Array.of(1n, 2n, 3n));
expect(packed.sourceStates).toEqual([
{ revisionToken: "node-1" },
{ revisionToken: "node-2" },
Expand All @@ -44,10 +44,10 @@ describe("datasource/catmaid/skeleton_packing", () => {
});

it("preserves large segment ids exactly", () => {
const largeSegmentId = 16_777_217;
const largeSegmentId = 9_007_199_254_740_993n;
const nodes: SpatiallyIndexedSkeletonNodeBase[] = [
{
nodeId: 1,
nodeId: 1n,
parentNodeId: undefined,
position: new Float32Array([1, 2, 3]),
segmentId: largeSegmentId,
Expand All @@ -56,6 +56,6 @@ describe("datasource/catmaid/skeleton_packing", () => {

const packed = packCatmaidSkeletonNodes(nodes);

expect(packed.segmentIds).toEqual(Uint32Array.of(largeSegmentId));
expect(packed.segmentIds).toEqual(BigUint64Array.of(largeSegmentId));
});
});
10 changes: 5 additions & 5 deletions src/datasource/catmaid/skeleton_packing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import type {

interface PackedCatmaidSkeletonData {
vertexPositions: Float32Array;
segmentIds: Uint32Array;
segmentIds: BigUint64Array;
indices: Uint32Array;
nodeIds: Int32Array;
nodeIds: BigUint64Array;
sourceStates: Array<SpatialSkeletonSourceState | undefined>;
}

Expand All @@ -32,13 +32,13 @@ export function packCatmaidSkeletonNodes(
): PackedCatmaidSkeletonData {
const numVertices = nodes.length;
const vertexPositions = new Float32Array(numVertices * 3);
const segmentIds = new Uint32Array(numVertices);
const nodeIds = new Int32Array(numVertices);
const segmentIds = new BigUint64Array(numVertices);
const nodeIds = new BigUint64Array(numVertices);
const sourceStates = new Array<SpatialSkeletonSourceState | undefined>(
numVertices,
);
const indices: number[] = [];
const nodeMap = new Map<number, number>();
const nodeMap = new Map<bigint, number>();

for (let i = 0; i < numVertices; ++i) {
const node = nodes[i];
Expand Down
Loading
Loading