catalystneuro / roiextractors

Python-based module for extracting from, converting between, and handling optical imaging data from several file formats. Inspired by SpikeInterface.
https://roiextractors.readthedocs.io/en/latest/index.html
BSD 3-Clause "New" or "Revised" License
12 stars 7 forks source link

[Bug]: ScanImageTiffSinglePlaneImagingExtractor cannot read files with only 1 frame each #298

Closed pauladkisson closed 2 months ago

pauladkisson commented 8 months ago

What happened?

Tried to instantiate a ScanImageTiffSinglePlaneImagingExtractor on a file with only 1 frame and got an error bc the array returned by ScanImageTiffReader.get_data() is 2D instead of 3D.

Steps to Reproduce

from roiextractors import ScanImageTiffSinglePlaneImagingExtractor
file_path = "/Users/pauladkisson/Documents/CatalystNeuro/ROIExtractors/ophys_testing_data/ophys_testing_data/imaging_datasets/ScanImage/scanimage_20240320_single_frame.tif"
imaging_extractor = ScanImageTiffSinglePlaneImagingExtractor(
    file_path=file_path,
    channel_name='Channel 1',
    plane_name='0'
)

Traceback

NotImplementedError                       Traceback (most recent call last)
Cell In[1], line 3
      1 from roiextractors import ScanImageTiffSinglePlaneImagingExtractor
      2 file_path = "/Users/pauladkisson/Documents/CatalystNeuro/ROIExtractors/ophys_testing_data/ophys_testing_data/imaging_datasets/ScanImage/scanimage_20240320_single_frame.tif"
----> 3 imaging_extractor = ScanImageTiffSinglePlaneImagingExtractor(
      4     file_path=file_path,
      5     channel_name='Channel 1',
      6     plane_name='0'
      7 )

File ~/Documents/CatalystNeuro/ROIExtractors/roiextractors/src/roiextractors/extractors/tiffimagingextractors/scanimagetiffimagingextractor.py:279, in ScanImageTiffSinglePlaneImagingExtractor.__init__(self, file_path, channel_name, plane_name, metadata)
    277     self._num_cycles = self._total_num_frames // self._num_raw_per_cycle
    278 else:
--> 279     raise NotImplementedError(
    280         "Extractor cannot handle 4D ScanImageTiff data. Please raise an issue to request this feature: "
    281         "https://github.com/catalystneuro/roiextractors/issues "
    282     )
    283 timestamps = extract_timestamps_from_file(file_path)
    284 index = [self.frame_to_raw_index(iframe) for iframe in range(self._num_frames)]

NotImplementedError: Extractor cannot handle 4D ScanImageTiff data. Please raise an issue to request this feature: https://github.com/catalystneuro/roiextractors/issues

Operating System

macOS

Python Executable

Conda

Python Version

3.9

Package Versions

No response

Code of Conduct

Yes

Duplicated Issue Check

Yes