Skip to content

Commit 6faed4c

Browse files
authored
Limit spikesorting artifacts to valid timestamps (#1196)
* limit artifacts to valid timestamps * update changelog
1 parent 37ddfc1 commit 6faed4c

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ dj.FreeTable(dj.conn(), "common_session.session_group").drop()
8181
- Fix bug in `_compute_metric` #1099
8282
- Fix bug in `insert_curation` returned key #1114
8383
- Fix handling of waveform extraction sparse parameter #1132
84+
- Limit Artifact detection intervals to valid times #1196
8485

8586
## [0.5.3] (August 27, 2024)
8687

src/spyglass/spikesorting/v0/spikesorting_artifact.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,10 @@ def _get_artifact_times(
276276
for interval_idx, interval in enumerate(artifact_intervals):
277277
artifact_intervals_s[interval_idx] = [
278278
valid_timestamps[interval[0]] - half_removal_window_s,
279-
valid_timestamps[interval[1]] + half_removal_window_s,
279+
np.minimum(
280+
valid_timestamps[interval[1]] + half_removal_window_s,
281+
valid_timestamps[-1],
282+
),
280283
]
281284
# make the artifact intervals disjoint
282285
if len(artifact_intervals_s) > 1:

src/spyglass/spikesorting/v1/artifact.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,10 @@ def _get_artifact_times(
308308
),
309309
np.searchsorted(
310310
valid_timestamps,
311-
valid_timestamps[interval[1]] + half_removal_window_s,
311+
np.minimum(
312+
valid_timestamps[interval[1]] + half_removal_window_s,
313+
valid_timestamps[-1],
314+
),
312315
),
313316
]
314317
artifact_intervals_s[interval_idx] = [

0 commit comments

Comments
 (0)