Channel cleaning and referencing
Detection and interpolation of bad EEG channels and re-referencing of electrophysiological data.
almkanal.almkanal_steps.channel_utils.EEGRANSAC
Bases: AlmKanalStep
Detect and interpolate bad EEG channels using RANSAC.
EEGRANSAC uses :class:autoreject.Ransac to identify EEG channels whose
signals are poorly predicted from other EEG sensors. Continuous data are first
split into fixed-length epochs for RANSAC fitting. Channels identified as bad
are then marked in the original recording and interpolated using MNE.
Only EEG channels participate in RANSAC detection and interpolation. Existing bad channels of other channel types are preserved and excluded from the interpolation step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ransac_epoch_duration
|
int | float
|
Duration, in seconds, of the fixed-length epochs created from the continuous recording for RANSAC fitting. |
4
|
n_resample
|
int
|
Number of random sensor subsets used by RANSAC to estimate channel predictability. |
50
|
min_channels
|
float
|
Fraction of available EEG channels used for robust reconstruction during each RANSAC resampling iteration. |
0.25
|
min_corr
|
float
|
Minimum correlation between the measured and RANSAC-predicted signal for a channel to be considered sufficiently predictable. |
0.75
|
unbroken_time
|
float
|
Fraction of time for which a channel may fall below |
0.4
|
n_jobs
|
int
|
Number of parallel jobs used by :class: |
1
|
verbose
|
bool
|
Whether RANSAC should emit progress and diagnostic output. |
False
|
Notes
The continuous recording is segmented into fixed-length epochs solely for RANSAC fitting. These temporary epochs are not returned and do not replace the continuous pipeline data.
Only EEG channels are retained in the temporary RANSAC epochs. ECG, EOG, MEG, and other channel types therefore do not contribute to the bad-channel detection procedure.
Previously marked bad channels are preserved when the newly detected EEG bad channels are added. During interpolation, previously bad non-EEG channels are explicitly excluded so that this step only repairs EEG channels.
Interpolation is performed on the supplied raw object using
:meth:mne.io.Raw.interpolate_bads.
The processing metadata returned by :meth:run is stored under
'ransac_info' and contains the RANSAC epoch duration and effective RANSAC
configuration.
EEGRANSAC may occur multiple times in a pipeline and is intended to run
before ICA, forward modelling, spatial filtering, and source reconstruction.
See Also
autoreject.Ransac RANSAC implementation used for bad-channel detection. mne.make_fixed_length_epochs Create the temporary epochs used for RANSAC fitting. mne.io.Raw.interpolate_bads Interpolate channels marked as bad.
almkanal.almkanal_steps.channel_utils.ReReference
Bases: AlmKanalStep
Re-reference EEG, ECoG, sEEG, or DBS channels.
ReReference changes the reference of electrophysiological channels using
:meth:mne.io.Raw.set_eeg_reference. It supports references based on one or
more existing channels, average referencing, REST referencing, and explicit
per-channel reference mappings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ref_channels
|
str | list of str | dict
|
Reference specification passed to
:meth: Supported forms include:
|
'average'
|
projection
|
bool
|
Whether an average reference should be added as a projection rather than
applied directly to the data. When |
False
|
ch_type
|
str | list of str
|
Channel type or types to re-reference. Supported types include |
'auto'
|
forward
|
Forward | None
|
Forward solution used for REST referencing. Only relevant when
|
None
|
joint
|
bool
|
Whether multiple channel types specified by |
False
|
verbose
|
bool | str | int | None
|
Verbosity setting passed to :meth: |
False
|
Notes
Re-referencing is performed in place on the supplied raw object. The modified
object is returned under 'data'.
Except when adding an average-reference projection, the data must be preloaded before the reference can be applied.
For average referencing, channels marked as bad in data.info['bads'] are
excluded from the reference calculation by MNE.
REST referencing requires a suitable forward solution supplied through
forward.
The processing metadata returned by :meth:run is stored under 'ref_info'
and contains the reference channels, projection setting, channel types,
forward solution, joint-reference setting, and verbosity configuration.
ReReference may occur multiple times in a pipeline and is intended to run
before forward modelling, spatial filtering, and source reconstruction.
See Also
mne.io.Raw.set_eeg_reference Change the reference of channels in a raw recording. mne.set_eeg_reference General MNE function for re-referencing Raw, Epochs, or Evoked data.