nirspipe.pipeline.denoise#
Bandpass and resample, and the one place in the package a filter is designed.
Module Contents#
Functions#
Length in samples of the FIR that filter_kwargs would build. |
|
Keyword arguments for one bandpass design, for Raw.filter or mne.filter.filter_data. |
|
One sentence naming the filter, for logs and for a methods section. |
|
Frequency response of the design filter_kwargs returns, as (freqs, dB). |
|
bandpass_filter’s filter applied to a plain (…, n_times) array. |
|
A copy of |
|
Data#
API#
- nirspipe.pipeline.denoise.logger = 'get_logger(...)'#
- nirspipe.pipeline.denoise.FILTER_METHODS = ('iir', 'fir')#
- nirspipe.pipeline.denoise.DEFAULT_FILTER_METHOD = 'iir'#
- nirspipe.pipeline.denoise.DEFAULT_FILTER_ORDER = 4#
- nirspipe.pipeline.denoise.FIR_TRANS_RATIO = 0.5#
- nirspipe.pipeline.denoise.fir_taps(sfreq: float, l_freq: float | None, h_freq: float | None) int#
Length in samples of the FIR that filter_kwargs would build.
The narrower of the two transition bands sets it, which is usually the high-pass: fir_taps(10.0, 0.05, 0.5) -> 661.
- nirspipe.pipeline.denoise.filter_kwargs(sfreq: float, n_times: int, l_freq: float | None = None, h_freq: float | None = None, method: str = DEFAULT_FILTER_METHOD, order: int = DEFAULT_FILTER_ORDER) dict#
Keyword arguments for one bandpass design, for Raw.filter or mne.filter.filter_data.
- filter_kwargs(10.17, 3051, 0.02, 0.2) ->
{“method”: “iir”, “iir_params”: {“order”: 4, “ftype”: “butter”, “output”: “sos”}}
Raises FilterDesignError when a FIR sharp enough to mean what its cutoffs say is longer than the recording. MNE only warns there and truncates, which would leave one set of nominal parameters meaning different filters on runs of different length.
- nirspipe.pipeline.denoise.filter_description(l_freq: float | None, h_freq: float | None, method: str = DEFAULT_FILTER_METHOD, order: int = DEFAULT_FILTER_ORDER) str#
One sentence naming the filter, for logs and for a methods section.
filter_description(0.02, 0.2) -> “zero-phase Butterworth bandpass, order 4, 0.02-0.2 Hz”
- nirspipe.pipeline.denoise.filter_response(sfreq: float, n_times: int, l_freq: float | None = None, h_freq: float | None = None, method: str = DEFAULT_FILTER_METHOD, order: int = DEFAULT_FILTER_ORDER, n_points: int = 4096) tuple[numpy.ndarray, numpy.ndarray]#
Frequency response of the design filter_kwargs returns, as (freqs, dB).
For plotting the filter itself rather than inferring it from a before/after pair. The IIR branch doubles the dB because MNE applies it with filtfilt, so what is drawn is the attenuation the data actually receives.
- nirspipe.pipeline.denoise.filter_array(data: numpy.ndarray, sfreq: float, l_freq: float | None = None, h_freq: float | None = None, method: str = DEFAULT_FILTER_METHOD, order: int = DEFAULT_FILTER_ORDER) numpy.ndarray#
bandpass_filter’s filter applied to a plain (…, n_times) array.
For signals that have to match the data but do not travel inside the Raw, which is the aux regressors: they come from a separate file and would otherwise be regressed against data that had been through a filter they never saw.
- nirspipe.pipeline.denoise.band_limited(raw: mne.io.Raw, l_freq: float | None, h_freq: float | None, method: str = DEFAULT_FILTER_METHOD, order: int = DEFAULT_FILTER_ORDER) mne.io.Raw#
A copy of
rawthrough the same filter design bandpass_filter writes with.For measuring a stage on the analysis band, not for writing one, so nothing is stamped. MNE’s own default is a FIR whose low-pass transition is at least 2 Hz wide, which leaves a haemodynamic low-pass all but open.
- nirspipe.pipeline.denoise.bandpass_filter(haemo: mne.io.Raw, l_freq: float | None = None, h_freq: float | None = None, method: str = DEFAULT_FILTER_METHOD, order: int = DEFAULT_FILTER_ORDER) mne.io.Raw#
- nirspipe.pipeline.denoise.resample(haemo: mne.io.Raw, sfreq: float) mne.io.Raw#