-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: ngff v0.4 coordinate transform parsing
see #17
- Loading branch information
Showing
17 changed files
with
258 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
...janelia/saalfeldlab/n5/universe/metadata/ome/ngff/v04/CoordinateTransformParsingTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package org.janelia.saalfeldlab.n5.universe.metadata.ome.ngff.v04; | ||
|
||
import static org.junit.Assert.assertArrayEquals; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import java.net.URI; | ||
import java.nio.file.Paths; | ||
import java.util.Optional; | ||
|
||
import org.janelia.saalfeldlab.n5.DataType; | ||
import org.janelia.saalfeldlab.n5.DatasetAttributes; | ||
import org.janelia.saalfeldlab.n5.N5Reader; | ||
import org.janelia.saalfeldlab.n5.RawCompression; | ||
import org.janelia.saalfeldlab.n5.universe.N5Factory; | ||
import org.janelia.saalfeldlab.n5.universe.N5TreeNode; | ||
import org.janelia.saalfeldlab.n5.universe.metadata.N5SingleScaleMetadata; | ||
import org.junit.Test; | ||
|
||
import net.imglib2.realtransform.AffineGet; | ||
import net.imglib2.realtransform.AffineTransform3D; | ||
import net.imglib2.realtransform.ScaleAndTranslation; | ||
|
||
public class CoordinateTransformParsingTest { | ||
|
||
private static final double EPS = 1E-6; | ||
|
||
@Test | ||
public void testCoordinateTransformParsing() { | ||
|
||
URI rootF = Paths.get("src", "test", "resources", "metadata.zarr").toUri(); | ||
final N5Reader zarr = new N5Factory().openReader(rootF.toString()); | ||
|
||
final OmeNgffMetadataParser grpParser = new OmeNgffMetadataParser(); | ||
test(grpParser.parseMetadata(zarr, setupNode("coordTforms/ss", "s0")), | ||
new double[]{4, 4}, | ||
new double[]{0, 0}); | ||
|
||
test(grpParser.parseMetadata(zarr, setupNode("coordTforms/st", "s0")), | ||
new double[]{2, 2}, | ||
new double[]{10, 10}); | ||
|
||
test(grpParser.parseMetadata(zarr, setupNode("coordTforms/ts", "s0")), | ||
new double[]{2, 2}, | ||
new double[]{20, 20}); | ||
|
||
test(grpParser.parseMetadata(zarr, setupNode("coordTforms/tt", "s0")), | ||
new double[]{1, 1}, | ||
new double[]{20, 20}); | ||
} | ||
|
||
private void test(final Optional<OmeNgffMetadata> metaOpt, final double[] expectedScale, final double[] expectedTranslation) { | ||
|
||
assertTrue("ss not parsable", metaOpt.isPresent()); | ||
|
||
final OmeNgffMetadata meta = metaOpt.get(); | ||
final AffineGet[] tforms = meta.spatialTransforms(); | ||
assertTrue("ss has one transform", tforms.length == 1); | ||
|
||
final ScaleAndTranslation tform = (ScaleAndTranslation)tforms[0]; | ||
assertArrayEquals(expectedScale, tform.getScaleCopy(), EPS); | ||
assertArrayEquals(expectedTranslation, tform.getTranslationCopy(), EPS); | ||
} | ||
|
||
private N5TreeNode setupNode(final String path, final String childPath) { | ||
|
||
final N5TreeNode node = new N5TreeNode(path); | ||
final N5TreeNode child = new N5TreeNode(path + "/" + childPath); | ||
final DatasetAttributes attrs = new DatasetAttributes(new long[]{4, 4}, new int[]{4, 4}, DataType.UINT8, new RawCompression()); | ||
child.setMetadata(new N5SingleScaleMetadata(path + "/" + childPath, new AffineTransform3D(), | ||
new double[]{1, 1}, new double[]{1, 1}, new double[]{0, 0}, "", attrs, false)); | ||
|
||
node.add(child); | ||
return node; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"zarr_format":2} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"zarr_format":2} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"multiscales": [ | ||
{ | ||
"name": "boats", | ||
"type": "Average", | ||
"version": "0.4", | ||
"axes": [ | ||
{ | ||
"type": "space", | ||
"name": "y", | ||
"unit": "pixel" | ||
}, | ||
{ | ||
"type": "space", | ||
"name": "x", | ||
"unit": "pixel" | ||
} | ||
], | ||
"datasets": [ | ||
{ | ||
"path": "s0", | ||
"coordinateTransformations": [ | ||
{ | ||
"scale": [ | ||
2, | ||
2 | ||
], | ||
"type": "scale" | ||
}, | ||
{ | ||
"scale": [ | ||
2, | ||
2 | ||
], | ||
"type": "scale" | ||
} | ||
] | ||
} | ||
], | ||
"coordinateTransformations": [] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"zarr_format":2} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"zarr_format":2,"shape":[576,720],"chunks":[16,16],"dtype":"|u1","compressor":{"id":"gzip","level":-1},"fill_value":"0","filters":[],"order":"C","dimension_separator":"/"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"multiscales": [ | ||
{ | ||
"name": "boats", | ||
"type": "Average", | ||
"version": "0.4", | ||
"axes": [ | ||
{ | ||
"type": "space", | ||
"name": "y", | ||
"unit": "pixel" | ||
}, | ||
{ | ||
"type": "space", | ||
"name": "x", | ||
"unit": "pixel" | ||
} | ||
], | ||
"datasets": [ | ||
{ | ||
"path": "s0", | ||
"coordinateTransformations": [ | ||
{ | ||
"scale": [ | ||
2, | ||
2 | ||
], | ||
"type": "scale" | ||
}, | ||
{ | ||
"translation": [ | ||
10, | ||
10 | ||
], | ||
"type": "translation" | ||
} | ||
] | ||
} | ||
], | ||
"coordinateTransformations": [] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"zarr_format":2} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"zarr_format":2,"shape":[576,720],"chunks":[16,16],"dtype":"|u1","compressor":{"id":"gzip","level":-1},"fill_value":"0","filters":[],"order":"C","dimension_separator":"/"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"multiscales": [ | ||
{ | ||
"name": "boats", | ||
"type": "Average", | ||
"version": "0.4", | ||
"axes": [ | ||
{ | ||
"type": "space", | ||
"name": "y", | ||
"unit": "pixel" | ||
}, | ||
{ | ||
"type": "space", | ||
"name": "x", | ||
"unit": "pixel" | ||
} | ||
], | ||
"datasets": [ | ||
{ | ||
"path": "s0", | ||
"coordinateTransformations": [ | ||
{ | ||
"translation": [ | ||
10, | ||
10 | ||
], | ||
"type": "translation" | ||
}, | ||
{ | ||
"scale": [ | ||
2, | ||
2 | ||
], | ||
"type": "scale" | ||
} | ||
] | ||
} | ||
], | ||
"coordinateTransformations": [] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"zarr_format":2} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"zarr_format":2,"shape":[576,720],"chunks":[16,16],"dtype":"|u1","compressor":{"id":"gzip","level":-1},"fill_value":"0","filters":[],"order":"C","dimension_separator":"/"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"multiscales": [ | ||
{ | ||
"name": "boats", | ||
"type": "Average", | ||
"version": "0.4", | ||
"axes": [ | ||
{ | ||
"type": "space", | ||
"name": "y", | ||
"unit": "pixel" | ||
}, | ||
{ | ||
"type": "space", | ||
"name": "x", | ||
"unit": "pixel" | ||
} | ||
], | ||
"datasets": [ | ||
{ | ||
"path": "s0", | ||
"coordinateTransformations": [ | ||
{ | ||
"translation": [ | ||
10, | ||
10 | ||
], | ||
"type": "translation" | ||
}, | ||
{ | ||
"translation": [ | ||
10, | ||
10 | ||
], | ||
"type": "translation" | ||
} | ||
] | ||
} | ||
], | ||
"coordinateTransformations": [] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"zarr_format":2} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"zarr_format":2,"shape":[576,720],"chunks":[16,16],"dtype":"|u1","compressor":{"id":"gzip","level":-1},"fill_value":"0","filters":[],"order":"C","dimension_separator":"/"} |