Is it possible to save ECG waveform data as an text file with RR-intervals?

3 views (last 30 days)
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!

Answers (2)

Star Strider
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)
EKGsig = 121300×2
0 0.0934 0.0010 0.0905 0.0020 0.1008 0.0030 0.1303 0.0040 0.1536 0.0050 0.1644 0.0060 0.1533 0.0070 0.1627 0.0080 0.1822 0.0090 0.1919
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'})
RR_Table = 165×6 table
R_Time R_index R_Amplitude RR_Interval_Idx RR_Interval"Time Instantaneous_Rate ______ _______ ___________ _______________ ________________ __________________ 0.059 60 0.24646 0 0 Inf 0.734 735 0.20326 675 0.675 88.889 1.414 1415 0.20177 680 0.68 88.235 2.096 2097 0.19193 682 0.682 87.977 2.782 2783 0.19952 686 0.686 87.464 3.45 3451 0.19831 668 0.668 89.82 4.099 4100 0.2089 649 0.649 92.45 4.737 4738 0.23072 638 0.638 94.044 5.368 5369 0.27407 631 0.631 95.087 6.004 6005 0.34363 636 0.636 94.34 6.655 6656 0.32617 651 0.651 92.166 7.311 7312 0.32673 656 0.656 91.463 7.98 7981 0.30211 669 0.669 89.686 8.67 8671 0.26687 690 0.69 86.957 9.365 9366 0.19034 695 0.695 86.331 10.041 10042 0.20801 676 0.676 88.757
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.
.

Luigi FALANGA
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

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!