atlab / scanreader

Python TIFF Stack Reader for ScanImage 5 scans (including multiROI).
MIT License
9 stars 11 forks source link

meta data change? scanimage 2021 `KeyError: 'RoiGroups'` #14

Closed MMathisLab closed 2 years ago

MMathisLab commented 2 years ago

hey team! I am also now using scanimage 2021, and see you support it (yay!), but I hit one error, maybe the metadata has changed between 2018b (prior use), so documenting it here if you happen to know whats up, and/or as I debug it I will let you know:

scan = scanreader.read_scan(scan_filename)
  File "/usr/local/lib/python3.6/dist-packages/scanreader/core.py", line 63, in read_scan
    scan.read_data(filenames, dtype=dtype)
  File "/usr/local/lib/python3.6/dist-packages/scanreader/scans.py", line 762, in read_data
    self.rois = self._create_rois()
  File "/usr/local/lib/python3.6/dist-packages/scanreader/scans.py", line 769, in _create_rois
    roi_infos = self.tiff_files[0].scanimage_metadata['RoiGroups']['imagingRoiGroup']['rois']
KeyError: 'RoiGroups'
MMathisLab commented 2 years ago

@danielmk or @ecobost - did you hit any errors by chance? thanks for the 2021 support 👍

here is a small scan from scanimage2021, and the demo notebook:

https://drive.google.com/drive/folders/1J4wmXlBw8pjOYs6CHNjTaPYi1v3IHT8V?usp=sharing

Thanks for any help! 🙏

*edit to add solution: the version of tifffile needs to be >> than 2019.2.2 as in setup.py file; which requires python >3.7.

ecobost commented 2 years ago

Hi @MMathisLab, nice to see you solved the issue. Sorry I didn't get around to try it on time, I probably could have help diagnose it.

I am not 100% sure why I moved to tifffile 2019.2.2 (probably just hoping for some performance improvements). But if you're forced to use previous python versions perhaps you can change your local copy of scanreader as in here: https://github.com/atlab/scanreader/commit/4f94d1aba12d3aaf093ffde1677398bd0a3d231b I would pull the latest code and change those lines and I presume everything will work ok then but I'm not 100% sure.