Beispiel #1
0
def show_signals(data,bvals,gradients,sticks=None):
    
    s=data[1:]
    s0=data[0]    
    ls=np.log(s)-np.log(s0)
    ind=np.arange(1,data.shape[-1])
    ob=-1/bvals[1:]
    #lg=np.log(s[1:])-np.log(s0)
    d=ob*(np.log(s)-np.log(s0))    
    r=fvtk.ren()
    all=fvtk.crossing(s,ind,gradients,scale=1)
    #fvtk.add(r,fvtk.line(all,fvtk.coral))    
    #d=d-d.min()        
    #all3=fvtk.crossing(d,ind,gradients,scale=10**4)
    #fvtk.add(r,fvtk.line(all3,fvtk.red))    
    #d=d-d.min()        
    all2=fvtk.crossing(d,ind,gradients,scale=10**4)
    fvtk.add(r,fvtk.line(all2,fvtk.green))    
    #"""
    #d2=d*10**4
    #print d2.min(),d2.mean(),d2.max(),d2.std()    
    for a in all2:    
        fvtk.label(r,str(np.round(np.linalg.norm(a[0]),2)),pos=a[0],scale=(.2,.2,.2),color=(1,0,0))        
    if sticks!=None:
        for s in sticks:
            ln=np.zeros((2,3))
            ln[1]=s
            fvtk.add(r,fvtk.line(d.max()*10**4*ln,fvtk.blue)) 
    #data2=data.reshape(1,len(data))
    #pdi=ProjectiveDiffusivity(data2,bvals,gradients,dotpow=6,width=6,sincpow=2)
    #pd=pdi.spherical_diffusivity(data)
    #print pd
    #"""    
    fvtk.show(r)
Beispiel #2
0
def show(T,A,IND,VERTS,scale):
    
    r=fvtk.ren()
    fvtk.clear(r)
    fvtk.add(r,fvtk.line(T,fvtk.red))
    fvtk.show(r)
    
    Td=[downsample(t,20) for t in T]
    C=local_skeleton_clustering(Td,3)
    fvtk.clear(r)
    lent=float(len(T))
    
    for c in C:
        color=np.random.rand(3)
        virtual=C[c]['hidden']/float(C[c]['N'])
        if length(virtual)> virtual_thr: 
            linewidth=100*len(C[c]['indices'])/lent
            if linewidth<1.:
                linewidth=1
            #fvtk.add(r,fvtk.line(virtual,color,linewidth=linewidth))
            #fvtk.add(r,fvtk.label(r,str(len(C[c]['indices'])),pos=virtual[0],scale=3,color=color ))
        #print C[c]['hidden'].shape
    
    print A.shape
    print IND.shape
    print VERTS.shape
    
    all,allo=fvtk.crossing(A,IND,VERTS,scale,True)
    colors=np.zeros((len(all),3))
    for (i,a) in enumerate(all):
        if allo[i][0]==0 and allo[i][1]==0 and allo[i][2]==1:
            pass
        else:            
            colors[i]=cm.boys2rgb(allo[i])
    
    fvtk.add(r,fvtk.line(all,colors))    
    fvtk.show(r)
We locate 3 contiguous voxels [3,8,4], [3,8,5], and [3,8,6] which have respectively
1, 2, and 3 crossings.

``fvtk.crossing`` is a helper function which we use to graph the orientations of the maxima
of all the voxels in our dataset. We use 3 different colourings and offset the graphs to display them
in one diagram. The colourings are:

- all blue, with the 3 voxels used above ([3,8,4], [3,8,5], and [3,8,6]) marked in blue, indigo, and red.
- the Boys' colour map (see ``colormap.boys2rgb.py``)
- the orientation colour map (see ``colormap.orient2rgb.py`` with red: left-right; green: anteroposterior; blue: superior-inferior.

"""

#3,8,4 no crossing
no_cross = fvtk.crossing(QA[3, 8, 4], IN[3, 8, 4], verts, 1)

#3,8,5 crossing
cross = fvtk.crossing(QA[3, 8, 5], IN[3, 8, 5], verts, 1)

#3,8,6 double crossing
dcross = fvtk.crossing(QA[3, 8, 6], IN[3, 8, 6], verts, 1)

all, allo = fvtk.crossing(QA, IN, verts, 1, True)
fvtk.add(r, fvtk.line(all, fvtk.azure, linewidth=1.))

no_cross_shift = [c + np.array([3, 8, 4]) for c in no_cross]
cross_shift = [c + np.array([3, 8, 5]) for c in cross]
dcross_shift = [c + np.array([3, 8, 6]) for c in dcross]

fvtk.add(r, fvtk.line(no_cross_shift, fvtk.blue, linewidth=5.))
We locate 3 contiguous voxels [3,8,4], [3,8,5], and [3,8,6] which have respectively
1, 2, and 3 crossings.

``fvtk.crossing`` is a helper function which we use to graph the orientations of the maxima
of all the voxels in our dataset. We use 3 different colourings and offset the graphs to display them
in one diagram. The colourings are:

- all blue, with the 3 voxels used above ([3,8,4], [3,8,5], and [3,8,6]) marked in blue, indigo, and red.
- the Boys' colour map (see ``colormap.boys2rgb.py``)
- the orientation colour map (see ``colormap.orient2rgb.py`` with red: left-right; green: anteroposterior; blue: superior-inferior.

"""

#3,8,4 no crossing
no_cross=fvtk.crossing(QA[3,8,4],IN[3,8,4],verts,1)

#3,8,5 crossing
cross=fvtk.crossing(QA[3,8,5],IN[3,8,5],verts,1)

#3,8,6 double crossing
dcross=fvtk.crossing(QA[3,8,6],IN[3,8,6],verts,1)

all,allo=fvtk.crossing(QA,IN,verts,1,True)
fvtk.add(r,fvtk.line(all,fvtk.azure,linewidth=1.))

no_cross_shift=[c+np.array([3,8,4]) for c in no_cross]
cross_shift=[c+np.array([3,8,5]) for c in cross]
dcross_shift=[c+np.array([3,8,6]) for c in dcross]

fvtk.add(r,fvtk.line(no_cross_shift,fvtk.blue,linewidth=5.))