Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed bug with ScanImage's parse_metadata so that it works properly when hStackManager is disabled #373

Merged
merged 2 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
4 changes: 2 additions & 2 deletions tests/test_scanimage_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
Loading