Artifact Rejection
Date created: 2026-03-06
Quick Access
General Workflow
- artifact rejection on interest channels
- downsample channels
- convert to .mat files
- load into RAVE
[!NOTE] Artifact rejection pipeline already involves bipolar referencing–no need to do this again in RAVE.
Pipeline
- load ns5 file
- take a look at the raw data
- bipolar rereferencing
- figure out timing of pulse locations – plot sync pulse from events channel
- clean sync pulse
- edge, find_peaks, or first derivative method
- extract stim onset and artifact window
- remove a few irrecoverable samples if necessary
- detrend to remove DC offset
- find average to build template
- template subtraction
- interpolate – take any point that is NaN and replaces it with moving mean
- filter
- downsample to 2K
- convert to .mat files
MATLAB Code
Notes
- spacing on sEEG probes is 3 mm for the first two contacts and 5 mm for the rest – keep this in mind for bipolar referencing
- the first artifact might look quite different than the rest – may have to make a separate template
- many systems (not ours) use the recording ground as a current return – NOT recommended
- 8 V limit on the amplifier
- neighboring channel has better recovery than the stimulating channel
- when using stimulator.play with multiple repeats in your code, keep in mind that there is a small delay between each play
- longer pulse duration = more artifact
- bipolar rereference around the stimulating electrode (contact before rereferenced to contact after)
- check for bad channels on the raw data (60 Hz noise, electrodes out of brain, etc.)
- make sure in your task code you store stim parameters for each trial so that artifact rejection is easier later on