Пример #1
0
    def __init__(self, pdfdataobj, data, chind, power='off'):#, seedpoint, weight, iterations):
        '''
        p = pdf.read(path2pdf)
        p.data.setchannels('meg')
        p.data.channels.getposition()
        chind = p.data.channels.sensorpos.chlpos[:,1]>0
        '''
        p = pdf.read(pdfdataobj)
        p.data.setchannels('meg')
        p.data.channels.getposition()

        if size(data.shape) == 1: #make 2d
            data = array([data])

        numhspts = size(p.hs.hs_point,0)
        d = zeros([numhspts])
        for j in range(0, numhspts): #distance from 0,0,40 mm to all hs points
            d[j] = euclid.distarray([0,0,40],p.hs.hs_point[j]*1000)
        self.d = d

        self.n = euclid.distarray([0,0,40],p.hs.index_nasion*1000)

        numofgrids = ng = 6 #d.max()
        startgridspacing = gs = float((self.n.max()/ng)*2) #mm
        cog = centerofgrid = array([0,0,40]) #mm
        iterations = 10

        for i in range(0,iterations): #iterate over grids
            scaledgs = gs/(i+1); print 'gs',gs
            print cog,ng,scaledgs
            e = grid.sphere(cog,ng,scaledgs)
            self.e = e
            self.lf = leadfield.calc(pdfdataobj, p.data.channels, e)
            if power == 'on': #doing power localization. ABS of leadfields
                self.w = calc(pdfdataobj, abs(self.lf.leadfield[:,chind,:]), data[:,chind])
            else:
                self.w = calc(pdfdataobj, self.lf.leadfield[:,chind,:], data[:,chind])

            cog = self.lf.grid[argmax(self.w.corr_mat)]
            gof = self.w.corr_mat.max()
            print gof, cog
            gs = scaledgs
            self.bestfit = cog
            self.gof = gof
Пример #2
0
    #a_sph.append(abs(h))
    #a_th.append(theta * 180/pi)
    #theta = theta + 0.02

#plot(a_th,a_sph)
#show()


#simsource
from meg import leadfield
from meg import simsource
xyz=array([ 12.5, -56.6 ,  82.0]) #in mm
qxqyqz=array([.8,.078,1.578])
from meg import makesine
ms = makesine.create(1000, 1/p.hdr.header_data.sample_period, 5)
lfin = leadfield.calc(p, p.data.channels, xyz)
s = simsource.calc(lfin, xyz, qxqyqz)
s=s[0,:,:]
simd_5hz = dot(ms,s)

xyzout=array([ 12.5, -56.6 ,  250.0]) #in mm; outside array
qxqyqz=array([.8,.078,1.578])
from meg import makesine
ms = makesine.create(1000, 1/p.hdr.header_data.sample_period, 30)
lfout = leadfield.calc(p, p.data.channels, xyzout)
s=simsource.calc(lfout, xyzout, qxqyqz)
s=s[0,:,:]
simd_30hz = dot(ms,s)

simd_mix = simd_5hz + simd_30hz
Alm_in = dot(simd_mix, Sin.T)
Пример #3
0
 def getleadfield(self):
     from meg import leadfield
     from pdf2py import pdf
     p = pdf.read(self.path2pdf);p.data.setchannels('meg')
     self.lf = leadfield.calc(self.path2pdf, p.data.channels, self.scaledgrid*1000)