reference
labkit.biosignal.filterSignal
Apply a zero-phase FFT-domain filter to a biosignal.
Syntax
filtered = labkit.biosignal.filterSignal(signal)
filtered = labkit.biosignal.filterSignal(signal, spec)Description
Applies an ideal frequency mask in the discrete Fourier domain and uses an inverse transform to return a zero-phase filtered waveform. Low-pass and band-pass filtering restore the input mean after filtering; high-pass filtering does not. Missing samples are filled before the transform, so filtered.values is finite when the input contains enough finite data for interpolation.
Reflect edge mode extrapolates both ends of the waveform before applying the FFT and removes the padding afterward. A cosine taper is applied only to the outer padded samples. This reduces wraparound artifacts without changing the length or time axis of the signal. Use edgeMode "none" when the unpadded periodic FFT behavior is required.
Inputs
signal- Biosignal structure with values, fs, and metadata fields. fs is the sample rate in hertz.
spec- Optional scalar struct containing the fields listed below.
Options
type- "bandpass" (default), "lowpass", "highpass", "none", or "off". The latter two skip frequency masking but still fill missing data.
cutoffHz- Scalar cutoff for low-pass or high-pass filtering, or a two-element [low high] band for band-pass filtering. The default is [0.5 40] Hz. Empty or nonfinite values skip filtering and return the filled waveform.
edgeMode- "reflect" (default) or "none". The aliases "reflection", "symmetric", "pad", and "padded" select reflection; "off" and "raw" select no padding.
edgePadSec- Nonnegative padding duration in seconds. By default, band-pass and high-pass filters use three periods of the lowest cutoff, limited to 0.5 through 5 seconds. Other filters use 1 second. Padding cannot exceed half the available signal minus one sample.
edgeTaperSec- Nonnegative duration of the outer padding taper. The default is 1 second.
Outputs
filtered- Copy of signal with filtered values. All other signal fields are preserved, and metadata.filter records spec exactly as supplied by the caller.
Errors
labkit:biosignal:InvalidSignal- signal lacks values or fs.
labkit:biosignal:UnsupportedFilter- type is not supported.
labkit:biosignal:UnsupportedFilterEdgeMode- edgeMode is not supported.
Example
fs = 100;
time = (0:1/fs:2)';
values = sin(2*pi*2*time) + 0.2*sin(2*pi*30*time);
signal = struct('time', time, 'values', values, 'fs', fs, ...
'metadata', struct());
filtered = labkit.biosignal.filterSignal(signal, ...
struct('type', 'lowpass', 'cutoffHz', 10));Related APIs
labkit.biosignal.cropSignal— Return a signal clipped to a time range in seconds.labkit.biosignal.detectEcgPeaks— Detect ECG/QRS peaks as event anchors.labkit.biosignal.buildTemplate— Build a representative segment template.labkit.biosignal.compareGroups— Summarize groups and compute pairwise Welch comparisons.labkit.biosignal.defaultEcgPeakOptions— Return documented defaults for ECG/QRS peak detection.labkit.biosignal.getChannel— Return one signal from a recording by display name or index.labkit.biosignal.listChannels— Return display names for all channels in a recording.labkit.biosignal.measureSegments— Measure generic template-residual segment quality.
Source
This page is generated from the MATLAB help text in +labkit/+biosignal/filterSignal.m.