1 %This file is part of TEAP.
3 %TEAP is free software: you can redistribute it and/or modify
4 %it under the terms of the GNU General Public License as published by
5 %the Free Software Foundation, either version 3 of the License, or
6 %(at your option) any later version.
8 %TEAP is distributed in the hope that it will be useful,
9 %but WITHOUT ANY WARRANTY; without even the implied warranty of
10 %MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 %GNU General Public License
for more details.
13 %You should have received a copy of the GNU General Public License
14 %along with TEAP. If not, see <http://www.gnu.org/licenses/>.
17 %> @brief Computes the IBI
if it is not yet available
18 %> @param ECGSignal: the ECG signal
19 %> @retval ECGSignal: the ECG signal containing the computed IBI signal
21 %> @author Copyright Guillaume Chanel 2015
24 %Compute the signal
if it has not been already computed
27 %Get information on the ECG signal
33 ECG = resample(rawSignal, newfs, samprate); %WARN what happens
if samprate/newfs is not a integer ?
34 if size(ECG,1)<size(ECG,2)
37 [hrv, R_t, R_amp, R_index, S_t, S_amp] =
rpeakdetect(ECG, newfs); %FIXME: there seem to be a problem with filter side effects (begin and end)
38 [~, IBI, ~, listePeak] =
correctBPM(R_index, newfs);
40 %If the number of detected peaks is lower than 2 than IBI cannot be
42 if(length(listePeak) < 2)
43 warning(['A least 2 peaks are needed to compute IBI but ' num2str(length(listePeak)) ' were found: result will be NaN'])
46 %Attribute the computed signal to IBI to check if range is correct
47 % This is done now because this can cause problems in the resampling
51 %Resample the signal with the one requested for IBI
53 IBI =
interpIBI(listePeak/newfs,IBI_samprate,listePeak(end)/newfs)';
55 %Attribute the computed signal to IBI