def read(self, record=None): if record == None: if self.record == None: sys.exit(1) else: record = self.record else: self.record = record sig0 = [] sigt = [] siarray = wfdb.WFDB_SiginfoArray(2) if (wfdb.isigopen(record, siarray.cast(), 2) < 1): sys.exit(1) v = wfdb.WFDB_SampleArray(2) #Getting X Axes Interval #Appending data to array X_INTERVAL = 20 pause = 0 for i in range(siarray.cast().nsamp): if (wfdb.getvec(v.cast()) < 0): break sig0.append(v.__getitem__(0)) sigt.append(pause) pause = pause + X_INTERVAL pass #High Pass Filtering highpass_filter = HighpassFilter() high_pass = highpass_filter.process(sig0, siarray.cast().nsamp) #Low pass Filtering lowpass_filter = LowpassFilter() low_pass = lowpass_filter.process(high_pass, len(high_pass)) qrs = QRSDetector() qrs_data = qrs.process(low_pass, len(low_pass)) feature_extractor = FeatureExtractor() features = feature_extractor.get_RR_interval(sig0, qrs_data) #sig0 = qrs_dat wfdb.wfdbquit() return sigt, sig0, features
def setupWfdb(rec_name, annotator ): nsig = openWfdbSignal(rec_name); #Allocate memory for sig info array #we can use siarray to access WFDB_Siginfo structure siarray = wfdb.WFDB_SiginfoArray(nsig); #Allocate memory for data sdata = wfdb.WFDB_SampleArray(nsig); #Open WFDB record wfdb.isigopen(rec_name, siarray.cast(), nsig); #read annotations from file #WFDB_Anninfor() contains name and attributes of annotator .atr etc a = wfdb.WFDB_Anninfo(); #WFDB_Annotation describes the attributes of signals #declare object in c : WFDB_Annotation annot; see below for declaring object in python annot = wfdb.WFDB_Annotation(); #read name and status of annotation file #a.name="atr"; #a.name="ecg"; #a.name="output_annotator" a.name=annotator; a.stat = wfdb.WFDB_READ; freq=wfdb.sampfreq(rec_name); nsamp=siarray[0].nsamp; print ("sampling frequency is: " + str(freq)) init_time=wfdb.timstr(0); #print("strtim for starting value is: " + str(wfdb.strtim(init_time))); ##comment june 16 ###### print signal specification ##### record_info=wfdb.getinfo(rec_name) #print("getinfor is " + str(record_info)); # print("total num of samples: " + str(nsamp)); # print "Starting time of record is: "+ str(init_time); # print("sampling frequency is:"+ str(freq)); ########## READ ANNOTATION ################## if wfdb.annopen(rec_name, a, 1) < 0: print("cannot open aanopen"); exit(); return (nsamp, freq, annot, init_time,sdata);
#Find the number of signals in record nsig = wfdb.isigopen(rec_name, None, 0) if nsig < 0: print "error opening signal record" exit() print "Number of signals: " + str(nsig) + " in record: " + rec_name #Allocate memory for sig info array #we can use siarray to access WFDB_Siginfo structure siarray = wfdb.WFDB_SiginfoArray(nsig) #Allocate memory for data sdata = wfdb.WFDB_SampleArray(nsig) #Open WFDB record wfdb.isigopen(rec_name, siarray.cast(), nsig) #Move data from record to sdata sig0 = [] sig1 = [] #physig0 is array with physical units physig0 = [] physig1 = [] #read annotations from file #WFDB_Anninfor() contains name and attributes of annotator .atr etc a = wfdb.WFDB_Anninfo()