v2.0.0
Loading...
Searching...
No Matches
UTILSLIB::FirFilter Class Reference

Discoverable façade over the FilterKernel FIR-filter engine. More...

#include <firfilter.h>

Public Types

enum  FilterType { LowPass = 0 , HighPass = 1 , BandPass = 2 , BandStop = 3 }
 FIR filter type — mirrors IirFilter::FilterType for a uniform API. More...
enum  DesignMethod { Cosine = 0 , ParksMcClellan = 1 }
 FIR design method — wraps FilterKernel's iDesignMethod integer codes. More...

Static Public Member Functions

static FilterKernel design (int iOrder, FilterType type, double dCutoffLow, double dCutoffHigh, double dSFreq, double dTransition=5.0, DesignMethod method=Cosine)
static Eigen::RowVectorXd apply (const Eigen::RowVectorXd &vecData, FilterKernel &kernel)
static Eigen::RowVectorXd applyZeroPhase (const Eigen::RowVectorXd &vecData, FilterKernel &kernel)
static Eigen::MatrixXd applyZeroPhaseMatrix (const Eigen::MatrixXd &matData, FilterKernel &kernel, const Eigen::RowVectorXi &vecPicks=Eigen::RowVectorXi())
static Eigen::RowVectorXd designMne (double dSFreq, double dLFreq, double dHFreq)
static Eigen::MatrixXd filterData (const Eigen::MatrixXd &matData, double dSFreq, double dLFreq, double dHFreq)

Detailed Description

Discoverable façade over the FilterKernel FIR-filter engine.

Mirrors the IirFilter API:

designMne / filterData reproduce mne.filter.create_filter / filter_data:

Definition at line 62 of file firfilter.h.

Member Enumeration Documentation

◆ DesignMethod

FIR design method — wraps FilterKernel's iDesignMethod integer codes.

Enumerator
Cosine 

Cosine window (fast, moderate roll-off).

ParksMcClellan 

Equiripple Parks-McClellan (optimal minimax).

Definition at line 81 of file firfilter.h.

◆ FilterType

FIR filter type — mirrors IirFilter::FilterType for a uniform API.

Enumerator
LowPass 

Low-pass filter.

HighPass 

High-pass filter.

BandPass 

Band-pass filter.

BandStop 

Band-stop (notch) filter.

Definition at line 69 of file firfilter.h.

Member Function Documentation

◆ apply()

RowVectorXd FirFilter::apply ( const Eigen::RowVectorXd & vecData,
FilterKernel & kernel )
static

Apply the filter to a single row vector.

Uses overlap-add FFT convolution. The group delay of a symmetric FIR is removed by the FilterKernel engine (it takes the output segment starting at order/2), so the result is already approximately zero-phase for symmetric designs.

Parameters
[in]vecDataInput row vector.
[in,out]kernelFilterKernel (prepareFilter is called if needed).
Returns
Filtered row vector (same length as input).

Definition at line 114 of file firfilter.cpp.

◆ applyZeroPhase()

RowVectorXd FirFilter::applyZeroPhase ( const Eigen::RowVectorXd & vecData,
FilterKernel & kernel )
static

Apply the filter in a zero-phase forward-backward pass to a single row vector.

Runs the filter twice (forward then reverse) to achieve exactly zero phase shift. Effective order is doubled; transition bandwidth is halved.

Parameters
[in]vecDataInput row vector.
[in,out]kernelFilterKernel.
Returns
Zero-phase filtered row vector.

Definition at line 124 of file firfilter.cpp.

◆ applyZeroPhaseMatrix()

MatrixXd FirFilter::applyZeroPhaseMatrix ( const Eigen::MatrixXd & matData,
FilterKernel & kernel,
const Eigen::RowVectorXi & vecPicks = Eigen::RowVectorXi() )
static

Apply the filter in a zero-phase forward-backward pass to every row of a matrix.

Parameters
[in]matDataInput matrix (n_channels × n_samples).
[in,out]kernelFilterKernel.
[in]vecPicksOptional row indices to filter; if empty, all rows are filtered.
Returns
Zero-phase filtered matrix (same dimensions as input).

Definition at line 140 of file firfilter.cpp.

◆ design()

FilterKernel FirFilter::design ( int iOrder,
FilterType type,
double dCutoffLow,
double dCutoffHigh,
double dSFreq,
double dTransition = 5.0,
DesignMethod method = Cosine )
static

Design a linear-phase FIR filter using FilterKernel as the backend.

Frequencies are given in Hz; the method converts them to the Nyquist-normalised form expected by FilterKernel internally.

Parameters
[in]iOrderFilter order (number of taps − 1). Must be even for linear phase.
[in]typeFilter type (LowPass, HighPass, BandPass, BandStop).
[in]dCutoffLowLower cutoff frequency in Hz. For LowPass/HighPass: the single cutoff. For BandPass/BandStop: lower edge of the transition band.
[in]dCutoffHighUpper cutoff frequency in Hz (ignored for LowPass/HighPass).
[in]dSFreqSampling frequency in Hz.
[in]dTransitionWidth of the transition band in Hz (Parks-McClellan steepness / Cosine roll-off width). Defaults to 5 Hz.
[in]methodDesign method (Cosine or ParksMcClellan).
Returns
A ready-to-use FilterKernel object.

Definition at line 48 of file firfilter.cpp.

◆ designMne()

RowVectorXd FirFilter::designMne ( double dSFreq,
double dLFreq,
double dHFreq )
static

Designs the zero-phase FIR filter of mne.filter.create_filter with its defaults: firwin design with a Hamming window, "auto" transition bands (min(max(0.25 f, 2 Hz), f) below, min(max(0.25 f, 2 Hz), Nyquist - f) above) and "auto" length 3.3 / narrowest band.

Parameters
[in]dSFreqSampling frequency in Hz.
[in]dLFreqHigh-pass edge in Hz, or a negative value for a low-pass.
[in]dHFreqLow-pass edge in Hz, or a negative value for a high-pass.
Returns
The odd-length impulse response.

Definition at line 167 of file firfilter.cpp.

◆ filterData()

MatrixXd FirFilter::filterData ( const Eigen::MatrixXd & matData,
double dSFreq,
double dLFreq,
double dHFreq )
static

Filters every row like mne.filter.filter_data with its FIR defaults: the designMne kernel applied by overlap-add with zero phase, each row padded by reflecting it about its end samples ("reflect_limited").

Parameters
[in]matDataData, one row per channel.
[in]dSFreqSampling frequency in Hz.
[in]dLFreqHigh-pass edge in Hz, or a negative value for a low-pass.
[in]dHFreqLow-pass edge in Hz, or a negative value for a high-pass.
Returns
The filtered data.

Definition at line 224 of file firfilter.cpp.


The documentation for this class was generated from the following files: