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

OME-TIFF Read / Write #819

Merged
merged 40 commits into from
Jan 20, 2023
Merged

OME-TIFF Read / Write #819

merged 40 commits into from
Jan 20, 2023

Conversation

srivarra
Copy link
Contributor

@srivarra srivarra commented Nov 10, 2022

  • added OME-TIFF support

If you haven't already, please read through our contributing guidelines before opening your PR

What is the purpose of this PR?

Closes #807. Adds support for converting a FOV to an OME-TIFF and vice versa.

How did you implement your changes

Added two functions, fov_to_ome and ome_to_fov in load_utils.py.( moved to tmi)

  • fov_to_ome: Can convert multiple FOVs with whatever channels necessary to OME-TIFFs
  • ome_to_fov: Can only convert one OME-TIFF to a FOV.
  • Added a Jupyter Notebook which walks users through the conversion process.
  • Added an OME-TIFF into the Example Dataset.

Remaining issues

@srivarra srivarra added the enhancement New feature or request label Nov 10, 2022
@srivarra srivarra self-assigned this Nov 10, 2022
@srivarra srivarra marked this pull request as ready for review November 10, 2022 21:47
Copy link
Member

@ngreenwald ngreenwald left a comment

Choose a reason for hiding this comment

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

Looks good

requirements.txt Show resolved Hide resolved
ark/utils/load_utils.py Outdated Show resolved Hide resolved
@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@srivarra
Copy link
Contributor Author

@cliu72 I've added a short utility notebook which walks a user through the conversion process. Let me know your thoughts!

Copy link
Contributor

@cliu72 cliu72 left a comment

Choose a reason for hiding this comment

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

This looks good to me! I think it would be good to include in the notebook description that the conversion is to single-channel TIFs, instead of ambiguously saying it's in a format for ark. Maybe something like: "This notebook is used to convert an OME-TIFF into single-channel TIFFs (one TIFF per marker), which is the format used throughout Ark-Analysis."

Also, I think it would be good to have a more descriptive title for the notebook - like "OME-TIFF_Converter" or something like that?

Is there also going to be a notebook going the other way (i.e. single channel -> OME), or is that going to be a task for later? (I only need this one for my paper so I don't really care lol)

alex-l-kong and others added 7 commits November 21, 2022 09:39
…786)

* Initial commit of replacing _feature_0 with _whole_cell and _feature_1 with _nuclear

* Make sure dataset tests include _whole_cell and _nuclear

* Update distance matrix column to be dist_whole_cell

* Patch up marker quantification loading

* Ensure channels for stitch_images test are being passed in correctly

* Rename segmentation label saving to _whole_cell and _nuclear

* Define both the whole cell and nuclear suffix renaming choices for create_deepcell_output

* Change revision to match current PR on HuggingFace with new suffix names

* Patch up calc_dist_matrix suffix

* PYCODESTYLE in data_utils.py

* Patch up deepcell_utils

* Use new HuggingFace commit hash without hidden old files

* Change legacy example_dataset extensions to _whole_cell.tiff

* Make sure neighborhood mask uses _whole_cell.tiff

* Update comment to _whole_cell.tiff too

* Aesthetics

* Patch _feature_0 to _whole_cell to pass neighborhood mask generation test

* Change suffix in the README

* Refer to main branch for HuggingFace
renamed utility notebook
@srivarra srivarra requested a review from cliu72 November 21, 2022 22:19
@srivarra
Copy link
Contributor Author

srivarra commented Dec 6, 2022

@cliu72 I fixed the issue for reading the second image. You need the imagecodecs library in order to decompress the first image (the second image requires it as well).

imagecodecs does not have a native Apple Silicon PYPI build, that architecture's version is only available through Anaconda, but for any other platform it should be pip installable.

Also the Example Dataset does not include any OME-TIFFS, would you like a few of those in for this converter notebook in particular?

@cliu72
Copy link
Contributor

cliu72 commented Dec 13, 2022

If it's not too much work, can we add an example OME-TIFF? I think you can just take one of the example FOVs, use this notebook to create the OME-TIFF, and then add it to the example dataset. I think just one FOV would be fine.

And then can we move the cell to download the example dataset to the relevant sections? I.e. move the get_example_dataset for single channel TIFFs to the section "Single Channel TIFFs to OME-TIFF", and then add the cell to get the example OME-TIFF to the first section. Since presumably most users will be only doing one of the two.

@srivarra
Copy link
Contributor Author

@cliu72 Dataset is available on this branch, Need to fix a couple of tests, but you can use it with the conversion notebook.

@cliu72
Copy link
Contributor

cliu72 commented Dec 15, 2022

Sweet, looks good!

Last thing, can we add more description to before the cell to download the example dataset? Maybe so it looks like this:

OME-TIFF to Single Channel TIFFs

If you would like to test this feature using an example dataset, run the cell below. To use your own data, skip the cell below and change ome_dir_path and data_dir_path below to point to your own data.

example_dataset.get_example_dataset(dataset="ome_tiff", save_dir = pathlib.Path("../data/example_dataset/"), overwrite_existing = True)

[rest of the code]

Single Channel TIFFs to OME-TIFF

If you would like to test this feature using an example dataset, run the cell below. To use your own data, skip the cell below and change data_dir and save_dir below to point to your own data.

[rest of the code]

Copy link
Contributor

@cliu72 cliu72 left a comment

Choose a reason for hiding this comment

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

Not sure if there are remaining merge/example dataset issues to resolve, but I think this looks good to me

Copy link
Member

@ngreenwald ngreenwald left a comment

Choose a reason for hiding this comment

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

There are some merge conflicts that need to be addressed. It will also change the requirements, which will require a new docker. We'll discuss at our meeting today if it makes sense to get all that done today, or wait till after the closure

@srivarra srivarra requested a review from ngreenwald January 9, 2023 23:00
@srivarra
Copy link
Contributor Author

srivarra commented Jan 9, 2023

@ngreenwald Missing some coverage, as I'm not able to create ome-tiffs with tifffile that have a slightly different format (i.e. a couple of the example ones that @cliu72 tested out).

Copy link
Member

@ngreenwald ngreenwald left a comment

Choose a reason for hiding this comment

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

Code looks good, but I think we should hold off on adding TMI and making other changes until we've resolved any issues with the current python build. We haven't put out a new release yet that has a compatible docker image for the current version, we should do that and iron out any other kinks. Then we can make additional releases with these other PRs that will further change the requirements.

ark/utils/load_utils.py Outdated Show resolved Hide resolved
@srivarra srivarra requested a review from ngreenwald January 20, 2023 02:33
Copy link
Member

@ngreenwald ngreenwald left a comment

Choose a reason for hiding this comment

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

Looks good!

@ngreenwald ngreenwald merged commit e69ed2a into main Jan 20, 2023
@ngreenwald ngreenwald deleted the ome_tiff branch January 20, 2023 02:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OME-TIFF Reader / Writer
4 participants