Skip to content

Commit bc63f8d

Browse files
authored
Use mags instead of resolutions in datasource (#8958)
### URL of deployed dev instance (used for testing): - https://replaceresolutions.webknossos.xyz ### Steps to test: - open some datasets and annotations ### Issues: - fixes #8939 ------ (Please delete unneeded items, merge only when none are left open) - ~[ ] Added changelog entry~ irrelevant to end user
1 parent 6f9bd7b commit bc63f8d

38 files changed

+154
-168
lines changed

frontend/javascripts/admin/voxelytics/ai_model_list_view.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,11 @@ function TrainNewAiJobModal({ onClose }: { onClose: () => void }) {
149149
const volumeTracingIndex = volumeTracings.findIndex(
150150
(tracing) => tracing.tracingId === annotationLayer.tracingId,
151151
);
152-
const mags = volumeTracingMags[volumeTracingIndex] || ([[1, 1, 1]] as Vector3[]);
152+
const mags = volumeTracingMags[volumeTracingIndex] || [{ mag: [1, 1, 1] as Vector3 }];
153153
return getMagInfo(mags);
154154
} else {
155155
const segmentationLayer = getSegmentationLayerByName(dataset, layerName);
156-
return getMagInfo(segmentationLayer.resolutions);
156+
return getMagInfo(segmentationLayer.mags);
157157
}
158158
};
159159

frontend/javascripts/dashboard/advanced_dataset/create_explorative_modal.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export function RestrictMagnificationSlider({
9494
let lowestMagIndex = magInfo.getFinestMagIndex();
9595

9696
if (selectedSegmentationLayer != null) {
97-
const datasetFallbackLayerMagInfo = getMagInfo(selectedSegmentationLayer.resolutions);
97+
const datasetFallbackLayerMagInfo = getMagInfo(selectedSegmentationLayer.mags);
9898
highestMagIndex = datasetFallbackLayerMagInfo.getCoarsestMagIndex();
9999
lowestMagIndex = datasetFallbackLayerMagInfo.getFinestMagIndex();
100100
}
@@ -197,7 +197,7 @@ function CreateExplorativeModal({ datasetId, onClose }: Props) {
197197
const magInfo =
198198
selectedSegmentationLayer == null
199199
? getSomeMagInfoForDataset(dataset)
200-
: getMagInfo(selectedSegmentationLayer.resolutions);
200+
: getMagInfo(selectedSegmentationLayer.mags);
201201
const highestMagIndex = magInfo.getCoarsestMagIndex();
202202
const lowestMagIndex = magInfo.getFinestMagIndex();
203203

frontend/javascripts/test/fixtures/dataset_server_object.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ const sampleColorLayer: APIColorLayer = {
1010
height: 10240,
1111
depth: 10240,
1212
},
13-
resolutions: [
14-
[1, 1, 1],
15-
[2, 2, 2],
16-
[32, 32, 32], // unsorted on purpose
17-
[4, 4, 4],
18-
[8, 8, 8],
19-
[16, 16, 16],
13+
mags: [
14+
{ mag: [1, 1, 1] },
15+
{ mag: [2, 2, 2] },
16+
{ mag: [32, 32, 32] }, // unsorted on purpose
17+
{ mag: [4, 4, 4] },
18+
{ mag: [8, 8, 8] },
19+
{ mag: [16, 16, 16] },
2020
],
2121
elementClass: "uint8",
2222
additionalAxes: [],
@@ -33,13 +33,13 @@ const sampleSegmentationLayer: APISegmentationLayer = {
3333
height: 10240,
3434
depth: 10240,
3535
},
36-
resolutions: [
37-
[1, 1, 1],
38-
[2, 2, 2],
39-
[32, 32, 32], // unsorted on purpose
40-
[4, 4, 4],
41-
[8, 8, 8],
42-
[16, 16, 16],
36+
mags: [
37+
{ mag: [1, 1, 1] },
38+
{ mag: [2, 2, 2] },
39+
{ mag: [32, 32, 32] }, // unsorted on purpose
40+
{ mag: [4, 4, 4] },
41+
{ mag: [8, 8, 8] },
42+
{ mag: [16, 16, 16] },
4343
],
4444
elementClass: "uint32",
4545
largestSegmentId: 1000000000,

frontend/javascripts/test/fixtures/hybridtracing_object.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ export const colorLayer: APIColorLayer = {
1818
height: 256,
1919
depth: 256,
2020
},
21-
resolutions: [
22-
[1, 1, 1],
23-
[2, 2, 1],
24-
[4, 4, 1],
25-
[8, 8, 2],
26-
[16, 16, 4],
21+
mags: [
22+
{ mag: [1, 1, 1] },
23+
{ mag: [2, 2, 1] },
24+
{ mag: [4, 4, 1] },
25+
{ mag: [8, 8, 2] },
26+
{ mag: [16, 16, 4] },
2727
],
2828
elementClass: "uint8",
2929
coordinateTransformations: null,

frontend/javascripts/test/fixtures/volumetracing_object.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,7 @@ const stateWithoutDatasetInitialization = update(defaultState, {
5959
{
6060
// We need to have some mags. Otherwise,
6161
// getRequestLogZoomStep will always return 0
62-
resolutions: [
63-
[1, 1, 1],
64-
[2, 2, 2],
65-
[4, 4, 4],
66-
],
62+
mags: [{ mag: [1, 1, 1] }, { mag: [2, 2, 2] }, { mag: [4, 4, 4] }],
6763
category: "segmentation",
6864
largestSegmentId: volumeTracing.largestSegmentId ?? 0,
6965
elementClass: "uint32",

frontend/javascripts/test/model/accessors/flycam_accessors.spec.ts

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import defaultState from "viewer/default_state";
88
const { GPU_FACTOR_MULTIPLIER, DEFAULT_GPU_MEMORY_FACTOR } = constants;
99
const DEFAULT_REQUIRED_BUCKET_CAPACITY = GPU_FACTOR_MULTIPLIER * DEFAULT_GPU_MEMORY_FACTOR;
1010
const boundingBox = {
11-
topLeft: [0, 0, 0],
11+
topLeft: [0, 0, 0] as Vector3,
1212
width: 100,
1313
height: 100,
1414
depth: 100,
@@ -23,28 +23,25 @@ const initialState: WebknossosState = {
2323
dataLayers: [
2424
{
2525
name: "layer1",
26-
// @ts-expect-error ts-migrate(2322) FIXME: Type '{ topLeft: number[]; width: number; height: ... Remove this comment to see the full error message
2726
boundingBox,
2827
elementClass: "uint8",
29-
resolutions: [
30-
[1, 1, 1],
31-
[2, 2, 2],
32-
[4, 4, 4],
33-
[8, 8, 8],
34-
[16, 16, 16],
28+
mags: [
29+
{ mag: [1, 1, 1] },
30+
{ mag: [2, 2, 2] },
31+
{ mag: [4, 4, 4] },
32+
{ mag: [8, 8, 8] },
33+
{ mag: [16, 16, 16] },
3534
],
3635
category: "color",
36+
additionalAxes: [],
3737
},
3838
{
3939
name: "layer2",
40-
// @ts-expect-error ts-migrate(2322) FIXME: Type '{ topLeft: number[]; width: number; height: ... Remove this comment to see the full error message
4140
boundingBox,
4241
elementClass: "uint8",
43-
resolutions: [
44-
[1, 1, 1],
45-
[2, 2, 2],
46-
],
42+
mags: [{ mag: [1, 1, 1] }, { mag: [2, 2, 2] }],
4743
category: "color",
44+
additionalAxes: [],
4845
},
4946
],
5047
},

frontend/javascripts/test/model/binary/cube.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ describe("DataCube", () => {
5151

5252
beforeEach<TestContext>(async (context) => {
5353
const mockedLayer = {
54-
resolutions: [
54+
mags: [
5555
[1, 1, 1],
5656
[2, 2, 2],
5757
[4, 4, 4],
@@ -60,7 +60,7 @@ describe("DataCube", () => {
6060
[32, 32, 32],
6161
] as Vector3[],
6262
};
63-
const magInfo = new MagInfo(mockedLayer.resolutions);
63+
const magInfo = new MagInfo(mockedLayer.mags);
6464
const cube = new DataCube(
6565
new BoundingBox({ min: [0, 0, 0], max: [100, 100, 100] }),
6666
[],
@@ -275,9 +275,9 @@ describe("DataCube", () => {
275275
describe.skip("DataCube Benchmark", () => {
276276
it("Benchmark", () => {
277277
const mockedLayer = {
278-
resolutions: [[1, 1, 1]] as Vector3[],
278+
mags: [[1, 1, 1]] as Vector3[],
279279
};
280-
const magInfo = new MagInfo(mockedLayer.resolutions);
280+
const magInfo = new MagInfo(mockedLayer.mags);
281281
const cube = new DataCube(
282282
new BoundingBox({ min: [1024, 1024, 1024], max: [2048, 2048, 2048] }),
283283
[],

frontend/javascripts/test/model/binary/pullqueue.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ vi.mock("viewer/store", function () {
3939
url: "url",
4040
name: "layername",
4141
category: "color",
42-
resolutions: [[1, 1, 1]],
42+
mags: [{ mag: [1, 1, 1] }],
4343
},
4444
],
4545
},

frontend/javascripts/test/model/model_resolutions.spec.ts

Lines changed: 27 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ import { describe, it, expect } from "vitest";
22
import { getMagnificationUnion } from "viewer/model/accessors/dataset_accessor";
33
import type { Vector3 } from "viewer/constants";
44
import type { APIDataset } from "types/api_types";
5-
import { convertToDenseMag } from "viewer/model/helpers/mag_info";
5+
import { convertToDenseMags } from "viewer/model/helpers/mag_info";
66

7-
describe("Model resolutions", () => {
8-
it("Simple convertToDenseMag", () => {
9-
const denseMags = convertToDenseMag([
7+
describe("Model mags", () => {
8+
it("Simple convertToDenseMags", () => {
9+
const denseMags = convertToDenseMags([
1010
[2, 2, 1],
1111
[4, 4, 2],
1212
]);
@@ -17,21 +17,21 @@ describe("Model resolutions", () => {
1717
]);
1818
});
1919

20-
it("Complex convertToDenseMag", () => {
20+
it("Complex convertToDenseMags", () => {
2121
const dataset = {
2222
dataSource: {
2323
dataLayers: [
2424
{
25-
resolutions: [
26-
[16, 16, 2],
27-
[2, 2, 1],
28-
[4, 4, 1],
29-
[8, 8, 1],
30-
[32, 32, 4],
31-
] as Vector3[],
25+
mags: [
26+
{ mag: [16, 16, 2] },
27+
{ mag: [2, 2, 1] },
28+
{ mag: [4, 4, 1] },
29+
{ mag: [8, 8, 1] },
30+
{ mag: [32, 32, 4] },
31+
] as { mag: Vector3 }[],
3232
},
3333
{
34-
resolutions: [[32, 32, 4]] as Vector3[],
34+
mags: [{ mag: [32, 32, 4] }] as { mag: Vector3 }[],
3535
},
3636
],
3737
},
@@ -56,7 +56,8 @@ describe("Model resolutions", () => {
5656
] as Vector3[],
5757
};
5858

59-
const densify = (layer: { resolutions: Vector3[] }) => convertToDenseMag(layer.resolutions);
59+
const densify = (layer: { mags: { mag: Vector3 }[] }) =>
60+
convertToDenseMags(layer.mags.map((magObj) => magObj.mag));
6061

6162
expect(densify(dataset.dataSource.dataLayers[0])).toEqual(expectedMags[0]);
6263
expect(densify(dataset.dataSource.dataLayers[1])).toEqual(expectedMags[1]);
@@ -78,19 +79,15 @@ describe("Model resolutions", () => {
7879
dataSource: {
7980
dataLayers: [
8081
{
81-
resolutions: [
82-
[4, 4, 1],
83-
[8, 8, 1],
84-
[16, 16, 2],
85-
[32, 32, 4],
82+
mags: [
83+
{ mag: [4, 4, 1] },
84+
{ mag: [8, 8, 1] },
85+
{ mag: [16, 16, 2] },
86+
{ mag: [32, 32, 4] },
8687
],
8788
},
8889
{
89-
resolutions: [
90-
[2, 2, 1],
91-
[8, 8, 1],
92-
[32, 32, 4],
93-
],
90+
mags: [{ mag: [2, 2, 1] }, { mag: [8, 8, 1] }, { mag: [32, 32, 4] }],
9491
},
9592
],
9693
},
@@ -105,19 +102,15 @@ describe("Model resolutions", () => {
105102
dataSource: {
106103
dataLayers: [
107104
{
108-
resolutions: [
109-
[4, 4, 1],
110-
[8, 8, 1],
111-
[16, 16, 2],
112-
[32, 32, 4],
105+
mags: [
106+
{ mag: [4, 4, 1] },
107+
{ mag: [8, 8, 1] },
108+
{ mag: [16, 16, 2] },
109+
{ mag: [32, 32, 4] },
113110
],
114111
},
115112
{
116-
resolutions: [
117-
[2, 2, 1],
118-
[8, 8, 2],
119-
[32, 32, 4],
120-
],
113+
mags: [{ mag: [2, 2, 1] }, { mag: [8, 8, 2] }, { mag: [32, 32, 4] }],
121114
},
122115
],
123116
},

frontend/javascripts/test/model/volumetracing/volume_annotation_sampling.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ describe("Volume Annotation Sampling", () => {
6868

6969
beforeEach(() => {
7070
const mockedLayer = {
71-
resolutions: [
71+
mags: [
7272
[1, 1, 1],
7373
[2, 2, 2],
7474
[4, 4, 4],
@@ -77,7 +77,7 @@ describe("Volume Annotation Sampling", () => {
7777
[32, 32, 32],
7878
] as Vector3[],
7979
};
80-
const magInfo = new MagInfo(mockedLayer.resolutions);
80+
const magInfo = new MagInfo(mockedLayer.mags);
8181
const cube = new DataCube(cubeBoundingBox, [], magInfo, "uint32", false, "layerName");
8282
const pullQueue = {
8383
add: vi.fn(),

0 commit comments

Comments
 (0)