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:
size

The 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 a Raw dataset.

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 SourceEstimate object, 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:
dataarray, 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.

Returns:
tcarray, shape (1, n_times)

The time course that is extracted by the filter.

apply_raw(raw)#

Same as apply(), but designed to be applied directly to a Raw dataset.

Parameters:
rawRaw

The continuous data.

Returns:
tcarray, shape (1, n_times)

The time course that is extracted by the filter.

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:
leadfieldarray, shape (n_sensors, n_sources)

The leadfield matrix. Fixed source orientations are assumed, so each column corresponds to a single source.

modestr, default=”power”

Whether to return the CTF in terms of power (squared values) or amplitude (raw values).

normalizestr or None, default=”sum”

Whether and how to normalize the CTF. See Notes for more details on the available options.

Returns:
ctfarray, shape (n_sources,)

The cross-talk function of the spatial filter.

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 SourceEstimate object, which can be easily visualized on the brain surface.

Parameters:
fwdForward

The forward model.

modestr, default=”power”

Whether to return the CTF in terms of power (squared values) or amplitude (raw values).

normalizestr or None, default=”norm”

Whether and how to normalize the CTF. See the Notes section of get_ctf() for more details on the available options.

subjectstr, optional (default=None)

The subject name to be included in the returned SourceEstimate object.

Returns:
stcSourceEstimate

The CTF of the spatial filter as a SourceEstimate object.

plot(info, **topomap_kwargs)#

Plot the spatial filter as a topomap.

Parameters:
infoInfo

The Info object 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.

Returns:
immatplotlib.image.AxesImage

The interpolated data.

cnmatplotlib.contour.ContourSet

The fieldlines.

property size#

The number of channels (weights) in the filter.