Skip to content

Commit

Permalink
Fixed bug with ScanImage's parse_metadata so that it works properly w…
Browse files Browse the repository at this point in the history
…hen hStackManager is disabled (#373)

fixed bug with parse_metadata so that it works properly when hStackManager is disabled
  • Loading branch information
pauladkisson authored Oct 11, 2024
1 parent 9a5f0c9 commit 2cf9235
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
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

0 comments on commit 2cf9235

Please sign in to comment.