-
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.
fix: ngff multiscales and relative group path handling on windows
* test: build ngff multiscales v0.4 metadata * fix: use MetadataUtils.relative paths where applicable * fix: MetadataUtils relativePath for windows * style: formatting * doc: MetadataUtils relativePath
- Loading branch information
Showing
4 changed files
with
143 additions
and
77 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
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
65 changes: 65 additions & 0 deletions
65
...t/java/org/janelia/saalfeldlab/n5/universe/metadata/ome/ngff/v04/BuildMultiscaleTest.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,65 @@ | ||
package org.janelia.saalfeldlab.n5.universe.metadata.ome.ngff.v04; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import org.janelia.saalfeldlab.n5.N5URI; | ||
import org.janelia.saalfeldlab.n5.universe.metadata.axes.Axis; | ||
import org.janelia.saalfeldlab.n5.universe.metadata.axes.AxisUtils; | ||
import org.junit.Test; | ||
|
||
public class BuildMultiscaleTest { | ||
|
||
@Test | ||
public void buildNgffMultiscale() { | ||
|
||
testHelper("", new String[]{"s0", "s1", "s2", "s3"}); | ||
|
||
testHelper("a", new String[]{"s0", "s1", "s2", "s3"}); | ||
testHelper("a/b", new String[]{"s0", "s1", "s2", "s3"}); | ||
testHelper("a/b/c", new String[]{"s0", "s1", "s2", "s3"}); | ||
|
||
testHelper("a", new String[]{"0/s0", "0/s1", "0/s2", "0/s3"}); | ||
} | ||
|
||
private static void testHelper(final String path, final String[] childPaths) { | ||
|
||
final String downsampleMethod = "sampling"; | ||
final Axis[] axes = AxisUtils.buildAxes("x", "y", "z"); | ||
final OmeNgffMultiScaleMetadataMutable ms = new OmeNgffMultiScaleMetadataMutable(path); | ||
|
||
for (int i = 0; i < childPaths.length; i++) { | ||
final double s = Math.pow(2, i); | ||
ms.addChild(buildScaleLevelMetadata(childPaths[i], new double[]{s, s, s}, axes)); | ||
} | ||
|
||
final OmeNgffMultiScaleMetadata meta = new OmeNgffMultiScaleMetadata(ms.getAxes().length, | ||
path, path, downsampleMethod, "0.4", | ||
ms.getAxes(), | ||
ms.getDatasets(), null, | ||
ms.coordinateTransformations, ms.metadata, true); | ||
|
||
for (int i = 0; i < childPaths.length; i++) { | ||
assertEquals( | ||
String.format("multiscale path incorrect for root: %s, child: %s", path, childPaths[i]), | ||
childPaths[i], meta.getDatasets()[i].path); | ||
} | ||
|
||
// test building children from multiscales | ||
// these metadata's path variables must be relative to the root | ||
final NgffSingleScaleAxesMetadata[] children = OmeNgffMultiScaleMetadata.buildMetadata(3, path, null, meta); | ||
for (int i = 0; i < childPaths.length; i++) { | ||
// ensure the paths are equal up to normalization | ||
assertEquals( | ||
String.format("single scale path incorrect for root: %s, child: %s", path, childPaths[i]), | ||
N5URI.normalizeGroupPath(path + "/" + childPaths[i]), | ||
N5URI.normalizeGroupPath(children[i].getPath())); | ||
} | ||
} | ||
|
||
private static NgffSingleScaleAxesMetadata buildScaleLevelMetadata(final String path, final double[] res, | ||
final Axis[] axes) { | ||
|
||
return new NgffSingleScaleAxesMetadata(path, res, null, axes, null); | ||
} | ||
|
||
} |