Skip to content

Commit 4aa3ba5

Browse files
committed
test scene
1 parent 31f798c commit 4aa3ba5

15 files changed

Lines changed: 424 additions & 24 deletions

File tree

src/test/java/dev/zarr/zarrjava/ome/OmeZarrSceneV06Test.java

Lines changed: 62 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ public class OmeZarrSceneV06Test extends OmeZarrBaseTest {
1414

1515
private static final Path V06_SCENE_REGISTRATION =
1616
TESTDATA.resolve("ome/v0.6/examples/user_stories/image_registration_3d.zarr");
17+
private static final Path V06_SCENE_EXAMPLE1 =
18+
TESTDATA.resolve("ome/v0.6_scene/example1_instrument_registration.zarr");
19+
private static final Path V06_SCENE_EXAMPLE2 =
20+
TESTDATA.resolve("ome/v0.6_scene/example2_multi_instrument_chain.zarr");
1721

1822
@Override
1923
StoreHandle imageStoreHandle() throws Exception {
@@ -49,15 +53,11 @@ void openSceneAndNavigateImages() throws Exception {
4953
assertNotNull(scene.getSceneMetadata().coordinateTransformations);
5054
assertFalse(scene.getSceneMetadata().coordinateTransformations.isEmpty());
5155

52-
dev.zarr.zarrjava.ome.v0_6.metadata.SceneCoordinateTransformation top =
56+
dev.zarr.zarrjava.ome.v0_6.metadata.transform.CoordinateTransformation top =
5357
scene.getSceneMetadata().coordinateTransformations.get(0);
5458
assertEquals("bijection", top.type);
55-
assertNotNull(top.input);
56-
assertEquals("JRC2018F", top.input.path);
57-
assertEquals("physical", top.input.name);
58-
assertNotNull(top.output);
59-
assertEquals("FCWB", top.output.path);
60-
assertEquals("physical", top.output.name);
59+
assertEquals("JRC2018F#physical", top.input);
60+
assertEquals("FCWB#physical", top.output);
6161

6262
assertTrue(scene.listImageNodes().contains("FCWB"));
6363
assertTrue(scene.listImageNodes().contains("JRC2018F"));
@@ -89,22 +89,8 @@ void createAndReopenScene() throws Exception {
8989

9090
dev.zarr.zarrjava.ome.v0_6.metadata.SceneMetadata sceneMetadata =
9191
new dev.zarr.zarrjava.ome.v0_6.metadata.SceneMetadata(
92-
Collections.singletonList(new dev.zarr.zarrjava.ome.v0_6.metadata.SceneCoordinateTransformation(
93-
"translation",
94-
new dev.zarr.zarrjava.ome.v0_6.metadata.CoordinateSystemRef("imageA", "physical"),
95-
new dev.zarr.zarrjava.ome.v0_6.metadata.CoordinateSystemRef(null, "world"),
96-
"imageA to world",
97-
null,
98-
Arrays.asList(1.0, 2.0),
99-
null,
100-
null,
101-
null,
102-
null,
103-
null,
104-
null,
105-
null,
106-
null
107-
)),
92+
Collections.singletonList(new dev.zarr.zarrjava.ome.v0_6.metadata.transform.TranslationCoordinateTransformation(
93+
"imageA#physical", ".#world", "imageA to world", Arrays.asList(1.0, 2.0), null)),
10894
Collections.singletonList(new dev.zarr.zarrjava.ome.v0_6.metadata.CoordinateSystem(
10995
"world", Arrays.asList(y, x)))
11096
);
@@ -138,7 +124,7 @@ void createAndReopenScene() throws Exception {
138124
dev.zarr.zarrjava.ome.v0_6.Scene reopened = dev.zarr.zarrjava.ome.v0_6.Scene.openScene(root);
139125
assertEquals(Collections.singletonList("imageA"), reopened.listImageNodes());
140126
assertEquals("world", reopened.getSceneMetadata().coordinateSystems.get(0).name);
141-
assertEquals("imageA", reopened.getSceneMetadata().coordinateTransformations.get(0).input.path);
127+
assertEquals("imageA#physical", reopened.getSceneMetadata().coordinateTransformations.get(0).input);
142128

143129
dev.zarr.zarrjava.ome.v0_6.MultiscaleImage imageA = reopened.openImageNode("imageA");
144130
assertEquals(1, imageA.getScaleLevelCount());
@@ -152,4 +138,56 @@ void createAndReopenScene() throws Exception {
152138
reopened.createCoordinateTransformationsGroup();
153139
assertTrue(root.resolve("coordinateTransformations").resolve(dev.zarr.zarrjava.core.Node.ZARR_JSON).exists());
154140
}
141+
142+
@Test
143+
void openSceneExample1AffinePathBetweenInstruments() throws Exception {
144+
dev.zarr.zarrjava.ome.v0_6.Scene scene =
145+
dev.zarr.zarrjava.ome.v0_6.Scene.openScene(new FilesystemStore(V06_SCENE_EXAMPLE1).resolve());
146+
assertEquals(Arrays.asList("sampleA_instrument1", "sampleA_instrument2"), scene.listImageNodes());
147+
assertEquals(1, scene.getSceneMetadata().coordinateTransformations.size());
148+
dev.zarr.zarrjava.ome.v0_6.metadata.transform.CoordinateTransformation ct =
149+
scene.getSceneMetadata().coordinateTransformations.get(0);
150+
assertEquals("affine", ct.type);
151+
assertEquals("sampleA_instrument2#physical_instrument2", ct.input);
152+
assertEquals("sampleA_instrument1#physical_instrument1", ct.output);
153+
assertTrue(ct instanceof dev.zarr.zarrjava.ome.v0_6.metadata.transform.AffineCoordinateTransformation);
154+
assertEquals("coordinateTransformations/sampleA_instrument2-to-instrument1",
155+
((dev.zarr.zarrjava.ome.v0_6.metadata.transform.AffineCoordinateTransformation) ct).path);
156+
157+
dev.zarr.zarrjava.ome.v0_6.MultiscaleImage i1 = scene.openImageNode("sampleA_instrument1");
158+
dev.zarr.zarrjava.ome.v0_6.MultiscaleImage i2 = scene.openImageNode("sampleA_instrument2");
159+
assertEquals(Arrays.asList("z", "y", "x"), i1.getAxisNames());
160+
assertEquals(Arrays.asList("z", "y", "x"), i2.getAxisNames());
161+
162+
dev.zarr.zarrjava.ome.v0_6.SceneTransformationGraph graph = scene.getCoordinateTransformationGraph();
163+
assertEquals(2, graph.nodes.size());
164+
assertEquals(1, graph.edges.size());
165+
assertTrue(graph.warnings.isEmpty());
166+
}
167+
168+
@Test
169+
void openSceneExample2TwoAffineLinksViaInstrument2() throws Exception {
170+
dev.zarr.zarrjava.ome.v0_6.Scene scene =
171+
dev.zarr.zarrjava.ome.v0_6.Scene.openScene(new FilesystemStore(V06_SCENE_EXAMPLE2).resolve());
172+
assertEquals(Arrays.asList("instrument1", "instrument2", "instrument3"), scene.listImageNodes());
173+
assertEquals(2, scene.getSceneMetadata().coordinateTransformations.size());
174+
175+
dev.zarr.zarrjava.ome.v0_6.metadata.transform.CoordinateTransformation t0 =
176+
scene.getSceneMetadata().coordinateTransformations.get(0);
177+
dev.zarr.zarrjava.ome.v0_6.metadata.transform.CoordinateTransformation t1 =
178+
scene.getSceneMetadata().coordinateTransformations.get(1);
179+
assertEquals("affine", t0.type);
180+
assertEquals("affine", t1.type);
181+
assertEquals("instrument1#physical", t0.input);
182+
assertEquals("instrument2#physical", t0.output);
183+
assertEquals("instrument3#physical", t1.input);
184+
assertEquals("instrument2#physical", t1.output);
185+
assertTrue(t0 instanceof dev.zarr.zarrjava.ome.v0_6.metadata.transform.AffineCoordinateTransformation);
186+
assertTrue(((dev.zarr.zarrjava.ome.v0_6.metadata.transform.AffineCoordinateTransformation) t0).affine.size() > 0);
187+
188+
dev.zarr.zarrjava.ome.v0_6.SceneTransformationGraph graph = scene.getCoordinateTransformationGraph();
189+
assertEquals(3, graph.nodes.size());
190+
assertEquals(2, graph.edges.size());
191+
assertTrue(graph.warnings.isEmpty());
192+
}
155193
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"zarr_format": 3,
3+
"node_type": "array",
4+
"shape": [3, 4],
5+
"data_type": "float64",
6+
"fill_value": 0.0,
7+
"chunk_grid": {
8+
"name": "regular",
9+
"configuration": { "chunk_shape": [3, 4] }
10+
},
11+
"chunk_key_encoding": {
12+
"name": "default",
13+
"configuration": { "separator": "/" }
14+
},
15+
"codecs": [
16+
{ "name": "bytes", "configuration": { "endian": "little" } },
17+
{ "name": "zstd", "configuration": { "level": 3 } }
18+
],
19+
"dimension_names": ["row", "col"]
20+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"zarr_format": 3,
3+
"node_type": "group",
4+
"attributes": {}
5+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"zarr_format": 3,
3+
"node_type": "array",
4+
"shape": [4, 4, 4],
5+
"data_type": "uint16",
6+
"fill_value": 0,
7+
"chunk_grid": {
8+
"name": "regular",
9+
"configuration": { "chunk_shape": [2, 2, 2] }
10+
},
11+
"chunk_key_encoding": {
12+
"name": "default",
13+
"configuration": { "separator": "/" }
14+
},
15+
"codecs": [
16+
{ "name": "bytes", "configuration": { "endian": "little" } },
17+
{ "name": "zstd", "configuration": { "level": 3 } }
18+
],
19+
"dimension_names": ["z", "y", "x"]
20+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"zarr_format": 3,
3+
"node_type": "group",
4+
"attributes": {
5+
"ome": {
6+
"version": "0.6.dev3",
7+
"multiscales": [
8+
{
9+
"name": "multiscales",
10+
"coordinateSystems": [
11+
{
12+
"name": "physical_instrument1",
13+
"axes": [
14+
{ "name": "z", "type": "space", "unit": "micrometer" },
15+
{ "name": "y", "type": "space", "unit": "micrometer" },
16+
{ "name": "x", "type": "space", "unit": "micrometer" }
17+
]
18+
}
19+
],
20+
"datasets": [
21+
{
22+
"path": "s0",
23+
"coordinateTransformations": [
24+
{
25+
"type": "scale",
26+
"input": "s0",
27+
"output": "physical_instrument1",
28+
"scale": [1.0, 1.0, 1.0]
29+
}
30+
]
31+
}
32+
]
33+
}
34+
]
35+
}
36+
}
37+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"zarr_format": 3,
3+
"node_type": "array",
4+
"shape": [4, 4, 4],
5+
"data_type": "uint16",
6+
"fill_value": 0,
7+
"chunk_grid": {
8+
"name": "regular",
9+
"configuration": { "chunk_shape": [2, 2, 2] }
10+
},
11+
"chunk_key_encoding": {
12+
"name": "default",
13+
"configuration": { "separator": "/" }
14+
},
15+
"codecs": [
16+
{ "name": "bytes", "configuration": { "endian": "little" } },
17+
{ "name": "zstd", "configuration": { "level": 3 } }
18+
],
19+
"dimension_names": ["z", "y", "x"]
20+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"zarr_format": 3,
3+
"node_type": "group",
4+
"attributes": {
5+
"ome": {
6+
"version": "0.6.dev3",
7+
"multiscales": [
8+
{
9+
"name": "multiscales",
10+
"coordinateSystems": [
11+
{
12+
"name": "physical_instrument2",
13+
"axes": [
14+
{ "name": "z", "type": "space", "unit": "micrometer" },
15+
{ "name": "y", "type": "space", "unit": "micrometer" },
16+
{ "name": "x", "type": "space", "unit": "micrometer" }
17+
]
18+
}
19+
],
20+
"datasets": [
21+
{
22+
"path": "s0",
23+
"coordinateTransformations": [
24+
{
25+
"type": "scale",
26+
"input": "s0",
27+
"output": "physical_instrument2",
28+
"scale": [1.0, 1.0, 1.0]
29+
}
30+
]
31+
}
32+
]
33+
}
34+
]
35+
}
36+
}
37+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"zarr_format": 3,
3+
"node_type": "group",
4+
"attributes": {
5+
"ome": {
6+
"version": "0.6.dev3",
7+
"scene": {
8+
"coordinateTransformations": [
9+
{
10+
"type": "affine",
11+
"path": "coordinateTransformations/sampleA_instrument2-to-instrument1",
12+
"input": { "path": "sampleA_instrument2", "name": "physical_instrument2" },
13+
"output": { "path": "sampleA_instrument1", "name": "physical_instrument1" }
14+
}
15+
]
16+
}
17+
}
18+
}
19+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"zarr_format": 3,
3+
"node_type": "array",
4+
"shape": [6, 6, 6],
5+
"data_type": "uint16",
6+
"fill_value": 0,
7+
"chunk_grid": {
8+
"name": "regular",
9+
"configuration": { "chunk_shape": [3, 3, 3] }
10+
},
11+
"chunk_key_encoding": {
12+
"name": "default",
13+
"configuration": { "separator": "/" }
14+
},
15+
"codecs": [
16+
{ "name": "bytes", "configuration": { "endian": "little" } },
17+
{ "name": "zstd", "configuration": { "level": 3 } }
18+
],
19+
"dimension_names": ["z", "y", "x"]
20+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"zarr_format": 3,
3+
"node_type": "group",
4+
"attributes": {
5+
"ome": {
6+
"version": "0.6.dev3",
7+
"multiscales": [
8+
{
9+
"name": "multiscales",
10+
"coordinateSystems": [
11+
{
12+
"name": "physical",
13+
"axes": [
14+
{ "name": "z", "type": "space", "unit": "micrometer" },
15+
{ "name": "y", "type": "space", "unit": "micrometer" },
16+
{ "name": "x", "type": "space", "unit": "micrometer" }
17+
]
18+
}
19+
],
20+
"datasets": [
21+
{
22+
"path": "s0",
23+
"coordinateTransformations": [
24+
{
25+
"type": "scale",
26+
"input": "s0",
27+
"output": "physical",
28+
"scale": [1.0, 1.0, 1.0]
29+
}
30+
]
31+
}
32+
]
33+
}
34+
]
35+
}
36+
}
37+
}

0 commit comments

Comments
 (0)