Skip to content

Commit b31c32f

Browse files
authored
Merge branch 'master' into rc/2.4.0
2 parents e2f2a20 + 71281bf commit b31c32f

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

allensdk/internal/api/behavior_ophys_api.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,13 @@ def get_ophys_timestamps(self):
9191
plane_group = self.get_imaging_plane_group()
9292

9393
number_of_cells, number_of_dff_frames = dff_traces.shape
94-
num_of_timestamps = len(ophys_timestamps)
9594
# Scientifica data has extra frames in the sync file relative
9695
# to the number of frames in the video. These sentinel frames
9796
# should be removed.
9897
# NOTE: This fix does not apply to mesoscope data.
9998
# See http://confluence.corp.alleninstitute.org/x/9DVnAg
10099
if plane_group is None: # non-mesoscope
100+
num_of_timestamps = len(ophys_timestamps)
101101
if (number_of_dff_frames < num_of_timestamps):
102102
self.logger.info(
103103
"Truncating acquisition frames ('ophys_frames') "
@@ -119,6 +119,7 @@ def get_ophys_timestamps(self):
119119
"plane group(s).")
120120
ophys_timestamps = self._process_ophys_plane_timestamps(
121121
ophys_timestamps, plane_group, group_count)
122+
num_of_timestamps = len(ophys_timestamps)
122123
if number_of_dff_frames != num_of_timestamps:
123124
raise RuntimeError(
124125
f"dff_frames (len={number_of_dff_frames}) is not equal to "

allensdk/test/brain_observatory/behavior/test_behavior_ophys_lims_api.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ def test_process_ophys_plane_timestamps(
9898
np.arange(5), does_not_raise()),
9999
(None, np.arange(10), np.arange(20).reshape(1, 20),
100100
None, pytest.raises(RuntimeError)),
101-
(2, np.arange(10), np.arange(10).reshape(1, 10),
102-
np.arange(10), does_not_raise()),
103-
(2, np.arange(10), np.arange(5).reshape(1, 5),
101+
(0, np.arange(10), np.arange(5).reshape(1, 5),
102+
np.arange(0, 10, 2), does_not_raise()),
103+
(0, np.arange(20), np.arange(5).reshape(1, 5),
104104
None, pytest.raises(RuntimeError))
105105
],
106106
ids=["scientifica-trunate", "scientifica-raise", "mesoscope-good",
@@ -117,10 +117,8 @@ def test_get_ophys_timestamps(monkeypatch, plane_group, ophys_timestamps,
117117
lambda: {"ophys_frames": ophys_timestamps})
118118
monkeypatch.setattr(api, "get_raw_dff_data", lambda: dff_traces)
119119
monkeypatch.setattr(api, "get_imaging_plane_group", lambda: plane_group)
120-
monkeypatch.setattr(api, "_process_ophys_plane_timestamps",
121-
lambda *x: ophys_timestamps)
122-
monkeypatch.setattr(api, "get_plane_group_count", lambda: 4)
120+
monkeypatch.setattr(api, "get_plane_group_count", lambda: 2)
123121
with context:
124122
actual = api.get_ophys_timestamps()
125123
if expected is not None:
126-
np.testing.assert_array_equal(expected, actual)
124+
np.testing.assert_array_equal(expected, actual)

0 commit comments

Comments
 (0)