Signal Processing Functions#
This section documents the signal processing functions for spectral analysis, resampling, and baseline removal.
Spectral Analysis#
- eegprep.eeg_autocorr(EEG, pct_data=None)#
Compute autocorrelation of ICA components.
Parameters#
- EEGdict
EEG data structure with icaact
- pct_datafloat, optional
Percentage of data to use (default 100)
Returns#
- acndarray
Autocorrelation array
- eegprep.eeg_autocorr_welch(EEG, pct_data=100)#
Compute autocorrelation of EEG ICA components using Welch method.
Parameters#
- EEGdict
EEG data structure with ‘icaweights’, ‘icaact’, ‘pnts’, ‘srate’ fields.
- pct_datafloat, optional
Percentage of data to use. Default 100.
Returns#
- ndarray
Autocorrelation array.
- eegprep.eeg_rpsd(EEG, nfreqs=None, pct_data=100)#
Compute relative power spectral density for ICA components.
Parameters#
- EEGdict
EEG data structure with ICA activations.
- nfreqsint, optional
Number of frequency bins. Default is Nyquist frequency.
- pct_datafloat, optional
Percentage of data to use. Default is 100.
Returns#
- ndarray
Power spectral density in dB for each component.
Resampling#
- eegprep.pop_resample(EEG, freq, engine=None)#
Resample EEG data to a new sampling rate.
Parameters#
- EEGdict
EEGLAB EEG structure.
- freqfloat
New sampling rate in Hz.
- enginestr or None
Engine to use for implementation. Options are: - None: Use the default Python implementation - ‘poly’: Use scipy’s resample_poly function - ‘matlab’: Use MATLAB engine - ‘octave’: Use Octave engine
Returns#
- EEGdict
EEGLAB EEG structure with resampled data.
Baseline Removal#
- eegprep.pop_rmbase(EEG, timerange=None, pointrange=None, chanlist=None)#
POP_RMBASE - remove channel baseline means from an epoched or continuous EEG dataset.
- Return type:
- Parameters:
Parameters#
- EEGdict
EEGLAB-like EEG structure with keys: ‘data’, ‘nbchan’, ‘pnts’, ‘trials’, ‘times’, ‘event’. Event latencies are 1-based indices (EEGLAB convention).
- timerange[min_ms, max_ms] or None
Baseline latency range in milliseconds; overrides pointrange when provided.
- pointrangeiterable of indices or [start, end]
Baseline sample indices (0-based or 1-based tolerated). If None/empty, use whole epoch.
chanlist : iterable of channel indices (0-based). If None, all channels are used.
Returns#
- EEGdict
Updated EEG structure with baseline removed. EEG[‘icaact’] is cleared.