Example #1
0
        def avgdata():

            print self.datapiece.trigind.trigstartind
            for trig in self.datapiece.trigind.trigstartind: #do something for each trigger found
                if self.datapiece.chunk - trig >= epochwidth: #enough room for a single epoch
                    epochdata=(self.datapiece.data_blockall[trig:trig+epochwidth])
                    #print 'shape of avg data ',shape(epochdata)
                    try:
                        print 'checking for avg data'
                        self.data_avg
                    except AttributeError:
                        print 'starting first epoch'
                        self.data_avg = epochdata #create first epoch
                        #self.data_avg=data_avg
                        self.avgtimes=0
                        self.data3d=epochdata
                    self.data_avg=offset.correct((self.data_avg+epochdata))
                    #print 'shape of avg',self.data_avg
                    #print 'averaging', shape(self.data_avg)
                    self.avgtimes=self.avgtimes+1
                    #print 'avgtimes', self.avgtimes
                    self.lastepoch=offset.correct(epochdata)
                    #self.data3d=append(self.data3d,self.lastepoch)
                    print self.avgtimes,shape(epochdata)[0], shape(epochdata)[1]
                    #self.data3d=offset.correct(self.data3d.reshape(self.avgtimes+1, shape(epochdata)[0], shape(epochdata)[1]))
                else: #not enough room for an epoch
                    print 'not enough room for an epoch'
                    try:
                        self.bufferedtrig
                    except AttributeError:
                        self.bufferedtrig=array([trig])
                    else:
                        self.bufferedtrig=append(self.bufferedtrig, trig)

                    trig2end=shape(self.datapiece.data_blockall)[0] - trig #get size of from trigger ind to end of dataslice
                    #print trig2end, 'buffered'

                    try:
                        self.bufferdata #look for buffer var
                    except AttributeError:
                        #bufferdata = array([1,shape(self.datapiece.data_blockall)[1]]) #create empty buffer
                        self.bufferdata=self.datapiece.data_blockall[trig:trig+trig2end,:] #create first instance of buffer
                        #print 'shape of first buffer data ',shape(self.bufferdata)
                    else:

                    #print shape(self.datapiece.data_blockall)
                        self.bufferdata=append(self.bufferdata, self.datapiece.data_blockall[trig:trig+trig2end,:], axis=0) #keep appending until enough room
Example #2
0
 def __init__(self, datapdf, chlabel):
     ch=channel.index(datapdf, 'meg')
     chind=ch.channelindexhdr[ch.channelsortedlabels == chlabel]
     self.d=data.read(datapdf)
     self.d.getdata(0, self.d.pnts_in_file, chind)
     self.d.data_block=offset.correct(self.d.data_block)
     print self.d.data_block.shape
     self.p=pdf.read(datapdf)
     self.ext = 'pymtimef'
Example #3
0
    def runoffsetcorrect(self,widget):#, callback=None):
        start = self.builder.get_object('entry1').get_text()
        end = self.builder.get_object('entry2').get_text()
        self.startind = nearest.nearest(self.eventtime,start)[0]
        self.endind = nearest.nearest(self.eventtime,end)[0]
        print 'offset correcting data', self.startind, self.endind
        for i in range(self.numofepochs):
            print 'epoch',i+1# i*self.frames, (i*self.frames)+self.frames, self.startind, self.endind
            epoch_data = self.data[i*self.frames:(i*self.frames)+self.frames,:]
            tmp = offset.correct(epoch_data, start=self.startind, end=self.endind)

            try: outdata = vstack((outdata,tmp))
            except UnboundLocalError: outdata = copy(tmp)

        try: self.callback(outdata)
        except (TypeError,NameError): pass
Example #4
0
 def offsetcorrect2(self, start=0, end=-1):
     from meg import offset
     self.data_block = offset.correct(self.data_block, start, end)
Example #5
0
 def offset_correct(self, start=0, end=-1):
     from meg import offset
     self.results.offsetcorrecteddata = offset.correct(self.data.data_block, start=start, end=end)