Spatial filtering
SpatialFilter constructs spatial filters for M/EEG source analysis using MNE-Python.
Feature channels added by a preceding StimulusEpochs step are automatically
preserved alongside any channels listed in chans2keep. Their data are returned
in extra_data by the subsequent SourceReconstruction step.
almkanal.almkanal_steps.spatial_filter_utils.SpatialFilter
Bases: AlmKanalStep
Compute LCMV spatial filters for source reconstruction.
SpatialFilter computes data and noise covariance matrices as needed and
constructs an LCMV beamformer for subsequent source reconstruction. The
forward model and channel-selection parameters can either be supplied
directly or obtained from preceding pipeline configuration.
If an empty-room recording is used to estimate the noise covariance, the relevant preprocessing history is passed along so that compatible preprocessing can be applied to the empty-room data before covariance estimation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fwd
|
Forward | None
|
Forward model used to construct the spatial filter. If |
None
|
pick_dict
|
dict | None
|
Channel-selection parameters used for spatial filtering. If |
None
|
data_cov
|
Covariance | None
|
Precomputed data covariance matrix. If |
None
|
noise_cov
|
Covariance | None
|
Precomputed noise covariance matrix. If provided, it is used directly.
Otherwise, a covariance can be derived from |
None
|
empty_room
|
str | BaseRaw | None
|
Empty-room recording used to estimate the noise covariance. May be a
path to a recording or an already loaded :class: |
None
|
nearest_empty_room
|
bool
|
Whether an empty-room recording nearest in acquisition date should be selected when resolving empty-room data. |
False
|
chans2keep
|
list of str | None
|
Channels to preserve separately before spatial-filter channel selection,
for example stimulus features, ECG, EOG, or eye-tracking channels.
Their data are stored in the returned spatial-filter metadata.
Feature channels added by a preceding |
None
|
lcmv_reg
|
float
|
Regularization parameter passed to the LCMV beamformer computation. |
0.05
|
lcmv_pick_ori
|
str | None
|
Source-orientation selection passed to the LCMV beamformer. |
'max-power'
|
lcmv_weight_norm
|
str | None
|
Weight-normalization method passed to the LCMV beamformer. |
'nai'
|
lcmv_reduce_rank
|
bool
|
Whether to reduce the rank during LCMV filter construction. |
False
|
Notes
pick_dict takes precedence over pipeline-level pick_params. If
neither is available, :meth:run raises a :class:ValueError.
Likewise, an explicitly supplied fwd takes precedence over the forward
model stored by a preceding ForwardModel step.
The input data are returned unchanged. Computed spatial-filter information
is stored under 'spatial_filter_info' and contains the beamformer
filters, effective LCMV settings, data covariance, noise covariance, and any
channels preserved through chans2keep or added by StimulusEpochs.
SourceReconstruction returns these channels in its extra_data dictionary.
When empty-room data are used, the pipeline's ordered processing history is passed to the empty-room preprocessing machinery so that relevant previous preprocessing steps can be replayed before estimating the noise covariance.
SpatialFilter is intended to precede SourceReconstruction and can
occur only once in a pipeline.
See Also
comp_spatial_filters Compute the covariance matrices and LCMV beamformer. SourceReconstruction Apply the resulting spatial filters to reconstruct source activity. ForwardModel Produce the forward solution used for spatial filtering.