roiextract.filter.SpatialFilter#
- class roiextract.filter.SpatialFilter(w, method='', method_params={}, ch_names=None, name='')#
Convenience wrapper around a NumPy array that contains the weights of the spatial filter for each data channel.
- Attributes:
sizeThe number of channels (weights) in the filter.
Methods
apply(data[, ch_names])Apply the filter to the provided data.
apply_raw(raw)Same as
apply(), but designed to be applied directly to aRawdataset.get_ctf(leadfield[, mode, normalize])Get the cross-talk function (CTF) of the spatial filter.
get_ctf_fwd(fwd[, mode, normalize, subject])Get the CTF of the spatial filter as a
SourceEstimateobject, which can be easily visualized on the brain surface.plot(info, **topomap_kwargs)Plot the spatial filter as a topomap.
- apply(data, ch_names=None)#
Apply the filter to the provided data.
- Parameters:
- data
array, shape (n_sensors, n_times) The continuous data.
- ch_namesoptional, default=None
The names of channels in the provided data. If the names are provided, they are used to ensure that the data channels and filter weights are matched. If it is not possible, an error is raised.
- data
- Returns:
- tc
array, shape (1, n_times) The time course that is extracted by the filter.
- tc
- apply_raw(raw)#
Same as
apply(), but designed to be applied directly to aRawdataset.- Parameters:
- raw
Raw The continuous data.
- raw
- Returns:
- tc
array, shape (1, n_times) The time course that is extracted by the filter.
- tc
Notes
If both the spatial filter and the dataset contain the names of individual channels, this function ensures that the channels and filter weights are matched properly. An error is raised if the number of channels differs between the filter and the dataset, or if the names of channels do not match.
- get_ctf(leadfield, mode='power', normalize='sum')#
Get the cross-talk function (CTF) of the spatial filter.
- Parameters:
- leadfield
array, shape (n_sensors, n_sources) The leadfield matrix. Fixed source orientations are assumed, so each column corresponds to a single source.
- mode
str, default=”power” Whether to return the CTF in terms of power (squared values) or amplitude (raw values).
- normalize
strorNone, default=”sum” Whether and how to normalize the CTF. See Notes for more details on the available options.
- leadfield
- Returns:
- ctf
array, shape (n_sources,) The cross-talk function of the spatial filter.
- ctf
Notes
The following normalization options for the resulting CTF are available:
If
None, no normalization is applied.If
"max", the CTF is normalized by its maximum absolute value. This option is useful when visualizing the CTF, as it ensures that the values are in a comparable range across different filters.If
"norm", the CTF is normalized by its Euclidean norm.If
"sum", the CTF is normalized by the sum of its absolute values. This option is useful in combination with the"power"mode, as it allows interpreting the CTF values as fractions of the total power potentially contributed by different sources to the extracted time course.
- get_ctf_fwd(fwd, mode='power', normalize='norm', subject=None)#
Get the CTF of the spatial filter as a
SourceEstimateobject, which can be easily visualized on the brain surface.- Parameters:
- fwd
Forward The forward model.
- mode
str, default=”power” Whether to return the CTF in terms of power (squared values) or amplitude (raw values).
- normalize
strorNone, default=”norm” Whether and how to normalize the CTF. See the Notes section of
get_ctf()for more details on the available options.- subject
str, optional (default=None) The subject name to be included in the returned
SourceEstimateobject.
- fwd
- Returns:
- stc
SourceEstimate The CTF of the spatial filter as a
SourceEstimateobject.
- stc
- plot(info, **topomap_kwargs)#
Plot the spatial filter as a topomap.
- Parameters:
- info
Info The
Infoobject that contains the information about the set of data channels, for which the filter is designed.- **topomap_kwargs
Additional keyword arguments that are forwarded to the
mne.viz.plot_topomap()function without modification.
- info
- Returns:
- im
matplotlib.image.AxesImage The interpolated data.
- cn
matplotlib.contour.ContourSet The fieldlines.
- im
- property size#
The number of channels (weights) in the filter.