Skip to content
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

Improved zarr to multidimensional tiff converter #13

Merged
merged 9 commits into from
Mar 18, 2025

Conversation

maartenpaul
Copy link
Member

Enhanced OME-Zarr to TIFF Conversion for Microscopy Images

This PR enhances the zarr-to-tiff conversion tool by adding robust dimension handling for OME-Zarr files.

Key Changes:

  1. Added OME-Zarr metadata extraction:

    • New function get_dimension_order() to extract dimension ordering from OME-Zarr metadata
    • Preserves original dimension information for more accurate conversions
  2. Improved dimension handling:

    • Replaced hard-coded dimension transposition with metadata-aware processing
    • Added functions to normalize dimensions based on actual OME-Zarr structure
    • Better handles various dimension combinations (time series, channels, z-stacks)
  3. Enhanced metadata preservation:

    • The conversion now generates proper OME metadata in the output TIFF
    • Dimension axis information is carried through to the output file

This approach results in more accurate conversions, especially for time series and multi-channel files, while maintaining backward compatibility with existing workflows.

Copy link
Collaborator

@TorecLuik TorecLuik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ziet er goed uit, met een paar opmerkingen.

Ik zal 'm binnenkort eens testen

if output_file is None:
output_file = os.path.splitext(zarr_file_path)[0] + f".{key}.tif"
if output_file is None:
#to make it easier to work with current BIOMERO workflow save as tif instead of ome.tif
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hebben we geen support voor .ome.tiff files?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Die dubbele extensies zijn niet erg handig om mee te werken, dus voor convenience sla ik nu op als .tif, zodat het werkt met de current workflow. Ik weet niet of wat ik doe ook volledig voldoet aan de ome.tif standaard. Ik voeg alleen axes metadata toe.

dask_image_data.persist()
# to imagej tiff to be handled by cellprofiler wf wrt multiple channels
tf.imwrite(output_file, dask_image_data,
planarconfig='contig', imagej=True)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wordt dit een probleem, dat het geen multipage imagej tiff meer is? Had je 'm al getest met de cellprofiler pipelines?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ik zal hem testen met Cellprofiler. Heb hem nu getest met de originele stardist en cellpose containers, dat ging goed (met 2D images dan).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Het werkt met de cellprofiler spot analyse, behalve dat de output van Cellprofiler bij mij .txt files geeft ipv .csv's. Maar dat lijkt me iets anders.
Wel kom ik er nu achter dat de converter nog niet goed werkt met multichannel 2D tiffs met Cellpose...
Ik ga erna kijken...

@TorecLuik TorecLuik merged commit 1a8b6f5 into NL-BioImaging:main Mar 18, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants