def check_mem_masked_where(self,level=rlevel):
     """Ticket #62"""
     from numpy.core.ma import masked_where, MaskType
     a = N.zeros((1,1))
     b = N.zeros(a.shape, MaskType)
     c = masked_where(b,a)
     a-c
Exemplo n.º 2
0
def plot_data(xi,yi,zi):
    zim = ma.masked_where(N.isnan(zi),zi)
    pylab.figure(figsize=(8,8))
#    pylab.pcolor(xi,yi,zim,shading='interp',cmap=pylab.cm.gray)
    pylab.pcolor(xi,yi,zim,shading='interp',cmap=pylab.cm.jet)
#    pylab.contour(xi,yi,zim,cmap=pylab.cm.jet)
    pylab.show()
Exemplo n.º 3
0
 def check_mem_masked_where(self, level=rlevel):
     """Ticket #62"""
     from numpy.core.ma import masked_where, MaskType
     a = N.zeros((1, 1))
     b = N.zeros(a.shape, MaskType)
     c = masked_where(b, a)
     a - c
Exemplo n.º 4
0
def plot_data(xi,yi,zi,intx,inty):
    """provide...
        xi=grid x data
        yi=grided y data
        zi=interpolated MEG data for contour
        intx and inty= sensor coords for channel plotting"""
        
    tstart = time.time() 
    zim = ma.masked_where(isnan(zi),zi)

    #p.pcolor(xi,yi,zim,shading='interp',cmap=p.cm.jet)
    p.contourf(xi,yi,zim,cmap=p.cm.jet)
Exemplo n.º 5
0
def plot_data(xi,yi,zi,intx,inty):
    """provide...
        xi=grid x data
        yi=grided y data
        zi=interpolated MEG data for contour
        intx and inty= sensor coords for channel plotting"""
    zim = ma.masked_where(isnan(zi),zi)
    #pcolor(xi,yi,zim,shading='interp',cmap=cm.jet)
    contourf(xi,yi,zim,cmap=cm.jet)
    #scatter(intx,inty, alpha=.5,s=.5)
    #contour(xi,yi,zim,cmap=cm.jet)
    draw()
Exemplo n.º 6
0
def display(data, chanlocs, labels="None", contourdata=None):

    xi, yi = mgrid[-0.5:0.5:67j, -0.5:0.5:67j]
    intx = chanlocs[1, :]
    inty = chanlocs[0, :]
    print "2d array of data"

    # tri = Triangulation(intx,inty)

    p.ion()
    fig = p.figure()

    print "suplotting quiver"
    if len(data.shape) == 1:
        data = array([data])
    for i in range(0, size(data, 0)):
        spnum = ceil(sqrt(shape(data)[0]))  # get x and y dimension of subplots
        fig.add_subplot(spnum, spnum, i + 1)
        # axis('off')

        if contourdata != None:

            dataslice = contourdata[i, :]
            z = dataslice

            if delaunay == "yes":
                print "delaunay is set"
                tri = Triangulation(intx, inty)
                interp = tri.nn_interpolator(z)
                zi = interp(xi, yi)
            else:  # try griddata method
                print "delaunay is off"
                zi = griddata(intx, inty, z, xi, yi)

            interp = tri.nn_interpolator(z)
            zi = interp(xi, yi)
            zim = ma.masked_where(isnan(zi), zi)
            p.contourf(xi, yi, zim, cmap=p.cm.jet, alpha=0.8)
            p.axis("off")

        dataslice = data[i, :]
        z = dataslice
        sc = data.max() * 10
        # return intx, inty, z#imag(z), real(z)
        # print i
        p.quiver(intx, inty, imag(z), real(z))  # , scale=sc)
        if labels != "None":
            p.title(str(labels[i]))
        p.axis("off")
Exemplo n.º 7
0
def display(data, chanlocs):

    xi, yi = mgrid[-.5:.5:67j,-.5:.5:67j]
    intx=chanlocs[1,:]
    inty=chanlocs[0,:]
    z = data
    
    
##    tri = Triangulation(intx,inty)
##    interp = tri.nn_interpolator(z)
##    zi = interp(xi,yi)
    
    if delaunay == 'yes':
        tri = Triangulation(intx,inty)
        interp = tri.nn_interpolator(z)
        zi = interp(xi,yi)
    else: #try griddata method
        zi = griddata(intx,inty,z,xi,yi)
        
    zim = ma.masked_where(isnan(zi),zi)
    plot_data(xi,yi,zi,intx,inty)
Exemplo n.º 8
0
def display(data, chanlocs, data2=None, subplot='on', animate='off', quiver='off', title=None, labels=None, colorbar='off'):

    if len(shape(chanlocs)) != 2:
        print 'Chanlocs shape error. Should be 2D array "(2,N)"'
        print 'transposing'
        chanlocs = chanlocs.T

    #xi, yi = mgrid[-.5:.5:67j,-.5:.5:67j]
    xi, yi = mgrid[chanlocs[1,:].min():chanlocs[1,:].max():57j,chanlocs[0,:].min():chanlocs[0,:].max():57j]
    intx=chanlocs[1,:]
    inty=chanlocs[0,:]

    if shape(shape(data))[0]==2: #more than a single vector, need to animate or subplot

        print '2d array of data'
        z = data[0,:]
        if delaunay == 'yes':
            print 'delaunay is set'
            tri = Triangulation(intx,inty)
            interp = tri.nn_interpolator(z)
            zi = interp(xi,yi)
        else: #try griddata method
            print 'delaunay is off'
            zi = griddata(intx,inty,z,xi,yi)

        #p.ion()
        fig = p.figure()

        if animate == 'on': #single plot with a loop to animate
            p.scatter(intx,inty, alpha=.5,s=.5)
            print 'animating'
            for i in range(0, shape(data)[0]):
                dataslice=data[i,:];
                z = dataslice
                if delaunay == 'yes':
                    interp = tri.nn_interpolator(z)
                    zi = interp(xi,yi)
                else:
                    zi = griddata(intx,inty,z,xi,yi)

                zim = ma.masked_where(isnan(zi),zi)
                p.contourf(xi,yi,zim,cmap=p.cm.jet, alpha=.8)
                if labels != None:
                    printlabels(chanlocs, labels)
                p.draw()
                #del(z,interp,zi,zim)
        if subplot == 'on':
            print 'suplotting'
            for i in range(0, shape(data)[0]):
                spnum = ceil(sqrt(shape(data)[0])) #get x and y dimension of subplots
                fig.add_subplot(spnum,spnum,i+1);#axis('off')
                dataslice=data[i,:];
                p.scatter(intx,inty, alpha=.75,s=3)
                z = dataslice
                if delaunay == 'yes':
                    interp = tri.nn_interpolator(z)
                    zi = interp(xi,yi)
                else:
                    zi = griddata(intx,inty,z,xi,yi)

                zim = ma.masked_where(isnan(zi),zi)
                p.contourf(xi,yi,zim,cmap=p.cm.jet, alpha=.8)
                p.axis('off')
                if labels != None:
                    printlabels(chanlocs, labels)
                if title != None:
                    p.title(str(title[i]))
                else:
                    p.title(str(i))
        if quiver == 'on':
            print 'suplotting quiver'
            for i in range(0, shape(data)[0]):
                spnum = ceil(sqrt(shape(data)[0])) #get x and y dimension of subplots
                fig.add_subplot(spnum,spnum,i+1);#axis('off')
                dataslice=data[i,:];
                p.scatter(intx,inty, alpha=.75,s=3)
                z = dataslice
                print 'size or z', size(z)
                for xx in range(0,size(z)):
                    quiver(intx[xx],inty[xx], z[xx], data2[xx])

                p.axis('off')
                if labels != None:
                    printlabels(chanlocs, labels)
        if colorbar == 'on':
            p.colorbar()

        #p.ioff()
        #p.colorbar()
        p.show()
    else:
        z = data
        if delaunay == 'yes':
            print 'delaunay is set'
            tri = Triangulation(intx,inty)
            interp = tri.nn_interpolator(z)
            zi = interp(xi,yi)
        else:
            print 'delaunay is off'
            zi = griddata(intx,inty,z,xi,yi)

        zim = ma.masked_where(isnan(zi),zi)
        plot_data(xi,yi,zi,intx,inty)
        if labels != None:
            printlabels(chanlocs, labels)

        if colorbar == 'on':
            p.colorbar(cmap=p.cm.jet)