-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: build ngff multiscales v0.4 metadata #15
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
0a16e71
test: build ngff multiscales v0.4 metadata
bogovicj 2e642a1
fix: toward fixing ngff multiscales paths on windows
bogovicj 561a636
fix: use MetadataUtils.relative paths where applicable
bogovicj 54cb8b4
test: ngff-multiscales better assert messages
bogovicj 82d7ea2
fix: MetadataUtils relativePath for windows
bogovicj 3f5afe0
style: formatting
bogovicj 2bac7a8
doc: MetadataUtils relativePath
bogovicj e43f962
fix: relativePath regexp
bogovicj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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); | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bogovicj this text does not really seem to make sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe:
Given an absolute child path and a parent path, it returns the child path relativized with respect to the parent path. If the parent is in fact not a parent of the child, the child path is return as is.