-
Notifications
You must be signed in to change notification settings - Fork 35
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
Store dimension order using new "axes" spec #121
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
475a9aa
Store dimension order using new "axes" spec
melissalinkert 990b688
Check "axes" metadata in existing multiscales/dimension order tests
melissalinkert 2dc3d70
Merge branch 'master' of github.com:glencoesoftware/bioformats2raw in…
melissalinkert 7595d77
Fix axes metadata when dimensionOrder is null
melissalinkert fa6dd05
Add test for axes metadata when using "--dimension-order original"
melissalinkert 8f430e2
Don't set _ARRAY_DIMENSIONS attribute
melissalinkert 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1220,7 +1220,8 @@ public void saveResolutions(int series) | |
.nested(nested) | ||
.compressor(CompressorFactory.create( | ||
compressionType.toString(), compressionProperties)); | ||
ZarrArray.create(getRootPath().resolve(resolutionString), arrayParams); | ||
ZarrArray.create(getRootPath().resolve(resolutionString), | ||
arrayParams, getArrayAttributes()); | ||
|
||
nTile = new AtomicInteger(0); | ||
tileCount = (int) Math.ceil((double) scaledWidth / tileWidth) | ||
|
@@ -1472,9 +1473,10 @@ private void saveHCSMetadata(IMetadata meta) throws IOException { | |
* @param resolutions Total number of resolutions from which | ||
* names will be generated. | ||
* @throws IOException | ||
* @throws InterruptedException | ||
*/ | ||
private void setSeriesLevelMetadata(int series, int resolutions) | ||
throws IOException | ||
throws IOException, InterruptedException | ||
{ | ||
LOGGER.debug("setSeriesLevelMetadata({}, {})", series, resolutions); | ||
String resolutionString = String.format( | ||
|
@@ -1514,6 +1516,37 @@ private void setSeriesLevelMetadata(int series, int resolutions) | |
datasets.add(Collections.singletonMap("path", lastPath)); | ||
} | ||
multiscale.put("datasets", datasets); | ||
|
||
String axisOrder = null; | ||
if (dimensionOrder != null) { | ||
axisOrder = dimensionOrder.toString(); | ||
} | ||
else { | ||
IFormatReader reader = readers.take(); | ||
try { | ||
axisOrder = reader.getDimensionOrder(); | ||
} | ||
finally { | ||
readers.put(reader); | ||
} | ||
} | ||
List<Map<String, String>> axes = new ArrayList<Map<String, String>>(); | ||
for (int i=axisOrder.length()-1; i>=0; i--) { | ||
String axis = axisOrder.substring(i, i + 1).toLowerCase(); | ||
String type = "space"; | ||
if (axis.equals("t")) { | ||
type = "time"; | ||
} | ||
else if (axis.equals("c")) { | ||
type = "channel"; | ||
} | ||
Map<String, String> thisAxis = new HashMap<String, String>(); | ||
thisAxis.put("name", axis); | ||
thisAxis.put("type", type); | ||
axes.add(thisAxis); | ||
} | ||
multiscale.put("axes", axes); | ||
|
||
Path subGroupPath = getRootPath().resolve(seriesString); | ||
LOGGER.debug(" creating subgroup {}", subGroupPath); | ||
ZarrGroup subGroup = ZarrGroup.create(subGroupPath); | ||
|
@@ -1761,6 +1794,28 @@ private Class<?> getBaseReaderClass() throws FormatException, IOException { | |
} | ||
} | ||
|
||
private Map<String, Object> getArrayAttributes() throws InterruptedException { | ||
Map<String, Object> attrs = new HashMap<String, Object>(); | ||
String order = null; | ||
if (dimensionOrder != null) { | ||
order = dimensionOrder.toString(); | ||
} | ||
else { | ||
IFormatReader reader = readers.take(); | ||
try { | ||
order = reader.getDimensionOrder(); | ||
} | ||
finally { | ||
readers.put(reader); | ||
} | ||
} | ||
|
||
String[] axes = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As mentioned yesterday and as per ome/ngff#96, this block is no longer a requirement of the specification (and is effectively broken in the default layout) so we can safely remove it. |
||
new StringBuilder(order.toLowerCase()).reverse().toString().split(""); | ||
attrs.put("_ARRAY_DIMENSIONS", axes); | ||
return attrs; | ||
} | ||
|
||
/** | ||
* Check if the given metadata object contains at least one plate | ||
* with at least one well that links to an image. | ||
|
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
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.
Under which case would
dimensionOrder
benull
? In this scenario, the multi-scale would contain noaxes
and be invalid or can we infer a default value?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.
I think I originally assumed here that
dimensionOrder
can't really be null, and this is just being extra safe. Going back and looking at the history of the--dimension-order
option though,dimensionOrder
can be null if--dimension-order original
is used. In that case, you're correct that theaxes
metadata is missing, so I need to fix that here.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.
7595d77 should fix this so that
axes
is populated for any value ofdimensionOrder
.