Skip to content

Conversation

@mhhennig
Copy link
Member

@mhhennig mhhennig commented Dec 5, 2025

This fixes a bug in RemoveArtifactsRecordingSegment

Previously artifacts would not be removed if the trigger was before start_frame but the blanking carried on beyond. Only tested on zeros mode.

…actsRecordingSegment

Previously artifacts would not be removed if the trigger was before `start_frame` but the blanking carried on beyond. Only tested on `zeros` mode.
@alejoe91 alejoe91 added the preprocessing Related to preprocessing module label Dec 5, 2025
if pad is None:
mask = (self.triggers >= start_frame) & (self.triggers < end_frame)
else:
mask = (self.triggers >= start_frame - pad[1]) & (self.triggers < end_frame + pad[0])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mask = (self.triggers >= start_frame - pad[1]) & (self.triggers < end_frame + pad[0])
mask = (self.triggers >= start_frame - pad[0]) & (self.triggers < end_frame + pad[1])

pad is defined as pad = [int(ms_before * fs / 1000), int(ms_after * fs / 1000)]

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is wrong (tested it to be sure), this would fails if start_frame>trigger-pad[0] and pad[0]<pad[1].

It has to be this as in Chris' edit:
mask = (self.triggers >= start_frame - pad[1]) & (self.triggers < end_frame + pad[0])

One needs to look back for triggers before start_frame-pad[1] if start_frame is after a trigger time point (otherwise the trigger is just ignored), or ahead by end_frame - pad[0] if start_frame and end_frame areboth before a trigger.

Copy link
Member

@alejoe91 alejoe91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mhhennig see my comment

@chrishalcrow chrishalcrow added this to the 0.104.0 milestone Dec 17, 2025
@chrishalcrow chrishalcrow merged commit 62699ff into SpikeInterface:main Dec 17, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

preprocessing Related to preprocessing module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants