The peak detection can be run without the GUI. The x, y and flags are passed, and Pout returned.
Pout =
...
peakdetect_run( y, x, flags );
x: time values
y: waveform
flags: parameters
flags.use_defaults: (optional) true uses default settings, false does not.
flags.use_previous: (optional) true uses last GUI settings, false does not.
flags.timeunits: the time units of "x", used for calculating rate in Hz and cycles/minute (as in beats/minute, or breaths/minute)
flags.[parameter]: (optional) use specified parameter values, and default settings for other parameters.
flags.decaytimeconstpk = 1;
flags.decaytimeconsttr = 3;
*flags.flagmeanmax flagmininterval = 0;
*flags.flagmeanmin mawindow = 05;
flags.flagmininterval mininterval = 0.25;
*flags.flagpeakmax threshlimpk = 010;
*flags.flagtroughmin threshlimtr = 08;
*flags.mawindow flagpeakmax = 50;
*flags.meanmax flagtroughmin = 1000;
*flags.meanmin flagmeanmax = -1000;
*flags.mininterval flagmeanmin = 0.25;
f*lagsflags.peakmax troughmin = -100;
*flags.threshlimpk meanmax = 10100;
*flags.threshlimtr meanmin = 8-100;
*flags.troughmin peakmax = - 100;
- Not used (as of 2015-03-23)
Example
x = D.recording{i}.ts.pleth.Time;
y = squeeze( D.recording{1}.ts.pleth.Data)
...
;
flags.timeunits = 'minutes';
flags.use_defaults = true;
P = peakdetect_run( y, x, flags );
figure, plot(P.ratex_seconds, P.ratey_bpm), xlabel('Time (seconds)'), ylabel('Rate (bpm)')