Filtering and resampling
Temporal filtering and changes in sampling frequency for continuous or epoched M/EEG data.
Use StimulusEpochs(resample_sfreq=...) to change the sampling rate before
stimulus features are computed. A later Resample step warns when it changes
the rate because resampling appended features can distort binary (0/1) values.
almkanal.almkanal_steps.filter_utils.Filter
Bases: AlmKanalStep
Apply temporal filtering to continuous or epoched M/EEG data.
Filter applies high-pass, low-pass, band-pass, or band-stop filtering
using MNE's filtering implementation. The configured filter is applied
directly to the supplied :class:mne.io.BaseRaw or
:class:mne.BaseEpochs object.
In addition to performing the filter operation, the step records the
effective filter settings in the processing history. When transition
bandwidths are set to 'auto', concrete values are resolved before
filtering so that the reported preprocessing parameters remain explicit
and reproducible.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
highpass
|
float | None
|
High-pass cutoff frequency, in Hz. Passed to MNE as |
None
|
lowpass
|
float | None
|
Low-pass cutoff frequency, in Hz. Passed to MNE as |
None
|
picks
|
str | array - like | slice | None
|
Channels to filter. Passed directly to MNE. |
None
|
filter_length
|
str | int
|
Filter length passed to MNE. |
'auto'
|
l_trans_bandwidth
|
float | {'auto'}
|
Transition bandwidth, in Hz, below the high-pass cutoff. When set to
|
'auto'
|
h_trans_bandwidth
|
float | {'auto'}
|
Transition bandwidth, in Hz, above the low-pass cutoff. When set to
|
'auto'
|
n_jobs
|
int | str | None
|
Number of parallel jobs used for filtering. |
None
|
method
|
str
|
Filtering method passed to MNE, for example |
'fir'
|
iir_params
|
dict | None
|
Parameters used for IIR filtering. When |
None
|
phase
|
str
|
Phase response used for filtering. |
'zero'
|
fir_window
|
str
|
Window used for FIR filter design. |
'hamming'
|
fir_design
|
str
|
FIR design method passed to MNE. |
'firwin'
|
skip_by_annotation
|
str | tuple of str | list of str
|
Annotation descriptions over which filtering is skipped. |
('edge', 'bad_acq_skip')
|
pad
|
str
|
Padding mode used at the signal boundaries. |
'reflect_limited'
|
Notes
The filter is applied in place to the supplied MNE object.
highpass and lowpass correspond to MNE's l_freq and h_freq
parameters, respectively. Supplying only highpass produces a high-pass
filter, supplying only lowpass produces a low-pass filter, and supplying
both produces a band-pass filter.
When transition bandwidths are set to 'auto', the values used for
filtering are resolved explicitly before the MNE call. This ensures that
the processing history records concrete transition bandwidths rather than
the symbolic 'auto' setting.
skip_by_annotation is normalized to a JSON-friendly representation
before being stored in the processing metadata.
The processing metadata returned by :meth:run is stored under
'filter_info' and contains the effective cutoff frequencies,
transition bandwidths, filter design parameters, channel selection, and
annotation-skipping configuration.
Filter may occur multiple times in a pipeline.
See Also
mne.io.Raw.filter Filter continuous M/EEG data. mne.Epochs.filter Filter epoched M/EEG data.
almkanal.almkanal_steps.filter_utils.Resample
Bases: AlmKanalStep
Resample continuous or epoched M/EEG data.
Resample changes the sampling frequency of an
:class:mne.io.BaseRaw or :class:mne.BaseEpochs object using MNE's
resampling implementation.
When downsampling, the step requires the data to have been explicitly low-pass filtered at or below the Nyquist frequency of the requested sampling rate. Although MNE applies anti-aliasing internally during resampling, AlmKanal requires an explicit preceding low-pass filter so that the effective preprocessing settings are recorded in the processing history and can be reported reproducibly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sfreq
|
int
|
Target sampling frequency, in Hz. |
required |
npad
|
str
|
Amount of padding used during resampling. Passed directly to MNE's
|
'auto'
|
window
|
str
|
Window specification used for resampling. Passed directly to MNE's
|
'auto'
|
n_jobs
|
int | None
|
Number of parallel jobs used during resampling. |
None
|
pad
|
str
|
Padding mode used at the signal boundaries. |
'auto'
|
method
|
str
|
Resampling method passed to MNE. |
'fft'
|
Notes
Before resampling, the current low-pass frequency is compared with the
Nyquist frequency of sfreq. If the low-pass cutoff exceeds the new
Nyquist frequency, :meth:run raises a :class:ValueError and instructs
the user to apply an explicit anti-aliasing filter first.
Resampling is performed in place on the supplied MNE object.
Changing the sampling rate after StimulusEpochs emits a warning because
it also resamples appended stimulus features, which can distort binary
(0/1) values. Use StimulusEpochs(resample_sfreq=...) to resample before
feature extraction instead.
The processing metadata returned by :meth:run is stored under
'resample_info' and contains the target sampling frequency together
with the effective resampling parameters.
Resample may occur multiple times in a pipeline.
See Also
mne.io.Raw.resample Resample continuous data. mne.Epochs.resample Resample epoched data.