Surface more information during reader/plugin selection
See the original issue here for more information from aicsimageio. In short, it would be useful in some use cases to provide more information about what BioImage (previously AICSImage) is doing under the hood during reader selection.
Originally submitted by @tlambert03
I wonder if it would be enough to have: get_all_readers_for_given_file(filepath) then loop over readers, try each one, get some string message back about why it didn't work.
The difference between what it does now and what you are proposing being that currently we stop at the first reader that works but it would be ideal to see all working readers? That seems doable & easy to implement
If I recall correctly, the main issue was about surfacing why something didn't work (not just that it didn't work). The Bioformats reader is particularly tough because it requires a java runtime, so even if you have bioformats_jarinstalled, but don't have openjdk or the like, then you'll get an error, but the implementation as it was in aicsimageio didn't surface that issue, it just said:
>>> rdr = AICSImage.determine_reader('/Users/talley/Downloads/coupe shg stack_0001.oir')
AICSImage does not support the image:
'/Users/talley/Downloads/coupe shg stack_0001.oir'. File extension suggests
format: 'oir'. Install extra format dependency with: `pip install bioformats_jar`.
when in fact the real issue was only surfaced if you manually went in and tried to instantiate a bioformats reader:
>>> im = BioformatsReader('/Users/talley/Downloads/coupe shg stack_0001.oir')
RuntimeError:
BioformatsReader requires a java executable to be available
in your environment. If you are using conda, you can install
with `conda install -c conda-forge scyjava`.
Note: you may need to reactivate your conda environment after
installing opendjk. If you still have this error, try:
# mac and linux:
export JAVA_HOME=$CONDA_PREFIX
# windows:
set JAVA_HOME=%CONDA_PREFIX%\Library
so, the crux of that issue was more about surfacing useful error messages. Without it, would probably bang their head against a wall saying "I DID install bioformats_jar darn it!"
but, I'd need to familiarize myself with whatever equivalent you have for determine_reader here to have a suggestion
I wonder if we need better logging / path tracing then?
We should have different errors for ReaderInitError vs UnsupportedFileFormatError?
@tlambert03 @evamaxfield @SeanLeRoy @toloudis I am returning to this now and wanted to define a couple of specific changes to make as this issue seems mostly a discussion.
Possible features to add:
- [ ] Add function
get_all_readers_for_given_file(filepath)to report each reader compatibility - [ ] Add robust explanation in determine_plugin
- [ ] Add error separation for
ReaderInitErrorvsUnsupportedFileFormatError
@BrianWhitneyAI those all sound great to me!