-
Notifications
You must be signed in to change notification settings - Fork 7
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
Convert scale metadata #118
Conversation
only implemented for MM OME-TIFF and NDTiff, not for single-page TIFF Signed-off-by: Ziwen Liu <67518483+ziw-liu@users.noreply.github.com>
Convert one of the test datasets:
Check the converted dataset in napari: And we get a scale bar in microns! |
This looks nice! Can |
I made the CLI flag opt-in so that it's default behavior doesn't change. Also it does not work for all datasets so it might be confusing if it fails to find the metadata and just refuse to convert. But then I actually made it the default on the python API side... This inconsistency should be fixed and I'm not sure which one is better. |
Agreed, looks very promising! I would vote with Ivan for
Maybe throw a warning if the metadata isn't present and continue with the conversion? You could just write ones for the scales if the metadata isn't present. |
That's the current implementation. |
Also a note about why I'm matching OME-XML with some hand-crafted regex and not using ome-types. The data we have off of MM seems to be non-standard/corrupted/outdated (#66) enough that ome-types throws pydantic |
A problem is that it is far more intuitive and easier to document/troubleshoot to add feature flags in CLI commands than it is to turn off a default behavior that fails and throws up a scary stack trace. For example having to do |
The HCS grid layout is taken from the metadata too right? |
Not necessarily. By default it will dump everything into a single row. If the |
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 tested this branch on an ome-tiff dataset and the conversion failed (same result with and without --scale-voxels
). Am I using something incorrectly? Thanks @ziw-liu.
iohub convert -i 2022_08_04_recOrder_pytest_20x_04NA/2T_3P_16Z_128Y_256X_Kazansky_1/ -o ./test.zarr
Traceback (most recent call last):
File "/opt/anaconda3/envs/iohub/bin/iohub", line 8, in <module>
sys.exit(cli())
File "/opt/anaconda3/envs/iohub/lib/python3.9/site-packages/click/core.py", line 1130, in __call__
return self.main(*args, **kwargs)
File "/opt/anaconda3/envs/iohub/lib/python3.9/site-packages/click/core.py", line 1055, in main
rv = self.invoke(ctx)
File "/opt/anaconda3/envs/iohub/lib/python3.9/site-packages/click/core.py", line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/opt/anaconda3/envs/iohub/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/opt/anaconda3/envs/iohub/lib/python3.9/site-packages/click/core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "/Users/talon.chandler/iohub/iohub/cli/cli.py", line 86, in convert
converter = TIFFConverter(
File "/Users/talon.chandler/iohub/iohub/convert.py", line 105, in __init__
self.reader = read_micromanager(
File "/Users/talon.chandler/iohub/iohub/reader.py", line 201, in read_micromanager
return MicromanagerOmeTiffReader(path, extract_data)
File "/Users/talon.chandler/iohub/iohub/multipagetiff.py", line 53, in __init__
self._infer_image_meta()
File "/Users/talon.chandler/iohub/iohub/multipagetiff.py", line 300, in _infer_image_meta
self.xy_pixel_size = float(xy_size.group())
AttributeError: 'NoneType' object has no attribute 'group'
Now scaling is the default in CLI.
The dataset is missing the metadata field. I couldn't find another field that carries the value, so maybe the microscope was not calibrated to begin with. Now it will convert but log a warning. |
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.
Thanks for fixing the default behavior so that it doesn't fail when metadata is absent.
I have a suggestion for a better field to transfer from MM...see my comment.
Convert pixel and z-step sizes to scale transform in NGFF metadata.
Only implemented for MM OME-TIFF and NDTiff, not for single-page TIFF.
Partial implementation of #103.