Preprocessing module¶
The preprocessing
module includes preprocessing steps to apply before spike
sorting. Preprocessors are lazy, meaning that no computation is performed until it is required (usually at the
spike sorting step). This enables one to build preprocessing chains to be applied in sequence to a
RecordingExtractor
object.
This is possible because each preprocessing step returns a new RecordingExtractor
that can be input to the next
step in the chain.
In this code example, we build a preprocessing chain with 2 steps:
bandpass filter
common median reference (CMR)
import spikeinterface.preprocessing import bandpass_filter, common_reference
# recording is a RecordingEctractor object
recording_f = bandpass_filter(recording, freq_min=300, freq_max=6000)
recording_cmr = common_reference(recording_f, operator="median")
After preprocessing, we can optionally save the processed recording with the efficient SI save()
function:
recording_saved = recording_cmr.save(folder="preprocessed", n_jobs=8, total_memory="2G")
In this case, the save()
function will process in parallel our original recording with the bandpass filter and
CMR and save it to a binary file in the “preprocessed” folder. The recording_saved
is yet another
RecordignExtractor
which maps directly to the newly created binary file, for very quick access.