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
6 changes: 3 additions & 3 deletions docs/user-guide/skeleton_editing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ In the **Render** tab you can adjust:

When you make a skeleton visible, a full fetch is triggered and you are guaranteed
to see all nodes and details of that skeleton. Otherwise you see whatever is
provided by the spatial index level selected for the current view. The selected
grid size is controlled via the **Resolution (skeleton grid 2D)** and
**Resolution (skeleton grid 3D)** settings.
provided by the spatial index levels selected for the current view. The selected
levels are controlled via the **Spacing (skeleton grid 2D)** and
**Spacing (skeleton grid 3D)** settings.

The **Seg** tab works as normal for a segmentation layer, allowing you to set the
visibility of segments/skeletons by their ID or by label if one has been assigned.
Expand Down
21 changes: 21 additions & 0 deletions src/datasource/catmaid/api.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -539,9 +539,30 @@ describe("CatmaidClient skeleton editing methods", () => {
]);

expect(getFetchPath(fetchMock)).toMatch(/^node\/list\?/);
expect(
new URLSearchParams(getFetchPath(fetchMock).split("?")[1]).get("lod"),
).toBe("0");
expect(getFetchInit(fetchMock).priority).toBe("low");
});

it("passes the CATMAID source-associated lod to node/list", async () => {
const client = new CatmaidClient("https://example.invalid", 1);
const fetchMock = vi.fn().mockResolvedValue([[], [], {}, false, [], []]);
(client as any).fetch = fetchMock;

await client.fetchNodes(
{
lowerBounds: [0, 0, 0],
upperBounds: [10, 10, 10],
},
0.5,
);

expect(
new URLSearchParams(getFetchPath(fetchMock).split("?")[1]).get("lod"),
).toBe("0.5");
});

it("converts spatial skeleton grid cell indices to CATMAID bounds", () => {
expect(
getCatmaidSpatialSkeletonGridCellBounds([2, 3, 4], [10, 20, 30]),
Expand Down
64 changes: 64 additions & 0 deletions src/datasource/catmaid/backend.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/**
* @license
* Copyright 2026 Google Inc.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { describe, expect, it, vi } from "vitest";

import { CatmaidSpatiallyIndexedSkeletonSourceBackend } from "#src/datasource/catmaid/backend.js";

describe("CatmaidSpatiallyIndexedSkeletonSourceBackend", () => {
it("passes the source-associated CATMAID lod to node/list downloads", async () => {
const signal = new AbortController().signal;
const fetchNodes = vi.fn().mockResolvedValue([]);
const source = Object.create(
CatmaidSpatiallyIndexedSkeletonSourceBackend.prototype,
);
Object.defineProperties(source, {
client: { value: { fetchNodes } },
parameters: {
value: {
catmaidLod: 0.5,
catmaidParameters: { cacheProvider: "cached_msgpack_grid" },
},
},
spec: {
value: {
chunkDataSize: Float32Array.of(10, 20, 30),
},
},
});
const chunk = {
chunkGridPosition: Float32Array.of(2, 3, 4),
};

await CatmaidSpatiallyIndexedSkeletonSourceBackend.prototype.download.call(
source,
chunk,
signal,
);

expect(fetchNodes).toHaveBeenCalledWith(
{
lowerBounds: [20, 60, 120],
upperBounds: [30, 80, 150],
},
0.5,
{
cacheProvider: "cached_msgpack_grid",
signal,
},
);
});
});
4 changes: 2 additions & 2 deletions src/datasource/catmaid/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ export class CatmaidSpatiallyIndexedSkeletonSourceBackend extends WithParameters
chunkGridPosition,
chunkDataSize,
);
const lodValue = this.parameters.catmaidLod ?? 0;
const catmaidLod = this.parameters.catmaidLod ?? 0;
const cacheProvider = this.parameters.catmaidParameters.cacheProvider;
const nodes = await this.client.fetchNodes(bounds, lodValue, {
const nodes = await this.client.fetchNodes(bounds, catmaidLod, {
cacheProvider,
signal,
});
Expand Down
10 changes: 7 additions & 3 deletions src/datasource/catmaid/frontend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,12 @@ export class CatmaidMultiscaleSpatiallyIndexedSkeletonSource extends MultiscaleS
const sources: SliceViewSingleResolutionSource<SpatiallyIndexedSkeletonSource>[] =
[];

const lastGridIndex = this.gridLevels.length - 1;
for (const [
gridIndex,
{ size: gridCellSize, lod },
{ size: gridCellSize, limit },
] of this.gridLevels.entries()) {
const catmaidLod = lastGridIndex === 0 ? 0 : gridIndex / lastGridIndex;
const chunkDataSize = Uint32Array.from([
gridCellSize.x,
gridCellSize.y,
Expand Down Expand Up @@ -275,6 +277,7 @@ export class CatmaidMultiscaleSpatiallyIndexedSkeletonSource extends MultiscaleS
upperVoxelBound: this.upperBoundsInNanometers,
}),
chunkLayout,
limit,
};

const parameters = new CatmaidSkeletonSourceParameters();
Expand All @@ -284,7 +287,7 @@ export class CatmaidMultiscaleSpatiallyIndexedSkeletonSource extends MultiscaleS
parameters.catmaidParameters.cacheProvider = this.cacheProvider;
parameters.catmaidParameters.readonly = this.sourceReadonly;
parameters.gridIndex = gridIndex;
parameters.catmaidLod = lod;
parameters.catmaidLod = catmaidLod;
parameters.metadata = makeCatmaidSkeletonMetadata();

const chunkSource = this.chunkManager.getChunkSource(
Expand Down Expand Up @@ -383,10 +386,11 @@ export class CatmaidDataSourceProvider implements DataSourceProvider {
spatial,
readonly: sourceReadonly,
} = spatialIndexMetadata;
const gridCellSizes = spatial.map(({ chunkSize }) => ({
const gridCellSizes = spatial.map(({ chunkSize, limit }) => ({
x: Number(chunkSize[0]),
y: Number(chunkSize[1]),
z: Number(chunkSize[2]),
limit,
}));

// The model-space coordinates we emit are in nanometers, converted to meters for Neuroglancer.
Expand Down
Loading
Loading