tlambert03 / nd2

Full-featured nd2 (Nikon NIS Elements) file reader for python. Outputs to numpy, dask, and xarray. Exhaustive metadata extraction
https://tlambert03.github.io/nd2
BSD 3-Clause "New" or "Revised" License
54 stars 15 forks source link

feat: add to_ome_tif method #217

Closed fdrgsp closed 8 months ago

fdrgsp commented 8 months ago

Hey @tlambert03 , I've started working on the conversion of the nd2 files into the ome-tif format. It is definitely not finished but I think is a good starting point.

I've added a to_ome_tif() method to the package to save to disk na .ome.tif file and it is working as I want which means the I can also open the .ome.tif files in Fiji and properly load the ome metadata (also with multi position files - in this case the bio-formats importer asks the user to choose which series to open).

One thing that I understood is that we need to rearrange the ome metadata gathered form the nd2 ome_metadata() method to create as many Image objects as the number of positions (grouped by the x, y position). At the moment this is done with the _reorganize_metadata() function that I've added but maybe we can do that directly in ome_metadata().

When you have time can you have a look?

At the moment the test I've added only assert that the number of series in the tiff file is correct but it should be expanded as well.

fdrgsp commented 8 months ago

I didn't see you did work on it already 🤣

codspeed-hq[bot] commented 8 months ago

CodSpeed Performance Report

Merging #217 will not alter performance

Comparing fdrgsp:add_to_ome_tif (f4d3a34) with main (66f5bef)

Summary

✅ 13 untouched benchmarks

tlambert03 commented 8 months ago

Aw shoot, you closed it! I did start working on it cause I wasn't sure if you had time to do it after all. But I think it's very cool to see the similarities in how we did it! I'm going to reopen this, probably merge it (cause I want you as a contributor), and then consider any additional features later.

One thing I played with is not using to_dask as an intermediate which keeps it a bit leaner and allows a progress feedback,

But thank you! Reopening

codecov[bot] commented 8 months ago

Codecov Report

Attention: Patch coverage is 95.45455% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 95.17%. Comparing base (66f5bef) to head (f4d3a34).

Files Patch % Lines
src/nd2/nd2file.py 95.45% 2 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #217 +/- ## ======================================= Coverage 95.16% 95.17% ======================================= Files 17 17 Lines 2318 2362 +44 ======================================= + Hits 2206 2248 +42 - Misses 112 114 +2 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

tlambert03 commented 8 months ago

thanks for your work on this @fdrgsp! It was very helpful to compare what you did here to what I also stumbled across. I'm going to merge this in, and then reconcile it with #216