Ejemplo n.º 1
0
    def parse_logic(self,widget):
        self.result_all_ind = array([])
        '''8192>4216,300ms'''
        liststore,iter = self.View.get_selection().get_selected_rows()
        logic_list = []
        for i in iter:
            logic_list.extend([liststore[i[0]][3]])
        #logic = liststore[iter[0][0]][3]
        print 'logic found',logic_list


        for logic in logic_list: #logic var is an event

            #parse logic string into val,val,time
            trig_vals = logic.split(',')[0].split('>')
            try: timediff = int(logic.split(',')[1].rstrip('ms'))
            except: timediff = 0

            try:
                trig_int = []
                for i in trig_vals: #strings to integers
                    trig_int.append(int(i))

                self.ind_dict = event_logic.get_ind(trig_int,self.data)
                print('indices dict',self.ind_dict)
                if len(self.ind_dict.keys()) == 1: #no real logic, just get indices to this value.
                    self.result_ind = self.ind_dict[0]
                    print('result',self.result_ind.values()[0])
                else: #boolean logic to solve.
                    self.result_ind = event_logic.ind_logic(self.ind_dict, timediff, self.wintime)
                    print(self.result_ind,'timediff',timediff)

            except ValueError: #prob a custom trigger channel
                print 'getting indices for custom trig:',logic
                print self.event_dict.keys()
                print self.event_dict.values()
                print 'EN',liststore[i[0]][0]

                self.result_ind = self.event_dict[liststore[i[0]][0]]

            try:
                self.result_all_ind = append(self.result_all_ind,self.result_ind)
            except AttributeError:
                self.result_all_ind = self.result_ind

        print self.result_all_ind

        self.updatestatusbar('Logic Result: '+str(len(self.result_all_ind[0].values()[0]))+' events passed conditions')
        self.check_status(None)
Ejemplo n.º 2
0
    def get_trigger_events_from_data(self,widget):#,xtrachannellabels=None):
        if self.builder.get_object("togglebutton1").get_active():
            self.builder.get_object("togglebutton1").set_active(False)
        trigger_channels = ['TRIGGER','RESPONSE']; #default trig ch
        #if xtrachannellabels != None:
            #trigger_channels.append(xtrachannellabels)#adding a custom channel


        #p.data.setchannellabels(['Pinky','TRIGGER', 'RESPONSE'])

        print 'filename', self.builder.get_object('filechooserbutton1').get_uri()
        print(widget.get_filename())
        try:
            self.p = pdf.read(widget.get_filename()) #4D file read
            #self.p.data.setchannels('trig') #datatype equals 'trigger'
            self.p.data.setchannellabels(trigger_channels)

            self.p.data.getdata(0, self.p.data.pnts_in_file) #read the whole file
            self.data = self.p.data.data_block #actual data array
            self.srate = self.p.data.srate
            self.wintime = self.p.data.wintime #timecourse
            u,n,nz = trigger.vals(self.data) #u is the event value
            self.event_dict = event_logic.get_ind(u,self.data) #dictionary with indices to events
            print self.event_dict
            self.event_list = array(u,int32)
            print self.event_list
            self.channellist = array([]) #ch list for custom trigger channel
            for i in self.p.hdr.channel_ref_data:
                try: self.channellist = append(self.channellist, i.chan_label)
                except AttributeError: self.channellist = [i.chan_label]

            self.event_tree(None,self.event_list,self.event_dict,treeview='treeview1')
            self.builder.get_object('button1').set_sensitive(True)

        except TypeError:
            pass

        try: self.custom_ch_ind = self.p.data.channels.labellist.index(self.chan_sel)
        except: pass