pycrostates.preprocessing.apply_spatial_filter#
- pycrostates.preprocessing.apply_spatial_filter(inst, ch_type='eeg', exclude_bads=True, origin='auto', adjacency='auto', n_jobs=1, verbose=None)[source]#
Apply a spatial filter.
Adapted from Michel and Brunet[1]. Apply an instantaneous filter which interpolates channels with local neighbors while removing outliers. The current implementation proceeds as follows:
An interpolation matrix is computed using
mne.channels.interpolation._make_interpolation_matrix.An ajdacency matrix is computed using
mne.channels.find_ch_adjacency.If
exclude_badsis set toTrue, bad channels are removed from the ajdacency matrix.For each timepoint and each channel, a reduced adjacency matrix is built by removing neighbors with lowest and highest value.
For each timepoint and each channel, a reduced interpolation matrix is built by extracting neighbor weights based on the reduced adjacency matrix.
The reduced interpolation matrices are normalized.
The channel’s timepoints are interpolated using their reduced interpolation matrix.
- Parameters:
- inst
Raw|Epochs|ChData Instance to filter spatially.
- ch_type
str The channel type on which to apply the spatial filter. Currently only supports
'eeg'.- exclude_bads
bool If set to
True, bad channels will be removed from the adjacency matrix and therefore not used to interpolate neighbors. In addition, bad channels will not be filtered. If set toFalse, proceed as if all channels were good.- origin
arrayof shape (3,) |str Origin of the sphere in the head coordinate frame and in meters. Can be
'auto'(default), which means a head-digitization-based origin fit.- adjacency
arrayorcsr_matrixof shape (n_channels, n_channels) |str An adjacency matrix. Can be created using
mne.channels.find_ch_adjacency()and edited withmne.viz.plot_ch_adjacency(). If'auto'(default), the matrix will be automatically created usingmne.channels.find_ch_adjacency()and other parameters.- n_jobs
int|None The number of jobs to run in parallel. If
-1, it is set to the number of CPU cores. Requires thejoblibpackage.None(default) is a marker for ‘unset’ that will be interpreted asn_jobs=1(sequential execution) unless the call is performed under ajoblib.parallel_configcontext manager that sets another value forn_jobs.- verbose
int|str|bool|None Sets the verbosity level. The verbosity increases gradually between
"CRITICAL","ERROR","WARNING","INFO"and"DEBUG". If None is provided, the verbosity is set to"WARNING". If a bool is provided, the verbosity is set to"WARNING"for False and to"INFO"for True.
- inst
- Returns:
Notes
This function requires a full copy of the data in memory.
References