Skip to content

Honor force_sktiff in ome_to_binary - #1262

Open
adityasingh2400 wants to merge 1 commit into
MouseLand:mainfrom
adityasingh2400:fix-1250
Open

Honor force_sktiff in ome_to_binary#1262
adityasingh2400 wants to merge 1 commit into
MouseLand:mainfrom
adityasingh2400:fix-1250

Conversation

@adityasingh2400

Copy link
Copy Markdown

Fixes #1250.

ome_to_binary computed use_sktiff = not HAS_SCANIMAGE, ignoring the force_sktiff option that the sibling tiff_to_binary already honors one function up.

The variable was also dead for the purpose of picking a reader. Every open site re-derived the choice from HAS_SCANIMAGE inline instead of consulting use_sktiff: the TiffReader alias, the page count probe, both single page reads, and both open_tiff calls. use_sktiff was only ever passed on to read_tiff. So even fixing the one assignment would not have changed which reader opened the file, and setting force_sktiff had no effect on OME-TIFF imports at all.

This derives use_sktiff the way tiff_to_binary does and routes every reader selection in the function through it. With force_sktiff false the behaviour is bit identical, since use_sktiff and not HAS_SCANIMAGE agree in that case.

Two tests in tests/test_io.py. They generate their own small OME-style TIFFs with tifffile and monkeypatch HAS_SCANIMAGE and ScanImageTiffReader, so they need neither the cached input download nor ScanImageTiffReader to be installed. One asserts force_sktiff=True reaches tifffile and writes the expected binary, the other asserts the default path still prefers ScanImageTiffReader when it is available, which guards the change in the other direction.

Reverting suite2p/io/tiff.py from main makes the first fail with RuntimeError: ScanImageTiffReader was used. Both pass after.

Disclosure: this change was prepared with AI assistance. I have reviewed and tested it.

ome_to_binary computed use_sktiff as `not HAS_SCANIMAGE`, ignoring the
force_sktiff option that tiff_to_binary already honors. The variable was
also dead for reader selection: every open site re-derived the choice from
HAS_SCANIMAGE inline, so setting force_sktiff had no effect on OME-TIFF
imports at all.

Derive use_sktiff from force_sktiff the same way tiff_to_binary does, and
route every reader selection in the function through it.
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.

BUG: force_sktiff does not work in tiff.ome_to_binary

1 participant