Skip to content

Commit

Permalink
fixed bug with parse_metadata so that it works properly when hStackMa…
Browse files Browse the repository at this point in the history
…nager is disabled
  • Loading branch information
pauladkisson committed Oct 9, 2024
1 parent 9a5f0c9 commit 67ec6e8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
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 67ec6e8

Please sign in to comment.