% read the data (use selector and change Filetype to .log!) ecg = xff('*.ntt'); % get the data in channel 3 ecg_data = ecg.ChannelData(3); % compute a transformation (to improve the detection of heartbeats) ecg_dt = abs(ztrans(ecg_data)) .^ 2; % run a first pass of detection and plot the result // options used are: % - freq: frequency (must be known for text-based files!) % - skewdt: since we squared (the absolute z-transform of) the signal, % we need to lower this value accordingly! % - detlength: with the squared transformation, peaks become very thin % spikes (<0.05 seconds!) % - plot: set to true to create outcome windows ecg_beats = heartbeats(ecg_dt, struct( ... 'freq', 500, ... 'skewdt', 0.05, ... 'detlength', 0.02, ... 'plot', true)); % re-run heartbeats with original signal and pre-detection // new options: % - bppre: used to pass in the already detected beats % - cleanup: show manual clean-up interface % - ecg_beats = heartbeats(ecg_data, struct( ... 'freq', 500, ... 'bppre', ecg_beats, ... 'cleanup', true, ... 'plot', true)); % pass beats to computehrv hrv = computehrv(ecg_beats, struct('freq', 500)); % plot periodogram plot(hrv.prawf, hrv.praw); % compute relative power contribution HFP/LFP rel_pow_HoverL = hrv.hfp / hrv.lfp;