brainreg
brainreg copied to clipboard
registration failing when their are non-tiff files in the directory
Describe the bug Metadata in the image directory (in my case a couple of irrelevant .mat files) cause brainreg-napari to crash at the point of downsampling.
To Reproduce Fresh installation of brainreg-napari in a clean env on linux, python 3.10. Drag directory containing all raw data images and also a couple of .mat files into napari. Choose parameters and hit run.
Expected behaviour
I would expect such an issue to crash earlier - when the data are loaded or immediately after hitting run, with a message specifically about unexpected files.
Log file
The error message I receive is:
"ValueError: Could not find a backend to open stitchedSize.mat`` with iomode
ri`."
also.. deleting the offending .mat files does prevent the issue occurring.
Thanks for raising @stephenlenzi, we should fix this. The problem is that the brainreg plugin doesn't operate directly upon the data loaded into napari (unlike the cellfinder plugin). The data is viewed, but then the data is loaded again, in a slightly different way by brainreg (using imio). I guess we have three options with increasing elegance (and complexity for us to implement):
- Warn the user if there are other files in the directory (i.e. if we think brainreg will fail)
- Prevent these files from interrupting loading data with imio
- Pass the data directly from napari to brainreg
- If brainreg recieves a file path, it should load, downscale and save
- If brainreg recieves a numpy-like obkect, it should just downscale and save