function [F1,Se,PPV,Nb] = run_sqi(refqrs,testqrs,thres,margin,windowlen,fs) % sqi = run_sqi(refqrs,testqrs,thres,margin,windowlen,fs) % compare two sets of annotation with one as the reference (refqrs) and one % as the test (testqrs) % % inputs % refqrs: reference qrs annotation (in sec) % testqrs: test qrs annotations (in sec) % thres: threshold (in sec,default 0.05s) % margin: margin time not include in comparison (in sec,default 2s) % windowlen: length of the comparison window (in sec,default 60s) % fs: sampling frequency % % output % sqi: match proportion according to some criteria you can change % depending on what you are looking for (can be Se, PPV or F1 measure). % See at the end of the function. % % When using this work, then please cite [1] and [2]: % [1] Behar Joachim, Oster Julien, Qiao Li, Clifford Gari D. Signal Quality % During Arrhythmia and its Application to False Alarm Reduction. % IEEE Transactions on Biomedical Engineering. 60(6). 1660-6. 2013. % % [2] Li, Qiao, Roger G. Mark, and Gari D. Clifford. "Robust heart rate estimation % from multiple asynchronous noisy sources using signal quality indices and % a Kalman filter." Physiological measurement 29.1 (2008): 15. % % PCinCC2014, version 1.0, June 2014 % Released under the GNU General Public License % % Copyright (C) 2014 Joachim Behar % Oxford university, Intelligent Patient Monitoring Group - Oxford 2014 % joachim.behar@gmail.com % % Updates: % 07-02-2014 % JB- testes with Octave -> running OK % % 02-10-2014 % Bug fix: Dealing with annotations close to the border of the search % window. Lines 70 - 100 % David Springer % % 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 2 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. % == managing inputs if nargin<2; error('bsqi: wrong number of input arguments \n'); end; if nargin<3; thres=0.05; end; if nargin<4; margin=2; end; if nargin<5; windowlen=60; end; if nargin<6; fs=1000; end; if size(refqrs,1)>size(refqrs,2); refqrs=refqrs';end if size(testqrs,1)>size(testqrs,2); testqrs=testqrs';end start = margin*fs; stop = (windowlen-margin)*fs; refqrs = refqrs*fs; % convert into samples from time testqrs = testqrs*fs; % convert into samples from time try refqrs = refqrs(refqrs>start & refqrsstart & testqrs(windowlen-thres)*fs); % reference QRS at the border if ~isempty(indbord) [IndMatchBord,DistQRSbord] = dsearchn(testqrs,refqrs(indbord)); Indeces_below_threshold = DistQRSbord(windowlen-thres)*fs); % reference QRS at the border if ~isempty(indbord) [IndMatchBord,DistQRSbord] = dsearchn(refqrs,testqrs(indbord)); Indeces_below_threshold = DistQRSbord