Skip to content

Commit

Permalink
Included HEP.ibi
Browse files Browse the repository at this point in the history
Included variable HEP.ibi to easily access the interbeat intervals obtained by any peak detection method.
  • Loading branch information
perakakis committed Jun 1, 2021
1 parent d939894 commit 37d5e31
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 4 deletions.
3 changes: 1 addition & 2 deletions Functions/heplab_calculate_IBIs.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@

% calculate IBIs
RR=RRtimes(1:length(RRtimes)-1);
RR1=RRtimes(2:length(RRtimes));
RRinterval=RR1-RR;
RRinterval=diff(RRtimes);

% convert to sec and remove first interval
RRtimes=RRtimes(2:length(RRtimes))/1000;
Expand Down
43 changes: 43 additions & 0 deletions Functions/heplab_calculate_IBIs.m~
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
% heplab_calculate_IBIs - Calculates IBIs, called by heplab_ecgplot.m
%
% Copyright (C) 2019 Pandelis Perakakis, Granada University, [email protected]
%
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program. If not, see <https://www.gnu.org/licenses/>.


function [RRinterval, RRtimes]=heplab_calculate_IBIs(qrs,signal_sec,srate)

if length(qrs)>1,

time=0:1/srate:signal_sec-1/srate; % time axis

% convert to ms
RRtimes=round(1000*time(qrs));

% calculate IBIs
RR=RRtimes(1:length(RRtimes)-1);
RR1=RRtimes(2:length(RRtimes));
RRinterval=diff(RRtime);

% convert to sec and remove first interval
RRtimes=RRtimes(2:length(RRtimes))/1000;

% round IBIs
RRinterval=round(RRinterval);

else
RRinterval=-1;
RRtimes=-1;
end

2 changes: 1 addition & 1 deletion Functions/heplab_ecgplot.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
plot(t,signal,'b-',t,qrs,'ro');
end

% fing events within window
% find events within window
[RRinterval, RRtimes]=heplab_calculate_IBIs(r_ind,length(ecg)*1/srate,srate);
if RRinterval(1)~=-1,

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ If you have previously saved a file containing a HEP structure, you can use this

### Tools
#### Detect R waves
- **ecglab fast** and **ecglab slow** are two very similar peak detection algorithms included in the *ECGLAB*, developed by the group of João Luiz Azevedo de Carvalho at the University of Brasilia, DF, Brasil. Details about the algorithm are given in [Carvalho et al., 2002](Documentation/Articles/icsp2002_ecglab.pdf).
- **ecglab fast** and **ecglab slow** are two very similar peak detection algorithms included in *ECGLAB*, developed by the group of João Luiz Azevedo de Carvalho at the University of Brasilia, DF, Brasil. Details about the algorithm are given in [Carvalho et al., 2002](Documentation/Articles/icsp2002_ecglab.pdf).
- **Pan-Tompkin** implements the [Pan & Tompkins, 1985](Documentation/Articles/PanTompkins.pdf) algorith using the function `BioSigKit.PanTompkins()` that is distributed with the [BioSigKit toolbox](http://joss.theoj.org/papers/10.21105/joss.00671), developed by
[Hooman Sedghamiz](https://github.com/hooman650).

Expand Down
4 changes: 4 additions & 0 deletions heplab.m
Original file line number Diff line number Diff line change
Expand Up @@ -349,13 +349,15 @@
hepgui.subm_fastdetect=uimenu(hepgui.subm_r_detect,'Label','ecglab fast',...
'CallBack', [...
'HEP.qrs = heplab_fastdetect(HEP.ecg,HEP.srate);'...
'HEP.ibi = diff(HEP.qrs)/HEP.srate;'...
'HEP.ecg_handle=heplab_ecgplot(HEP.ecg,HEP.srate,HEP.qrs,HEP.sec_ini,',...
'HEP.ecg_handle,HEP.winsec);']);

% slowdetect
hepgui.subm_slowdetect=uimenu(hepgui.subm_r_detect,'Label','ecglab slow',...
'CallBack', [...
'HEP.qrs = heplab_slowdetect(HEP.ecg,HEP.srate);'...
'HEP.ibi = diff(HEP.qrs)/HEP.srate;'...
'HEP.ecg_handle=heplab_ecgplot(HEP.ecg,HEP.srate,HEP.qrs,HEP.sec_ini,',...
'HEP.ecg_handle,HEP.winsec);']);

Expand All @@ -364,6 +366,7 @@
'CallBack', [...
'[amp,HEP.qrs] = heplab_pan_tompkin(HEP.ecg,HEP.srate);'...
'if size(HEP.qrs,1)<size(HEP.qrs,2); HEP.qrs = HEP.qrs''; end;'...
'HEP.ibi = diff(HEP.qrs)/HEP.srate;'...
'HEP.ecg_handle=heplab_ecgplot(HEP.ecg,HEP.srate,HEP.qrs,HEP.sec_ini,',...
'HEP.ecg_handle,HEP.winsec);']);

Expand All @@ -372,6 +375,7 @@
'CallBack', [...
'[R,Q,S,T,P_w] = heplab_T_detect_MTEO(HEP.ecg,HEP.srate,0);'...
'HEP.qrs = T(:,1);'...
'HEP.ibi = diff(HEP.qrs)/HEP.srate;'...
'HEP.ecg_handle=heplab_ecgplot(HEP.ecg,HEP.srate,HEP.qrs,HEP.sec_ini,',...
'HEP.ecg_handle,HEP.winsec);'...
'clear R Q S T P_w']);
Expand Down

0 comments on commit 37d5e31

Please sign in to comment.