Skip to content

Commit

Permalink
Fix lfp artifact detection (LorenFrankLab#511)
Browse files Browse the repository at this point in the history
* lfp artifact detection edge artifact fix
  • Loading branch information
MichaelCoulter authored May 23, 2023
1 parent 8fa3397 commit de1a846
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions src/spyglass/lfp/v1/lfp.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,24 +459,27 @@ def _get_artifact_times(
# second, find artifacts with large baseline change
big_artifacts = np.zeros((recording.data.shape[1], above_thresh_1st.shape[0]))
for art_count in np.arange(above_thresh_1st.shape[0]):
local_max = np.max(
recording.data[
above_thresh_1st[art_count]
- local_window : above_thresh_1st[art_count]
+ local_window,
:,
],
axis=0,
)
local_min = np.min(
recording.data[
above_thresh_1st[art_count]
- local_window : above_thresh_1st[art_count]
+ local_window,
:,
],
axis=0,
)
if above_thresh_1st[art_count] <= local_window:
local_min = local_max = above_thresh_1st[art_count]
else:
local_max = np.max(
recording.data[
above_thresh_1st[art_count]
- local_window : above_thresh_1st[art_count]
+ local_window,
:,
],
axis=0,
)
local_min = np.min(
recording.data[
above_thresh_1st[art_count]
- local_window : above_thresh_1st[art_count]
+ local_window,
:,
],
axis=0,
)
big_artifacts[:, art_count] = (
np.abs(local_max - local_min) > amplitude_thresh_2nd
)
Expand Down

0 comments on commit de1a846

Please sign in to comment.