MATLAB Answers

Finding RRI fluctuations (ECG) in 1s windows

7 views (last 30 days)
Shamus Sim
Shamus Sim on 10 Aug 2020
Commented: Shamus Sim on 11 Aug 2020
This is the code I am running.
%ECG data
load('Dog_1_interictal_segment_0001.mat')
sf = 399.0698; %sampling frequency (Hz), samples per second
T = 1/sf;
timeSeries = T:T:600.8122;
%filtering
%y filtered data
d = designfilt('lowpassfir', ...
'PassbandFrequency',0.15,'StopbandFrequency',0.2, ...
'PassbandRipple',1,'StopbandAttenuation',60, ...
'DesignMethod','equiripple');
y = filtfilt(d,interictal_segment_1.data(1,:));
%findpeak for y signal in row 1
[pks,locs] = findpeaks(y(1,:),'MinPeakDistance',0.3);
I have found the local max for my signal y(1,:). However i would like to find fluctuations in the signal for successive 1 second, non-overlapping windows. Supposed that peaks 1,2,3,4 are successive local max.
Such that:
fluctuation1=peak2-peak1
fluctuation2=peak3-peak2
fluctuations are counted for a total length of 1 second and data is kept in window.1. Repeat for another 1s and keep data in window.2.
I am new to Matlab so any help is appreciated. Thank you.

Answers (1)

Peng Li
Peng Li on 10 Aug 2020
Your question isn't quite clear. If you want to get fluctuations of subsequent points in a time series as you described above, you can use diff function to do the first order difference, or simply using locs(2:end) - locs(1:end-1) (locs in the variable you defined in your program).
The thing that is confusing is that you are trying to get RRI within a 1-s window. That doesn't make a lot of sense as usually the heart beats about once, or a bit more than twice per second when people exercise. You are not able to get any fluctuations from a single heart beat.
  2 Comments
Shamus Sim
Shamus Sim on 11 Aug 2020
I mean EEG signal not ECG. Sorry

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!