diff --git a/CHANGELOG.md b/CHANGELOG.md index 11e2b385..36ed26e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,12 @@ All notable changes to this project will be documented in this file. ## Unreleased - +This pull request adds a line of code to the get_stim_epoch function in epochs.py to +remove np.nan values from the array of differences between data points before removing +all non-zero values. This change allows get_stim_epoch to find the correct ending index +of the stimlus epoch and the correct ending index of the experiment epoch as well since +it relys on the stimulus epoch, which should fix the issue of sweeps being incorrectly +tagged with "Recording stopped before completing the experiment epoch". ### Added ### Changed diff --git a/ipfx/epochs.py b/ipfx/epochs.py index f15e3b93..584dca06 100644 --- a/ipfx/epochs.py +++ b/ipfx/epochs.py @@ -108,6 +108,7 @@ def get_stim_epoch(i, test_pulse=True): """ di = np.diff(i) + di = di[~np.isnan(di)] # != NaN di_idx = np.flatnonzero(di) # != 0 if test_pulse: diff --git a/tests/test_epochs.py b/tests/test_epochs.py index 6364f0dc..d0bed253 100644 --- a/tests/test_epochs.py +++ b/tests/test_epochs.py @@ -109,6 +109,11 @@ def test_get_test_epoch(i, sampling_rate, test_epoch): [0, 0, 0, 0, 0, 0, 0], None ), + # array containing np.nan + ( + [0, 0, 1, 1, 0, 0, 2, 2, 2, 0, 0, np.nan, np.nan], + (6, 8) + ), ] )