napari / napari

napari: a fast, interactive, multi-dimensional image viewer for python
https://napari.org
BSD 3-Clause "New" or "Revised" License
2.07k stars 410 forks source link

[bugfix] Warn if float image data being saved to non-tiff #6884

Open psobolewskiPhD opened 2 weeks ago

psobolewskiPhD commented 2 weeks ago

References and relevant issues

Closes: https://github.com/napari/napari/issues/6670

Description

Only a subset of file types (e.g. TIFF) support float data, so if the user passes a different extension and dtype is float, then don't try saving to invalid format and instead warn the user. Also added a test for this condition. Also if no extension is provided and image is 3d or float, then use .tiff instead of png.

While there are skimage and imageio functions to convert arrays to int, they make assumptions, so I think this is the best way to handle this, rather than magic'ing a conversion.

codecov[bot] commented 2 weeks ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 92.44%. Comparing base (f66fce6) to head (5b1efc2). Report is 2 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #6884 +/- ## ========================================== - Coverage 92.45% 92.44% -0.02% ========================================== Files 617 617 Lines 55156 55188 +32 ========================================== + Hits 50993 51017 +24 - Misses 4163 4171 +8 ```

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

Czaki commented 2 weeks ago

Did you validate all extensions? Based on documentation, the .lsm should also be able to save float.