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

Polyphase anti-aliased rational resampling for MEG/EEG data. More...

#include <resample.h>

Static Public Member Functions

static Eigen::RowVectorXd resample (const Eigen::RowVectorXd &vecData, double dNewSFreq, double dOldSFreq, int iNZeros=10)
static Eigen::MatrixXd resampleMatrix (const Eigen::MatrixXd &matData, double dNewSFreq, double dOldSFreq, const Eigen::RowVectorXi &vecPicks=Eigen::RowVectorXi(), int iNZeros=10)

Detailed Description

Polyphase anti-aliased rational resampling for MEG/EEG data.

// Resample from 1000 Hz to 250 Hz (4:1 decimation)
Eigen::RowVectorXd downsampled = Resample::resample(vecData, 250.0, 1000.0);
// Resample all channels of a raw data matrix
Eigen::MatrixXd ds = Resample::resampleMatrix(matData, 250.0, 1000.0);
static Eigen::RowVectorXd resample(const Eigen::RowVectorXd &vecData, double dNewSFreq, double dOldSFreq, int iNZeros=10)
Definition resample.cpp:161
static Eigen::MatrixXd resampleMatrix(const Eigen::MatrixXd &matData, double dNewSFreq, double dOldSFreq, const Eigen::RowVectorXi &vecPicks=Eigen::RowVectorXi(), int iNZeros=10)
Definition resample.cpp:196

Definition at line 84 of file resample.h.

Member Function Documentation

◆ resample()

RowVectorXd Resample::resample ( const Eigen::RowVectorXd & vecData,
double dNewSFreq,
double dOldSFreq,
int iNZeros = 10 )
static

Resample a single-channel row vector from dOldSFreq to dNewSFreq.

The ratio is reduced to its lowest terms p/q via GCD, then a polyphase Hamming-windowed sinc filter is applied. The output length is ceil(nSamples · p / q).

Parameters
[in]vecDataInput row vector (calibrated, SI units).
[in]dNewSFreqTarget sampling frequency in Hz.
[in]dOldSFreqOriginal sampling frequency in Hz.
[in]iNZerosNumber of sinc zero-crossings on each side of the kernel (default 10). Higher values give better stopband attenuation at the cost of speed.
Returns
Resampled row vector.

Definition at line 161 of file resample.cpp.

◆ resampleMatrix()

MatrixXd Resample::resampleMatrix ( const Eigen::MatrixXd & matData,
double dNewSFreq,
double dOldSFreq,
const Eigen::RowVectorXi & vecPicks = Eigen::RowVectorXi(),
int iNZeros = 10 )
static

Resample every row of a data matrix.

Parameters
[in]matDataInput matrix (n_channels × n_samples).
[in]dNewSFreqTarget sampling frequency in Hz.
[in]dOldSFreqOriginal sampling frequency in Hz.
[in]vecPicksOptional channel indices to resample; if empty all rows are processed. Non-selected rows are returned at their original length — in practice always pass picks or leave empty for a uniform matrix result.
[in]iNZerosSinc zero-crossings per side (default 10).
Returns
Resampled matrix (n_channels × n_new_samples).

Definition at line 196 of file resample.cpp.


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