示例#1
0
def get_ind(triggervals, data):
    u,n,nz = trigger.vals(data)
    ind = {}
    for i in range(0,len(triggervals)):
        ind[i] = trigger.zero_to_nonzero_ind(data,triggervals[i])
        #ind[i] = trigger.ind([triggervals[i]],n,nz)
    return ind
示例#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