Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Rådata
- input_data = jonathanAktivECG.ECGLLRA;
- frequency_sampled_at = 512;
- plot (input_data)
- axis ('tight')
- grid on
- xlabel('Index of sample')
- ylabel('Voltage')
- legend('ECG data')
- title ('ECG data, unedited')
- time = (1:numel(input_data))/frequency_sampled_at;
- Filtrera data
- lowpass_filtered_ecg = lowpass(input_data,50,frequency_sampled_at);
- %plot (lowpass_filtered_ecg)
- %axis ('tight')
- %grid on
- highpass_filtered_ecg = highpass(input_data,0.4,frequency_sampled_at);
- plot (highpass_filtered_ecg)
- axis ('tight')
- grid on
- xlabel('Index of sample')
- ylabel('Voltage')
- legend('ECG data highpass filtered')
- title ('ECG data, with highpass filter')
- Räkna ut puls från data
- % Koden nedan baseras på https://se.mathworks.com/matlabcentral/fileexchange/68246-visualization-and-analysis-of-an-electrocardiogram-signal?focused=7fbc0610-5e23-435e-a271-ddd80d1065d0&tab=example%
- Alternativ 2 (fungerar)
- hold off
- %Andra sättet att hitta R (förprogrammerad funktion)
- %Visar graf där alla peaks hittas
- [peaks_2,pos_peaks_2] = findpeaks(highpass_filtered_ecg);
- plot(time, highpass_filtered_ecg, 'b', pos_peaks_2/frequency_sampled_at,(peaks_2),'ro')
- xlabel('Time (sec)')
- ylabel('Voltage (mV)')
- axis ('tight')
- legend('ECG data highpass filtered', 'Peaks_2 uncut')
- title ('ECG data highpass filtered, R peaks, version 2, uncut')
- %Visar graf där endast önskade peaks visas, baserat på mätpunktens värde
- %och distans till andra peaks
- [peaks_2,pos_peaks_2] = findpeaks(highpass_filtered_ecg,'MinPeakDistance',50,'MinPeakHeight',1);
- plot(time,highpass_filtered_ecg,'b',pos_peaks_2/frequency_sampled_at,(peaks_2),'ro')
- xlabel('Time (sec)')
- ylabel('Voltage (mV)')
- axis ('tight')
- legend('ECG data highpass filtered', 'Peaks_2, cut')
- title ('ECG data highpass filtered, R peaks, version 2, cut')
- %Results
- %First graph of result (shows ECG)
- subplot(211)
- plot(time,highpass_filtered_ecg,'b',pos_peaks_2/frequency_sampled_at,(peaks_2),'ro')
- grid on
- axis tight
- ylabel ('ECG','fontsize',14)
- xlabel ('Time (seconds)', 'fontsize', 14)
- %Second of result graphs (shows pulse)
- %Jag förstår inte den här, vad händer?
- subplot(212)
- plot()
- %pulsfrekvens f= 1/(pos för peak)*samplingsfrekvens
- %standardavvikelse för hjärtfrekvensen
- %Dela upp för tidsintervall
- grid on
- axis tight
- ylabel ('Momentous Heart Rate','fontsize',14)
- xlabel ('Time (seconds)','fontsize',14)
- sgtitle('Results: finding R-peaks and calculating pulse', 'fontsize', 22)
- %Beräkning av medelpuls
- number_of_R_peaks = length(peaks_2)
- time_of_first_R_peak = time(pos_peaks_2(1,1));
- time_of_last_R_peak = time(pos_peaks_2(end,1));
- time_between_R_peaks = time_of_last_R_peak - time_of_first_R_peak
- average_pulse = 60*(number_of_R_peaks)/(time_between_R_peaks)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement