LabKit MATLAB Workbench

reference

API ReferenceResponse Review And Stats

response_review_stats.analysisRun.measureAlignedSegments

Measure peak-to-peak, noise, and SNR per segment.

Syntax

metrics = response_review_stats.analysisRun.measureAlignedSegments(aligned) metrics = response_review_stats.analysisRun.measureAlignedSegments( ... aligned, opts)

Description

Baseline-corrects every aligned trace, measures its positive and negative extrema, and estimates baseline noise and peak-to-peak SNR. Each segment is measured independently and produces one output row. Peaks use only finite samples; NaN samples are omitted from baseline and noise means.

Inputs

aligned
Structure returned by response_review_stats.analysisRun.alignSegments. timeSec is G-by-1, values is G-by-N, and segmentNames contains N names.
opts
Optional scalar structure containing the measurement windows below.

Options

baselineWindowSec
Inclusive [start end] interval in aligned seconds used to calculate and subtract the baseline mean. Default: [0.007 0.009].
noiseWindowSec
Two-element numeric [start end] interval used for noise RMS after baseline subtraction. Default: baselineWindowSec.
measurementWindowSec
Inclusive interval used for positive and negative peaks. Empty input uses all aligned samples. Default: [].

Calculations

PeakToPeak = Peak1Value-Peak2Value, where Peak1 is the finite maximum and Peak2 is the finite minimum in the measurement window. NoiseRMS is the root mean square deviation from the finite noise-window mean. When NoiseRMS is positive and PeakToPeak is finite, SNR_dB is 20*log10(abs(PeakToPeak)/NoiseRMS). A window without usable samples leaves its metrics as NaN. A missing baseline also makes that segment's corrected trace and downstream measurements NaN.

Outputs

metrics
N-row table with SegmentName, BaselineStart_s, BaselineEnd_s, PeakToPeak, Peak1Time_s, Peak1Value, Peak2Time_s, Peak2Value, NoiseStart_s, NoiseEnd_s, NoiseRMS, and SNR_dB columns.

Failure Behavior

Windows without usable finite samples produce NaN metrics for the affected segment. aligned must provide compatible timeSec, values, and segmentNames fields, and every supplied window must contain two numeric endpoints; malformed values propagate the originating field, indexing, or conversion error.

Example

aligned = struct("timeSec", (0:0.001:0.012).', ...
"values", zeros(13, 1), "segmentNames", "response", "status", "ok");
aligned.values(7) = 2;
aligned.values(11) = -1;
opts = struct("baselineWindowSec", [0 0.002], ...
"noiseWindowSec", [0 0.002]);
metrics = response_review_stats.analysisRun.measureAlignedSegments( ...
aligned, opts);
assert(metrics.PeakToPeak == 3)

Source

This page is generated from the MATLAB help text in apps/neurophysiology/response_review_stats/+response_review_stats/+analysisRun/measureAlignedSegments.m.