ImageJ export: preserve physical size units #3295
Merged
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.
See #3127
Both the physical sizes and units are now taken from the ImagePlus' Calibration. This should have no impact on the common case where physical sizes are unchanged after import, but should fix the case when units are changed after import.
To test, make sure that the original bug is fixed by running the macro in #3127 with this change.
showinf -omexml
on the resulting file should also confirm that the correct physical sizes are stored. Also test with line 12 of the macro commented out (the firstrun("Properties..." ...
) and uncommented but with a unit that obviously cannot be mapped to an OME unit (I triedunit=december
). Opening files using the Bio-Formats importer plugin and then exporting again should also continue to work as before.Not sure if there are any other use cases to consider, or if/how this differs from the NPE-producing test mentioned in #3127 (comment).
ImageJ allows the specified units to be free-form, so I do wonder if we should be doing any extra checking/logging in the case where a unit string cannot be mapped to real unit enum (as in the
unit=december
test above).