def getderivedlabels(datafile): ch = channel.index(datafile, 'derived') chdict = {} for i in ch.chnumber: chdict[ch.cfgchname[ch.cfgchannumber == i][0]] = i return ch, chdict
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'
def coilpower(self, event): # wxGlade: MyFrame.<event_handler> print "Event handler `coilpower' " try: n = nearest(self.freq, 165) except AttributeError: print 'no power... running for you' self.pow,self.freq = functions.psd(self.datapdf) n = nearest(self.freq, 165) self.ch = channel.index(self.datapdf, 'meg') megcontour.display(self.pow[int(n[0]),:], self.ch.chanlocs)
def badchannels(self, event): # wxGlade: MyFrame.<event_handler> print "Event handler `badchannels' " try: bad = badchannels.calc(datapdf, self.pow, ch,thresh=5, chfreq='yes', freqarray=self.freq, maxhz=200,powernotch='yes', minhz=4) except NameError: print 'no power... running for you' self.pow,self.freq = functions.psd(self.datapdf) self.ch = channel.index(self.datapdf, 'meg') bad = badchannels.calc(self.datapdf, self.pow, self.ch, thresh=5, chfreq='yes', freqarray=self.freq, maxhz=200,powernotch='yes', minhz=4) figure(1,figsize=(5,10)) subplot(2,1,1);plot(bad[3]);title('channel power ratio to family'); subplot(2,1,2);megcontour.display(bad[3], self.ch.chanlocs)
def psd(datapdf): d = data.read(datapdf) nfft=256*2 ch = channel.index(datapdf, 'meg') d.getdata(0, d.pnts_in_file, ch.channelindexhdr) data2anz = d.data_block #data2anz = result['attenddata'] pow = zeros([(nfft/2)+1, size(data2anz,1)]) comp = zeros([(nfft/2)+1, size(data2anz,1)], complex_) #fftreal = (zeros([(nfft/2)+1, size(attenddata,1)])) for eachch in range(0, size(data2anz,1)): p,f,i = spectral.psd(data2anz[:,eachch], NFFT=nfft, Fs=1/ d.hdr.header_data.sample_period)#, noverlap=200)#, detrend=matplotlib.pylab.detrend_mean) #p,f,i = spectral.psd(data[:,eachch], NFFT=nfft, Fs=1/ d.hdr.header_data.sample_period ) pow[:,eachch] = p comp[:,eachch] = i #fftreal[:,eachch] = r logpow = 10*log10(pow) freq=f return logpow, freq
def getdata(datapath, chtype): ch = channel.index(datapath, chtype) d = data.read(datapath) labels = ch.chlabel[ch.channelsind] d.getdata(0, d.pnts_in_file, ch.channelsind) return d, labels