-
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
Universal API implementations for Micro-Manager OME-TIFF and NDTiff #185
Conversation
@JoOkuma Not sure if this is going to work for the DaXi data since I don't have 1024x2048x2048 volumes to test with... |
@ziw-liu, thank you. I'll give it a try soon |
use globals instead of fixtures since parametrization happens before fixture evaluation
@ziw-liu fantastic work across all the layers of I suggest merging when these features are implemented and tested with real data:
I think the following can be future/smaller PRs that quickly follow this:
I don't have input on when it is best to rename methods. Since many users are now finding this PR valuable and will provide input as they use the code, it is smart not to delay the merge. |
@ieivanov Is there any blocking issues left before we are ready to merge this? |
One question / request before I approve - when are the docs rebuilt? It looks like only on a push to |
Currently it is only built when pushing to main. I can attempt to also build for |
@ieivanov I propose that we handle the docs preview in a separate PR so we can easily revert the change after the transition. |
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.
Let's get this PR merged. A few outstanding non-blocking issues from my point of view based on our discussion so far:
- I suggest renaming classes as in Universal API implementations for Micro-Manager OME-TIFF and NDTiff #185 (comment). This does not introduce any use-facing changes, but I think would improve the readability of the code.
- build docs preview showing the new UAPI, to be resolved in a different PR
I think there is a bug / confusion around the
but its parent Should I think there may be a similar issue with |
I like @ieivanov's suggestion; I think |
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.
Once again, I would like to thank @ziw-liu for this PR. It's a huge change and will improve our implementation of downstream image processing/analysis routines.
It closes the Zarr and file issues we raised before.
My concerns are:
- The primary usage of
xdata
on the new FOV classes, which deviates from the common API. From what I chatted with @ziw-liu, this is a requirement for the TIFF data (so it has array-like behavior? I don't remember quite well).
I'm worried some routines start depending on it and, therefore, are not universal, which is the main goal of this PR.
This method could be added toBaseFOV
so every class must implement its ownxdata
method; the downside isBaseFOV
starts deviating slightly from being anArrayLike
object. - The convert function being TIFF specific. The original vision of the universal API was that the conversion function would be
BaseFOVMapping -> BaseFOVMapping
--- despite, in practice, the output type being a subset of all supported types because some are read-only.
This leads me to think that the API isn't universal yet.
I understand that MicroManager-specific features are not available in other classes, but I think these could be wrapped into existingBaseFOVMapping
methods; if that's not the case, theBaseFOVMapping
could be improved.
For MM formats, both FOV and Mapping classes should have the For NDTIFF, I couldn't find a way to get the intended time interval, so the For scaling, I think we should assume homogeneous mappings but allow it to be used for expressing heterogeneous datasets. |
|
Ok, now that I applied closer attention I understand that you're mainly using to_zarr(fov.xdata.data.rechunk(self.chunks), zarr_img) But there isn't an easy way around it. @ziw-liu , I'm very happy with the PR, and for me it's ready to merge and remaining tasks could be converted to issues. |
@ieivanov @JoOkuma @talonchandler Thanks for the reviews! |
commit fac2c13 Author: Ivan Ivanov <[email protected]> Date: Tue Apr 9 11:25:36 2024 -0700 Fix bug reading dragonfly acquisitions (#215) * fix bug reading dragonfly acquisitions * fix typo * style * bugfix commit 0c6984e Author: Ivan Ivanov <[email protected]> Date: Mon Mar 11 12:35:51 2024 -0700 Fix bug determining number of rows and cols (#214) * fix bug determining number of rows and cols * add another XY Stage variation * add docs and fix style commit 3ab89ba Author: Ziwen Liu <[email protected]> Date: Mon Mar 4 11:02:49 2024 -0800 Universal API implementations for Micro-Manager OME-TIFF and NDTiff (#185) * wip: draft mmstack ome-tiff fov * MM FOV base class * tests * bump tifffile * comment * fix indent after rebase * use get default * test pixel indexing * set MM metadata * style * update dependencies * add xarray * move old readers to the `_deprecated` namespace * uapi for ndtiff * refactor test setup to parametrize by dataset use globals instead of fixtures since parametrization happens before fixture evaluation * convert mmstack * fix and test chunking * fix metadata conversion and test ndtiff * update cli * fix scaling * test 1.4 and incomplete ome-tiffs * move reader tests * deprecate reader tests * update deprecated tests * update ngff tests * isort * update black target to 3.10 * lint * fix download paths * update docs references and theme * untrack autogenerated file * ignore execution time file * add github icon * update docstring * update docstring * show channel names and chunk size in info * print plate chunk size if verbose * fallback for pixel size * remove log level setting * do not filter logs and warnings in reader * avoid root logger * isort * set default logging level to INFO * format docstring * improve conversion messages * black * fix ome-tiff channel name indexing * fix ndtiff channel name indexing * update converter test * remove use of os.path in `reader` * expand _check_ndtiff checks * fix iteration * fix python 3.10 using `Path.glob(*/)` to get subdirs was added in 3.11 * bump zarr version to include resizing fix zarr-developers/zarr-python#1540 * fix cli default * set log level with an environment variable * fix unset * catch non-existent page * implement fallback for incomplete channel names workaround for the Dragonfly microscope where the multi-camera setup only has one channel name written * add debug logs * handle virtual frames * try reading pages from TiffFile directly * filter error logs about ImageJ metadata being broken this is a known MM limitation when writing OME-TIFFs * fix regex * remove use of os.path in `convert.py` * better channel indexing in `_get_summary_metadata` * style * safer NoneType check * private default axis names for NDTiff * update documentation to reflect new entry point * add repr to MM FOV and dataset types * rename mm_meta and expose summary metadata * add MicroManagerFOVMapping.root * add MicroManagerFOVMapping.zyx_scale * add warning log for failed position grid * fix grid layout * suppress hypothesis flakiness * different health check suppression --------- Co-authored-by: Ivan Ivanov <[email protected]>
* wip: draft mmstack ome-tiff fov * MM FOV base class * tests * bump tifffile * comment * fix indent after rebase * use get default * test pixel indexing * set MM metadata * style * update dependencies * add xarray * move old readers to the `_deprecated` namespace * uapi for ndtiff * refactor test setup to parametrize by dataset use globals instead of fixtures since parametrization happens before fixture evaluation * convert mmstack * fix and test chunking * fix metadata conversion and test ndtiff * update cli * fix scaling * test 1.4 and incomplete ome-tiffs * move reader tests * deprecate reader tests * update deprecated tests * update ngff tests * isort * update black target to 3.10 * lint * fix download paths * update docs references and theme * untrack autogenerated file * ignore execution time file * add github icon * update docstring * update docstring * show channel names and chunk size in info * print plate chunk size if verbose * fallback for pixel size * remove log level setting * do not filter logs and warnings in reader * avoid root logger * isort * set default logging level to INFO * format docstring * improve conversion messages * black * fix ome-tiff channel name indexing * fix ndtiff channel name indexing * update converter test * remove use of os.path in `reader` * expand _check_ndtiff checks * fix iteration * fix python 3.10 using `Path.glob(*/)` to get subdirs was added in 3.11 * bump zarr version to include resizing fix zarr-developers/zarr-python#1540 * fix cli default * set log level with an environment variable * fix unset * catch non-existent page * implement fallback for incomplete channel names workaround for the Dragonfly microscope where the multi-camera setup only has one channel name written * add debug logs * handle virtual frames * try reading pages from TiffFile directly * filter error logs about ImageJ metadata being broken this is a known MM limitation when writing OME-TIFFs * fix regex * remove use of os.path in `convert.py` * better channel indexing in `_get_summary_metadata` * style * safer NoneType check * private default axis names for NDTiff * sort metadata keys * Squashed commit of the following: commit fac2c13 Author: Ivan Ivanov <[email protected]> Date: Tue Apr 9 11:25:36 2024 -0700 Fix bug reading dragonfly acquisitions (#215) * fix bug reading dragonfly acquisitions * fix typo * style * bugfix commit 0c6984e Author: Ivan Ivanov <[email protected]> Date: Mon Mar 11 12:35:51 2024 -0700 Fix bug determining number of rows and cols (#214) * fix bug determining number of rows and cols * add another XY Stage variation * add docs and fix style commit 3ab89ba Author: Ziwen Liu <[email protected]> Date: Mon Mar 4 11:02:49 2024 -0800 Universal API implementations for Micro-Manager OME-TIFF and NDTiff (#185) * wip: draft mmstack ome-tiff fov * MM FOV base class * tests * bump tifffile * comment * fix indent after rebase * use get default * test pixel indexing * set MM metadata * style * update dependencies * add xarray * move old readers to the `_deprecated` namespace * uapi for ndtiff * refactor test setup to parametrize by dataset use globals instead of fixtures since parametrization happens before fixture evaluation * convert mmstack * fix and test chunking * fix metadata conversion and test ndtiff * update cli * fix scaling * test 1.4 and incomplete ome-tiffs * move reader tests * deprecate reader tests * update deprecated tests * update ngff tests * isort * update black target to 3.10 * lint * fix download paths * update docs references and theme * untrack autogenerated file * ignore execution time file * add github icon * update docstring * update docstring * show channel names and chunk size in info * print plate chunk size if verbose * fallback for pixel size * remove log level setting * do not filter logs and warnings in reader * avoid root logger * isort * set default logging level to INFO * format docstring * improve conversion messages * black * fix ome-tiff channel name indexing * fix ndtiff channel name indexing * update converter test * remove use of os.path in `reader` * expand _check_ndtiff checks * fix iteration * fix python 3.10 using `Path.glob(*/)` to get subdirs was added in 3.11 * bump zarr version to include resizing fix zarr-developers/zarr-python#1540 * fix cli default * set log level with an environment variable * fix unset * catch non-existent page * implement fallback for incomplete channel names workaround for the Dragonfly microscope where the multi-camera setup only has one channel name written * add debug logs * handle virtual frames * try reading pages from TiffFile directly * filter error logs about ImageJ metadata being broken this is a known MM limitation when writing OME-TIFFs * fix regex * remove use of os.path in `convert.py` * better channel indexing in `_get_summary_metadata` * style * safer NoneType check * private default axis names for NDTiff * update documentation to reflect new entry point * add repr to MM FOV and dataset types * rename mm_meta and expose summary metadata * add MicroManagerFOVMapping.root * add MicroManagerFOVMapping.zyx_scale * add warning log for failed position grid * fix grid layout * suppress hypothesis flakiness * different health check suppression --------- Co-authored-by: Ivan Ivanov <[email protected]> * black * bugfix --------- Co-authored-by: Ziwen Liu <[email protected]>
Implements universal API (UAPI) for MMStack (Micro-Manager OME-TIFF) and NDTiff (written by MM and pycro-manager). This PR contains many breaking changes and is geared towards the v0.2.0 release.
Unresolved issues
User-facing changes
API
read_micromanager
toread_images
extract_data
andformat
argumentsmultipagetiff.MicromanagerOmeTiffReader
withmmstack.MMStack
_set_mm_meta
inBaseReader
and its children #85 (@JoOkuma)[..., "Channel2", "Channel3", ...]
. Note that this will be incorrect if the partially available channel names do not start with the first channel or if they are not contiguous. A warning will be logged and the user is responsible to correct this downstream.ndtiff.NDTiffReader
withndtiff.NDTiffDataset
['Channel0', 'Channel1', ...]
instead of['0', '1', ...]
frame_metadata
object as proposed in Per-frame metadata in UAPI #155_deprecated
namespace1.0
and log a warning.iohub info
fails on MM datasets withoutxy_pixel_size
#180 (@talonchandler)convert.TIFFConverter.run()
toconvert.TIFFConverter.__call__()
CLI
convert
command--format
is always auto-inferred--scale-voxels
is always TRUE--check-image
is always FALSE--chunks
now works for both NDTiff and OME-TIFFIOHUB_LOG_LEVEL=DEBUG
Documentation
Technical changes
TiffZarrStore
to acheive lazy loading of OME-TIFF. The custom index map parsing is removed.xdata
attribute gives access to the underlying xarray object.)conftest.py
with globals since parametrization happens before fixture is availableNotes
Many issues are linked to be closed by this PR.
Reviewers: please check the boxes and leave a sign-off when an issue has been verified to be fixed.