reference
labkit.biosignal.cropSignal
Return a signal clipped to a time range in seconds.
Syntax
cropped = labkit.biosignal.cropSignal(signal, timeRangeSec)
cropped = labkit.biosignal.cropSignal(signal)Description
Keeps samples whose timestamps lie between the requested start and end times, including both endpoints. For a nonempty result, time is shifted so that the first retained sample occurs at zero. The sample rate is recalculated from the median positive time step when at least two usable timestamps remain; otherwise the input sample rate is preserved.
Omitting timeRangeSec or passing [] returns signal unchanged. A valid range that contains no samples returns empty time and values vectors.
Inputs
signal- Biosignal structure with time, values, fs, and metadata fields. time and values must describe corresponding samples.
timeRangeSec- Two-element numeric vector [startSec endSec], expressed on signal.time, with startSec less than endSec. The value may be omitted or empty to skip cropping.
Outputs
cropped- Copy of signal containing only the selected samples. The original range is recorded in metadata.cropTimeRangeSec.
Errors
labkit:biosignal:InvalidSignal- signal does not contain time, values, and fs fields.
labkit:biosignal:InvalidTimeRange- timeRangeSec is not an increasing two-element vector.
Example
signal = struct('time', (0:0.5:3)', 'values', (10:16)', ...
'fs', 2, 'metadata', struct());
cropped = labkit.biosignal.cropSignal(signal, [0.75 2.25]);Related APIs
labkit.biosignal.filterSignal— Apply a zero-phase FFT-domain filter to a biosignal.labkit.biosignal.getChannel— Return one signal from a recording by display name or index.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.detectEcgPeaks— Detect ECG/QRS peaks as event anchors.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/cropSignal.m.