Esempio n. 1
0
class DAQPanel2(DAQPanel):

    def __init__(self, parent,*args, **kwds):
        DAQPanel.__init__(self, *args, **kwds)
        self.parentFrame = parent

        self.sizersize = self.ecg_vertical_sizer.GetSize()
        self.plotter = Plotter(self,(1080,380))
        self.ecg_vertical_sizer.Add(self.plotter.plotpanel,1, wx.LEFT|wx.RIGHT|wx.BOTTOM|wx.EXPAND, 4)

       # self.Calibration_bitmap = wx.StaticBitmap(self, -1, wx.Bitmap("Icons/CalibrationSignal.png", wx.BITMAP_TYPE_ANY))
        #self.Calibration_bitmap.SetBitmap(wx.Bitmap("Icons/CalibrationSignal.png"))
        #self.ecg_vertical_sizer.Add(self.Calibration_bitmap,1, wx.BOTTOM|wx.SHAPED, 4)
        
        
        self.timer1 = wx.Timer(self)
        self.timer2 = wx.Timer(self)
        self.timer3 = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.serverCheck, self.timer3)
        
        self.timerEDF = wx.Timer(self)
        self.timerECG = wx.Timer(self)
        

        self.timerPLOT = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.plotECG, self.timerPLOT)

        self.plotinterval = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.plotnext, self.plotinterval)
        
        self.Bind(wx.EVT_TIMER, self.on_timer1, self.timer1)
        self.Bind(wx.EVT_TIMER, self.on_timer2, self.timer2)
        self.Bind(wx.EVT_TIMER, self.make_edf, self.timerEDF)
        self.Bind(wx.EVT_TIMER, self.getECGdata, self.timerECG)
        
       
        

        self.pressure_timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.pressure_update, self.pressure_timer)

        self.Biosignals = []
        
        self.spo2data = simsensors.Spo2sim(self)
        self.bpdata = simsensors.BpSim(self)
        self.ECGdata =[]
        for i in range(0,7500):
            self.ECGdata.append(0)
            
        self.ECGcount = 0 #ECG data counter
        self.ECGstart = 0 #ECG start counter
        
        
        self.patient1 = edf.Patient('1','Timothy','Cena','Ebido','Servan',\
                                    'Male','09.27.89','19')
                                    
        self.bp_infolabel.SetLabel('BP ready')
        self.heartrate_infolabel.SetLabel('Pulse Ox Ready')
        self.spo2_infolabel.SetLabel('Pulse Ox ready')
        self.count = 0      #no use as of now

        self.bp_slider.Enable(False)
        self.bp_pressure_indicator.Enable(False)
        self.parentFrame.Layout()
        
    def onStartStop(self, event):

        self.count = 0

        self.referflag = 0
        self.panel = 0
        self.parentFrame.PatientInfo_Label.SetLabel('Patient Name:'+'\n'+ 'Gender: ' + ' ' + '\nAge: ' + ' ' + ' '  + ' ' + 'Validity:' +\
                                               '\nAddress: ' + ' ' + '\nPhone: ' + ' ')

        if self.StartStop_Label.GetLabel() == "Start":
            
            self.Call_Label.SetLabel("Call")
            self.bpvalue_label.Enable(True)
            self.bpmvalue_label.Enable(True)
            self.spo2value_label.Enable(True)
            self.Call_Button.Enable(True)
            self.Call_Label.Enable(True)
            self.bpNow_Button.Enable(True)
            self.Upload_Button.Enable(True)
            self.Upload_Label.Enable(True)
            self.lead12_button.Enable(True)
            self.StartStop_Button.SetBitmapLabel(wx.Bitmap("Icons/StopButton.png",wx.BITMAP_TYPE_ANY))
            self.StartStop_Button.SetToolTipString("Stop RxBox session")
            self.StartStop_Label.SetLabel("Stop")


       
            self.timerECG.Start(30000)
           
            #self.displayECG()
            self.spo2data.get()         
            
            self.onBPCyclic()
            self.get_bp()
            
            self.timer1.Start(1000)
            self.timerEDF.Start(15000)
            
            self.timer3.Start(1000)
            if self.count == 3:
                self.parentFrame.RxFrame_StatusBar.SetStatusText("Connected")  
            
            
        else:
            self.bpNow_Button.Enable(True)
            self.StartStop_Button.SetBitmapLabel(wx.Bitmap("Icons/PlayButton.png",wx.BITMAP_TYPE_ANY))
            self.StartStop_Label.SetLabel("Start")
            self.bpNow_Button.Enable(True)
            self.Call_Button.Enable(False)
            self.Upload_Button.Enable(False)
            self.lead12_button.Enable(False)
            self.myECG.stop()
            self.refreshECMbitmap()

            self.timer1.Stop()
            self.timer2.Stop()
            self.timer3.Stop()
            self.timerEDF.Stop()
            #self.timerPLOT.Stop()
            self.timerECG.Stop()
            #self.timerplotsecond.Stop()
            #self.timerplotthird.Stop()
            self.plotinterval.Stop()
            self.heartrate_infolabel.SetLabel('Pulse Ox Ready')
            self.spo2_infolabel.SetLabel('Pulse Ox Ready')

            CallAfter(self.parentFrame.DestroyReferPanel)

    def refreshECMbitmap(self):
        
        self.R_bitmap.SetBitmap(wx.Bitmap("Icons/R_initial.png"))
        self.L_bitmap.SetBitmap(wx.Bitmap("Icons/L_initial.png"))
        self.N_bitmap.SetBitmap(wx.Bitmap("Icons/N_initial.png"))
        self.F_bitmap.SetBitmap(wx.Bitmap("Icons/F_initial.png"))
        self.C1_bitmap.SetBitmap(wx.Bitmap("Icons/C1_initial.png"))
        self.C2_bitmap.SetBitmap(wx.Bitmap("Icons/C2_initial.png"))
        self.C3_bitmap.SetBitmap(wx.Bitmap("Icons/C3_initial.png"))
        self.C4_bitmap.SetBitmap(wx.Bitmap("Icons/C4_initial.png"))
        self.C5_bitmap.SetBitmap(wx.Bitmap("Icons/C5_initial.png"))
        self.C6_bitmap.SetBitmap(wx.Bitmap("Icons/C6_initial.png"))

    def serverCheck(self,evt):
        
       # self.timer3.Start(1000)
        self.count = self.count + 1
        print self.count
        if self.count == 1:
            self.parentFrame.RxFrame_StatusBar.SetStatusText("Connecting to server.")
            #self.count = self.count + 1
            #print self.count
        elif self.count == 2:
            #print self.count
            self.parentFrame.RxFrame_StatusBar.SetStatusText("Connecting to server..")
            #self.count = self.count + 1
        elif self.count == 3:
            self.parentFrame.RxFrame_StatusBar.SetStatusText("Connecting to server...")
            #return True

        elif self.count == 4:
                self.parentFrame.RxFrame_StatusBar.SetStatusText("Connected") 
        else:
            self.timer3.Stop()
            self.count = 0
            #return True

    def displayECG(self):
        """ Calls the ecg_lead() method of the ecglogfile module to extract
            the 12 leads then passes it to the ecgplotter module for plotting
        """

        self.getlead = ECG().ecg_lead()    
        self.plotter.plot(self.getlead[1])

    def plotECG(self,evt):
        self.startcount = 0
        self.endcount = 1500
        self.data=[]

        for i in range(0,13):
        #for i in range(0,len(self.ECGdata)/1500):
            self.data = self.ECGdata[self.startcount:self.endcount]
            self.startcount=self.startcount+500
            self.endcount = self.endcount+500
            print len(self.data)
           # self.plotinterval.Start(50)
            self.plotter.plot(self.data)
            #time.sleep(0.5)
            
    def plotnext(self,evt):
        print 'ECG data counter =',self.ECGcount
       
        self.ECGcount = self.ECGcount+1
        if self.ECGcount == 1:
            self.plotter.plot(self.ECGdata[0:1500])
            print '0-3sec'
        elif self.ECGcount == 2:
            self.plotter.plot(self.ECGdata[500:2000])
            print '1-4sec'
        elif self.ECGcount == 3:
            self.plotter.plot(self.ECGdata[1000:2500])
            print '2-5sec'
        elif self.ECGcount == 4:
            self.plotter.plot(self.ECGdata[1500:3000])
            print '3-6sec'
        elif self.ECGcount == 5:
            self.plotter.plot(self.ECGdata[2000:3500])
            print '4-7sec'
        elif self.ECGcount == 6:
            self.plotter.plot(self.ECGdata[2500:4000])
            print '5-8sec'
        elif self.ECGcount == 7:
            self.plotter.plot(self.ECGdata[3000:4500])
            print '6-9sec'
        elif self.ECGcount == 8:
            self.plotter.plot(self.ECGdata[3500:5000])
            print '7-10sec'
        elif self.ECGcount == 9:
            self.plotter.plot(self.ECGdata[4000:5500])
            print '8-11sec'
        elif self.ECGcount == 10:
            self.plotter.plot(self.ECGdata[4500:6000])
            print '9-12sec'
        elif self.ECGcount == 11:
            self.plotter.plot(self.ECGdata[5000:6500])
            print '10-13sec'
        elif self.ECGcount == 12:
            self.plotter.plot(self.ECGdata[5500:7000])
            print '11-14sec'
        elif self.ECGcount == 13:
            self.plotter.plot(self.ECGdata[6000:7500])
            print '12-15sec'
        else:
            self.ECGcount = 0
            self.plotinterval.Stop()
        

    def getECGdata(self,evt):
        
        
        self.myECG  = rxsensor.ECG(self)
        self.myECG.get()
        
        print len(self.myECG.ecg_leadII)
        self.ECGdata = self.myECG.ecg_leadII
        if len(self.ECGdata)<7500:
            for i in range(0,7500-len(self.ECGdata)):
                self.ECGdata.append(0)

        elif len(self.ECGdata)>7500:
            for i in range(0,len(self.ECGdata)-7500):
                self.ECGdata.pop()
        print len(self.ECGdata)
       
        self.plotinterval.Start(500)
        self.myECG.stop()

    
    

    def on_timer1(self,evt):
        
        self.spo2data.get()    
        print 'Spo2 data acquired'

    def on_timer2(self,evt):
        
        print 'BP ready'
        self.bp_infolabel.SetLabel('BP ready')
        self.onBPCyclic()
        self.get_bp()

    def get_bp(self):
        self.bp_slider.Enable(True)
        self.bp_pressure_indicator.Enable(True)
        self.bpNow_Button.Enable(False)
        self.setBPmins_combobox.Enable(False)
        self.file = open('pressure.txt','r')
        self.pressure_timer.Start(20)

    def pressure_update(self, evt):
        press = int(self.file.readline())
        if press != 999:
            self.bp_slider.SetValue(20-(press/10))
            self.bp_pressure_indicator.SetValue(press)
        else:
            self.file.close()
            self.pressure_timer.Stop()
            self.bp_slider.Enable(False)
            self.bp_pressure_indicator.Enable(False)
            self.bpNow_Button.Enable(True)
            self.setBPmins_combobox.Enable(True)
            self.bpdata.get()
        
    def make_edf(self,evt):

        self.Endtime = datetime.datetime.today()
        self.Starttime = self.Endtime + datetime.timedelta(seconds = -15)
        self.strDate = self.Starttime.strftime("%d.%m.%y")
        self.strStarttime = self.Starttime.strftime("%H.%M.%S")
        self.strY2KDate = self.Starttime.strftime("%d-%b-%Y")
        
        Biosignal_SPO2 = BioSignal('SpO2 finger','IR-Red sensor',\
                                '%',0,100,0,100,'None',15,self.spo2data.spo2_list)
        Biosignal_BPM = BioSignal('SpO2 finger','IR-Red sensor',\
                                'bpm',0,300,0,300,'None',15,self.spo2data.bpm_list)
        Biosignal_pSys = BioSignal('bpsystole', 'NIBP2010','mmHg',\
                                        0,300,0,300,'None',1,self.bpdata.systole_sim_values)
        Biosignal_pDias = BioSignal('bpdiastole','NIBP2010','mmHg',\
                                        0,300,0,300,'None',1,self.bpdata.diastole_sim_values)
        
        self.Biosignals.append(Biosignal_SPO2)
        self.Biosignals.append(Biosignal_BPM)
        self.Biosignals.append(Biosignal_pSys)
        self.Biosignals.append(Biosignal_pDias)     
        
        myedf = edf.EDF(self.patient1,self.Biosignals,self.strDate,self.strStarttime,self.strY2KDate + \
                        ': LifeLink 15 second data of CorScience modules', \
                        4, 15)
        myedf.get(self.patient1)
        print 'EDF creation finished'

        self.Biosignals = []


    def onCall(self, event): # wxGlade: DAQPanel_Parent.<event_handler>

        if (self.Call_Label.GetLabel() == "Call") and (self.referflag == 0):   
            CreateDialog = CreateRecordDialog2(self.parentFrame,self)
            CreateDialog.ShowModal()
            CallAfter(self.parentFrame.CreateReferPanel)
            self.Call_Label.SetLabel(">>  ")       
            self.Call_Button.Enable(True)
            self.Call_Label.Enable(True)
            self.referflag = 1
            self.panel = 1
            
        elif (self.Call_Label.GetLabel() == "<<  ") and (self.referflag == 1):   
            #CallAfter(self.parentFrame.CreateReferPanel)
            self.Call_Label.SetLabel(">>  ")       
            self.Call_Button.Enable(True)
            self.Call_Label.Enable(True)
            self.panel = 1
            self.parentFrame.ReferPanel.Show()
            self.parentFrame.Layout()
            
        else:
            self.Call_Button.Enable(False)
            self.Call_Label.Enable(False)
            #CallAfter(self.parentFrame.DestroyReferPanel)
            self.Call_Label.SetLabel("<<  ")       
            self.Call_Button.Enable(True)
            self.Call_Label.Enable(True)
            self.panel = 0
            self.parentFrame.ReferPanel.Hide()
            self.parentFrame.Layout()

    def onBPNow(self, event): # wxGlade: MyPanel1.<event_handler>
        
        reload_bp_str = self.setBPmins_combobox.GetValue()
        reload_bp = int(reload_bp_str[0:2])*1000
        self.bpNow_Button.Enable(False)
        self.get_bp()
        
    def onBPCyclic(self):

        reload_bp_str = self.setBPmins_combobox.GetValue()
        reload_bp = int(reload_bp_str[0:2])*60000
        self.timer2.Start(reload_bp)
        
    def updateSPO2Display(self, data):
        self.spo2value_label.SetLabel(data)
        

    def updateBPMDisplay(self, data):
        self.bpmvalue_label.SetLabel(data)
        
        
    def updateBPDisplay(self, data):
        self.bpvalue_label.SetLabel(data)
        
        
    def startSaveThread (self):
##        """ calls makeEDF.SaveThread.run() """
        event.Skip()

    def on12Lead(self, event): # wxGlade: DAQPanel.<event_handler>
        """event handler of the 12 lead button. When 12 lead button is pressed
        calls the 12 lead dialog window for plotting
        """
        #self.lead12_button.Enable(False)
        CreateDialog2 = Lead12Dialog2(self,self)
        CreateDialog2.ShowModal()
Esempio n. 2
0
    def __init__(self, parent,*args, **kwds):
        DAQPanel.__init__(self, *args, **kwds)
        self.parentFrame = parent

        self.sizersize = self.ecg_vertical_sizer.GetSize()
        self.plotter = Plotter(self,(1080,380))
        self.ecg_vertical_sizer.Add(self.plotter.plotpanel,1, wx.LEFT|wx.RIGHT|wx.BOTTOM|wx.EXPAND, 4)

       # self.Calibration_bitmap = wx.StaticBitmap(self, -1, wx.Bitmap("Icons/CalibrationSignal.png", wx.BITMAP_TYPE_ANY))
        #self.Calibration_bitmap.SetBitmap(wx.Bitmap("Icons/CalibrationSignal.png"))
        #self.ecg_vertical_sizer.Add(self.Calibration_bitmap,1, wx.BOTTOM|wx.SHAPED, 4)
        
        
        self.timer1 = wx.Timer(self)
        self.timer2 = wx.Timer(self)
        self.timer3 = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.serverCheck, self.timer3)
        
        self.timerEDF = wx.Timer(self)
        self.timerECG = wx.Timer(self)
        

        self.timerPLOT = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.plotECG, self.timerPLOT)

        self.plotinterval = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.plotnext, self.plotinterval)
        
        self.Bind(wx.EVT_TIMER, self.on_timer1, self.timer1)
        self.Bind(wx.EVT_TIMER, self.on_timer2, self.timer2)
        self.Bind(wx.EVT_TIMER, self.make_edf, self.timerEDF)
        self.Bind(wx.EVT_TIMER, self.getECGdata, self.timerECG)
        
       
        

        self.pressure_timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.pressure_update, self.pressure_timer)

        self.Biosignals = []
        
        self.spo2data = simsensors.Spo2sim(self)
        self.bpdata = simsensors.BpSim(self)
        self.ECGdata =[]
        for i in range(0,7500):
            self.ECGdata.append(0)
            
        self.ECGcount = 0 #ECG data counter
        self.ECGstart = 0 #ECG start counter
        
        
        self.patient1 = edf.Patient('1','Timothy','Cena','Ebido','Servan',\
                                    'Male','09.27.89','19')
                                    
        self.bp_infolabel.SetLabel('BP ready')
        self.heartrate_infolabel.SetLabel('Pulse Ox Ready')
        self.spo2_infolabel.SetLabel('Pulse Ox ready')
        self.count = 0      #no use as of now

        self.bp_slider.Enable(False)
        self.bp_pressure_indicator.Enable(False)
        self.parentFrame.Layout()
Esempio n. 3
0
    def __init__(self, parent, *args, **kwds):
        """ initializes the placement of the plotter to the 12 lead dialog window

        Parameters
        ----------
        parent  :  the main window which calls the creation of the dialog window

        """
        
        Lead12Dialog.__init__(self, *args, **kwds)
        self.parent=parent
        sizersize = self.leadI_sizer.GetSize()
        print sizersize
        bigsizer = self.leadII_sizer.GetSize()
        print bigsizer
        self.plotter_I=Plotter(self,(308,162))
        self.plotter_II=Plotter(self,(308,162))
        self.plotter_III=Plotter(self,(308,162))
        self.plotter_aVR=Plotter(self,(308,162))
        self.plotter_aVL=Plotter(self,(308,162))
        self.plotter_aVF=Plotter(self,(308,162))
        self.plotter_V1=Plotter(self,(308,162))
        self.plotter_V2=Plotter(self,(308,162))
        self.plotter_V3=Plotter(self,(308,162))
        self.plotter_V4=Plotter(self,(308,162))
        self.plotter_V5=Plotter(self,(308,162))
        self.plotter_V6=Plotter(self,(308,162))
        
        self.leadI_sizer.Add(self.plotter_I.plotpanel,1, wx.LEFT|wx.RIGHT|wx.BOTTOM|wx.EXPAND, 4)
        self.small_leadII_sizer.Add(self.plotter_II.plotpanel,1, wx.LEFT|wx.RIGHT|wx.BOTTOM|wx.EXPAND, 4)
        self.leadIII_sizer.Add(self.plotter_III.plotpanel,1, wx.LEFT|wx.RIGHT|wx.BOTTOM|wx.EXPAND, 4)
        self.aVR_sizer.Add(self.plotter_aVR.plotpanel,1, wx.LEFT|wx.RIGHT|wx.BOTTOM|wx.EXPAND, 4)
        self.aVL_sizer.Add(self.plotter_aVL.plotpanel,1, wx.LEFT|wx.RIGHT|wx.BOTTOM|wx.EXPAND, 4)
        self.aVF_sizer.Add(self.plotter_aVF.plotpanel,1, wx.LEFT|wx.RIGHT|wx.BOTTOM|wx.EXPAND, 4)
        self.V1_sizer.Add(self.plotter_V1.plotpanel,1, wx.LEFT|wx.RIGHT|wx.BOTTOM|wx.EXPAND, 4)
        self.V2_sizer.Add(self.plotter_V2.plotpanel,1, wx.LEFT|wx.RIGHT|wx.BOTTOM|wx.EXPAND, 4)
        self.V3_sizer.Add(self.plotter_V3.plotpanel,1, wx.LEFT|wx.RIGHT|wx.BOTTOM|wx.EXPAND, 4)
        self.V4_sizer.Add(self.plotter_V4.plotpanel,1, wx.LEFT|wx.RIGHT|wx.BOTTOM|wx.EXPAND, 4)
        self.V5_sizer.Add(self.plotter_V5.plotpanel,1, wx.LEFT|wx.RIGHT|wx.BOTTOM|wx.EXPAND, 4)
        self.V6_sizer.Add(self.plotter_V6.plotpanel,1, wx.LEFT|wx.RIGHT|wx.BOTTOM|wx.EXPAND, 4)

##        self.plotter_I.plot(self.parent.getlead[0])
##        self.plotter_II.plot(self.parent.getlead[1])
##        self.plotter_III.plot(self.parent.getlead[2])
##        self.plotter_aVR.plot(self.parent.getlead[3])
##        self.plotter_aVL.plot(self.parent.getlead[4])
##        self.plotter_aVF.plot(self.parent.getlead[5])
##        self.plotter_V1.plot(self.parent.getlead[6])
##        self.plotter_V2.plot(self.parent.getlead[7])
##        self.plotter_V3.plot(self.parent.getlead[8])
##        self.plotter_V4.plot(self.parent.getlead[9])
##        self.plotter_V5.plot(self.parent.getlead[10])
##        self.plotter_V6.plot(self.parent.getlead[11])

        self.plotter_I.plot(self.parent.myECG.ecg_leadI[500:2000])
        self.plotter_II.plot(self.parent.myECG.ecg_leadII[500:2000])
        self.plotter_III.plot(self.parent.myECG.ecg_leadIII[500:2000])
        self.plotter_aVR.plot(self.parent.myECG.ecg_leadaVR[500:2000])
        self.plotter_aVL.plot(self.parent.myECG.ecg_leadaVL[500:2000])
        self.plotter_aVF.plot(self.parent.myECG.ecg_leadaVF[500:2000])
        self.plotter_V1.plot(self.parent.myECG.ecg_leadV1[500:2000])
        self.plotter_V2.plot(self.parent.myECG.ecg_leadV2[500:2000])
        self.plotter_V3.plot(self.parent.myECG.ecg_leadV3[500:2000])
        self.plotter_V4.plot(self.parent.myECG.ecg_leadV4[500:2000])
        self.plotter_V5.plot(self.parent.myECG.ecg_leadV5[500:2000])
        self.plotter_V6.plot(self.parent.myECG.ecg_leadV6[500:2000])

        self.plotter_bigII=extendPlotter(self,(1500,162))        
        #self.plotter_bigII=extendedPlotter(self,bigsizer,self.parent.myECG.ecg_leadII[500:6500])
        self.leadII_sizer.Add(self.plotter_bigII.plotpanel,1, wx.LEFT|wx.RIGHT|wx.BOTTOM|wx.EXPAND, 4)
        self.plotter_bigII.extendplot(self.parent.myECG.ecg_leadII[500:6500])