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

Force tile sizes to be a multiple of 16 #89

Merged
merged 2 commits into from
Dec 5, 2022

Conversation

melissalinkert
Copy link
Member

Fixes #88.

Tile sizes were previously taken directly from the input zarr's chunk sizes. Now, if the chunk size is a multiple of 16 it will be used directly, otherwise it will be rounded up to the next multiple of 16. This mostly affects the smallest resolution images (which are typically a single tile) and datasets generated by bioformats2raw with non-default tile sizes. When the tile size is calculated to be different from the chunk size, a warning is now printed.

This shouldn't actually affect pixel data that is returned when reading converted OME-TIFFs (with Bio-Formats, at least). It should eliminate warnings from libtiff as described in the test case in #88.

Copy link
Member

@sbesson sbesson left a comment

Choose a reason for hiding this comment

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

Tested using 2 sample files which were converted using bioformats2raw 0.5.0

  • CMU-1-Small-Region.svs which was the original image
  • a synthetic test file with dimensions which are not multiple of 16 test&sizeX=383&sizeY=275.fake

With raw2ometiff, I can reproduce the warning sent by libtiff

(java11) sbesson@Sebastiens-MacBook-Pro-2 Downloads % /raw2ometiff-0.3.1/bin/raw2ometiff CMU-1-Small-Region.ome.zarr raw2ometiff-0.3.1/CMU-1-Small-Region.ome.tiff
zsh: no such file or directory: /raw2ometiff-0.3.1/bin/raw2ometiff
(java11) sbesson@Sebastiens-MacBook-Pro-2 Downloads % ./raw2ometiff-0.3.1/bin/raw2ometiff CMU-1-Small-Region.ome.zarr raw2ometiff-0.3.1/CMU-1-Small-Region.ome.tiff
(java11) sbesson@Sebastiens-MacBook-Pro-2 Downloads % tiffinfo raw2ometiff-0.3.1/CMU-1-Small-Region.ome.tiff > /dev/null
raw2ometiff-0.3.1/CMU-1-Small-Region.ome.tiff: Warning, Nonstandard tile width 387, convert file.
raw2ometiff-0.3.1/CMU-1-Small-Region.ome.tiff: Warning, Nonstandard tile length 463, convert file.
raw2ometiff-0.3.1/CMU-1-Small-Region.ome.tiff: Warning, Nonstandard tile width 387, convert file.
raw2ometiff-0.3.1/CMU-1-Small-Region.ome.tiff: Warning, Nonstandard tile length 463, convert file.
raw2ometiff-0.3.1/CMU-1-Small-Region.ome.tiff: Warning, Nonstandard tile width 387, convert file.
raw2ometiff-0.3.1/CMU-1-Small-Region.ome.tiff: Warning, Nonstandard tile length 463, convert file.
raw2ometiff-0.3.1/CMU-1-Small-Region.ome.tiff: Warning, Nonstandard tile length 431, convert file.
raw2ometiff-0.3.1/CMU-1-Small-Region.ome.tiff: Warning, Nonstandard tile length 431, convert file.
raw2ometiff-0.3.1/CMU-1-Small-Region.ome.tiff: Warning, Nonstandard tile length 431, convert file.
(java11) sbesson@Sebastiens-MacBook-Pro-2 Downloads % tiffinfo raw2ometiff-0.3.1/test.ome.tiff > /dev/null
raw2ometiff-0.3.1/test.ome.tiff: Warning, Nonstandard tile width 383, convert file.
raw2ometiff-0.3.1/test.ome.tiff: Warning, Nonstandard tile length 275, convert file.

With this PR included, the utility warns of the tile size correction and adjusts it and tiffinfo throws no warning in the output file

(java11) sbesson@Sebastiens-MacBook-Pro-2 Downloads % ./raw2ometiff-0.4.0-SNAPSHOT/bin/raw2ometiff test.ome.zarr  raw2ometiff-0.4.0-SNAPSHOT/test.ome.tiff
2022-11-15 11:18:04,374 [main] WARN  c.g.pyramid.PyramidSeries - Tile width (383) not a multiple of 16; correcting
2022-11-15 11:18:04,378 [main] WARN  c.g.pyramid.PyramidSeries - Tile height (275) not a multiple of 16; correcting
2022-11-15 11:18:04,379 [main] WARN  c.g.pyramid.PyramidSeries - Tile width (191) not a multiple of 16; correcting
2022-11-15 11:18:04,379 [main] WARN  c.g.pyramid.PyramidSeries - Tile height (137) not a multiple of 16; correcting
(java11) sbesson@Sebastiens-MacBook-Pro-2 Downloads % ./raw2ometiff-0.4.0-SNAPSHOT/bin/raw2ometiff CMU-1-Small-Region.ome.zarr raw2ometiff-0.4.0-SNAPSHOT/CMU-1-Small-Region.ome.tiff
2022-11-15 11:18:20,699 [main] WARN  c.g.pyramid.PyramidSeries - Tile width (555) not a multiple of 16; correcting
2022-11-15 11:18:20,702 [main] WARN  c.g.pyramid.PyramidSeries - Tile height (741) not a multiple of 16; correcting
2022-11-15 11:18:20,702 [main] WARN  c.g.pyramid.PyramidSeries - Tile width (277) not a multiple of 16; correcting
2022-11-15 11:18:20,702 [main] WARN  c.g.pyramid.PyramidSeries - Tile height (370) not a multiple of 16; correcting
2022-11-15 11:18:20,703 [main] WARN  c.g.pyramid.PyramidSeries - Tile width (138) not a multiple of 16; correcting
2022-11-15 11:18:20,703 [main] WARN  c.g.pyramid.PyramidSeries - Tile height (185) not a multiple of 16; correcting
2022-11-15 11:18:20,706 [main] WARN  c.g.pyramid.PyramidSeries - Tile width (387) not a multiple of 16; correcting
2022-11-15 11:18:20,706 [main] WARN  c.g.pyramid.PyramidSeries - Tile height (463) not a multiple of 16; correcting
2022-11-15 11:18:20,706 [main] WARN  c.g.pyramid.PyramidSeries - Tile width (193) not a multiple of 16; correcting
2022-11-15 11:18:20,706 [main] WARN  c.g.pyramid.PyramidSeries - Tile height (231) not a multiple of 16; correcting
2022-11-15 11:18:20,708 [main] WARN  c.g.pyramid.PyramidSeries - Tile height (431) not a multiple of 16; correcting
2022-11-15 11:18:20,708 [main] WARN  c.g.pyramid.PyramidSeries - Tile height (215) not a multiple of 16; correcting
2022-11-15 11:18:20,709 [main] WARN  c.g.pyramid.PyramidSeries - Tile height (107) not a multiple of 16; correcting
2022-11-15 11:18:20,709 [main] WARN  c.g.pyramid.PyramidSeries - Tile height (53) not a multiple of 16; correcting
(java11) sbesson@Sebastiens-MacBook-Pro-2 Downloads % tiffinfo raw2ometiff-0.4.0-SNAPSHOT/CMU-1-Small-Region.ome.tiff > /dev/null
(java11) sbesson@Sebastiens-MacBook-Pro-2 Downloads % tiffinfo raw2ometiff-0.4.0-SNAPSHOT/test.ome.tiff > /dev/null 

👍 for including this fix in the next release of raw2ometiff as this is effectively the same change as ome/bioformats#3709 in the OME Bio-Formats utility.
The only nitpicky concern is whether the WARN level of debugging statement might create unnecessary noise especially when it comes to mass conversion.

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.

Tile width/length must be a multiple of 16
3 participants