Is it possible to save ECG waveform data as an text file with RR-intervals?
3 views (last 30 days)
Show older comments
Hi!
We have an ECG text file from LabChart Lightning and want to analyze the R-R intervals in matlab but have no idea how to transform/save the text file so that it works i matlab (HRV-tools). Can anyone please help us? I attach the text file we are using. Thank you!
0 Comments
Answers (2)
Star Strider
on 18 Oct 2021
I am not certain what the desired result is.
Try this —
EKGsig = readmatrix('https://www.mathworks.com/matlabcentral/answers/uploaded_files/770486/Sara3.txt', 'HeaderLines',5)
t = EKGsig(:,1);
EKG = EKGsig(:,2);
Ts = mean(diff(t)); % Sampling Interval
Fs = 1/Ts; % Sampling Frequency
Fn = Fs/2; % Nyquist Frequency
[EKG,df1] = highpass(EKG, 4.5, Fs, 'ImpulseResponse','iir'); % Filter
[EKG,df2] = lowpass(EKG, 35, Fs, 'ImpulseResponse','iir'); % Filter
[Rwv,Rlocs] = findpeaks(EKG, 'MinPeakProminence',0.25); % Initial Peaks
RRmean = mean(diff(Rlocs)); % Mean R-R Indices
[Rwv,Rlocs] = findpeaks(EKG, 'MinPeakProminence',0.25, 'MinPeakDistance',(RRmean/2)); % Revised Peaks
RRint = diff([Rlocs(1); Rlocs]); % R-R Intervals
RR_Table = table(t(Rlocs), Rlocs, Rwv, RRint, RRint*Ts, 60./(RRint*Ts), 'VariableNames',{'R_Time','R_index','R_Amplitude','RR_Interval_Idx','RR_Interval"Time','Instantaneous_Rate'})
figure
plot(t, EKG)
hold on
plot(t(Rlocs), Rwv, '+r')
hold off
grid
xlabel('Time')
ylabel('Amplitude')
legend('EKG','R-Waves', 'Location','best')
xlim([0 15]+5) % 'Zoom' View
I could not get the results I wanted with a bandpass filter, so I ganged a highpass and lowpass in series to get an acceptable result. It’s likely not possible to eliminate all the noise, and this will make other features (such as P aand T waves and others) much more difficult to detect. I do not see any obvious pathology in this trace, so those details are not likely to yield important information in any event.
Experiment to get different results.
.
0 Comments
Luigi FALANGA
on 23 Jul 2022
Hello,
I have the same ECG text file from LabChart, and I need to analyze the R-R intervals in matlab, exaclty as you did in the previouse script. Unfortunetly my RR intervals and HR looks like unreal. I suppose it is a problem about downsample, sample frequency (or maybe both).
Could you please help me adjusting my script? Resolved this fundamental issue, I'm looking to save only the RR intervals within the comment "Start" "End" in the thrid column.
I'll attach my txt... the signal was recorde at 2000 (sampling rate), 0.5 (sample intervals) and downsample at 0.5 intervals.
I hope that you can help me somehow, ufortunatly this is my first project on matlab.
thank you in advance for your attention,
Luigi
0 Comments
See Also
Categories
Find more on Measurements and Feature Extraction in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!