diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f4bfe33..5f36e7b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ ### Fixes * Added specific error message for single-frame scanimage data [PR #360](https://github.com/catalystneuro/roiextractors/pull/360) +* Fixed bug with ScanImage's parse_metadata so that it works properly when hStackManager is disabled [PR #373](https://github.com/catalystneuro/roiextractors/pull/373) ### Improvements * Removed unnecessary import checks for scipy, h5py, and zarr [PR #364](https://github.com/catalystneuro/roiextractors/pull/364) diff --git a/src/roiextractors/extractors/tiffimagingextractors/scanimagetiff_utils.py b/src/roiextractors/extractors/tiffimagingextractors/scanimagetiff_utils.py index bf559573..f279ac3c 100644 --- a/src/roiextractors/extractors/tiffimagingextractors/scanimagetiff_utils.py +++ b/src/roiextractors/extractors/tiffimagingextractors/scanimagetiff_utils.py @@ -114,8 +114,12 @@ def parse_metadata(metadata: dict) -> dict: where M is the number of channels (active or not). """ sampling_frequency = float(metadata["SI.hRoiManager.scanFrameRate"]) - num_planes = int(metadata["SI.hStackManager.numSlices"]) - frames_per_slice = int(metadata["SI.hStackManager.framesPerSlice"]) + if metadata["SI.hStackManager.enable"] == "true": + num_planes = int(metadata["SI.hStackManager.numSlices"]) + frames_per_slice = int(metadata["SI.hStackManager.framesPerSlice"]) + else: + num_planes = 1 + frames_per_slice = 1 active_channels = parse_matlab_vector(metadata["SI.hChannels.channelsActive"]) channel_indices = np.array(active_channels) - 1 # Account for MATLAB indexing channel_names = np.array(metadata["SI.hChannels.channelName"].split("'")[1::2]) diff --git a/tests/test_scanimage_utils.py b/tests/test_scanimage_utils.py index 8429eba0..34e17031 100644 --- a/tests/test_scanimage_utils.py +++ b/tests/test_scanimage_utils.py @@ -67,8 +67,8 @@ def test_parse_matlab_vector_invalid(): { "sampling_frequency": 15.2379, "num_channels": 1, - "num_planes": 20, - "frames_per_slice": 24, + "num_planes": 1, + "frames_per_slice": 1, "channel_names": ["Channel 1"], "roi_metadata": { "imagingRoiGroup": {