Skip to content

Conversation

@samuelgarcia
Copy link
Member

@samuelgarcia samuelgarcia commented Jan 6, 2026

@JoeZiminski @oliche

This refactor the artifact detection and blanking

  • with a main multi method function : detect_artifact_periods()
  • return periods with the new base_period_dtype instead list of list
  • SilencedPeriodsRecording also use this new dtype
  • DetectArtifactAndSilentPeriodsRecording (replace SilencedArtifactsRecording) do detect and silence at the same
    time to be used in preprocess dict (@chrishalcrow this is for you)
  • refactor the method of Pierre based on envleope
  • incorporate the method of @oliche and @JoeZiminski to detect saturation

Could also be done in this PR:

  • add a margin_ms option in SilentPeriodsRecording to ewxtend the zeroing with a mragin : do we need this ?

To be done in 2 futures PR:

  • handle margin and taper on border of SilentPeriod (more tricky that it appear when period is at border...)
  • rewrite RemoveArtifactsRecording based on SilencedPeriodsRecording and the new dtype

@alejoe91 alejoe91 added the preprocessing Related to preprocessing module label Jan 6, 2026
@alejoe91 alejoe91 changed the title Refactor aftifacts detection. Refactor artifacts detection Jan 7, 2026
@yger
Copy link
Collaborator

yger commented Jan 12, 2026

@samuelgarcia do not forget, in this PR, to change DetectThresholdCrossing(recording, ...) to DetectThresholdCrossing(envelope, ...) in the detec_period_artefacts_by_envelope

@samuelgarcia
Copy link
Member Author

Hi @oliche @JoeZiminski
I copy paste and clean a bit your PR #4301 into this one.
Have a look and tell if this is OK.

I think we do not need to scaled traces at each chunk we could only could the unscaled threhold in the init and then we could avoid the costly convertion to float32 or float64.

Also I put the unit in uV to be more SI friendly.

@samuelgarcia samuelgarcia changed the title Refactor artifacts detection Refactor artifacts detection + add sturation detection Jan 21, 2026
@samuelgarcia samuelgarcia marked this pull request as ready for review January 21, 2026 13:21
@samuelgarcia
Copy link
Member Author

@alejoe91 @chrishalcrow ready to review on my side

random_slices_kwargs["seed"] = seed
noise_levels = get_noise_levels(envelope, return_in_uV=False, random_slices_kwargs=random_slices_kwargs)

node0 = _DetectThresholdCrossing(
Copy link
Collaborator

Choose a reason for hiding this comment

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

should be envelope here, am I right?

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