Beispiel #1
0
def compare_sdni_eitl():
    
    btable=np.loadtxt(get_data('dsi515btable'))
    bvals=btable[:,0]
    bvecs=btable[:,1:]   
    
    type=3
    axesn=200
    SNR=20
    
    data,gold,angs,anglesn,axesn,angles=generate_gold_data(bvals,bvecs,fibno=type,axesn=axesn,SNR=SNR)
    
    ei=EquatorialInversion(data,bvals,bvecs,odf_sphere='symmetric642',
                           auto=False,save_odfs=True,fast=True)    
    ei.radius=np.arange(0,5,0.1)
    ei.gaussian_weight=None
    ei.set_operator('laplacian')
    #{'reflect','constant','nearest','mirror', 'wrap'}
    ei.set_mode(order=1,zoom=1,mode='constant')    
    ei.update()
    ei.fit()

    dn=DiffusionNabla(data,bvals,bvecs,odf_sphere='symmetric642',
                      auto=False,save_odfs=True,fast=False)    
    dn.radius=np.arange(0,5,0.1)
    dn.gaussian_weight=None
    dn.update()
    dn.fit()
    
    vts=ei.odf_vertices
    
    def simple_peaks(ODF,faces,thr):
        x,g=ODF.shape
        PK=np.zeros((x,5))
        IN=np.zeros((x,5))
        for (i,odf) in enumerate(ODF):
            peaks,inds=peak_finding(odf,faces)
            ibigp=np.where(peaks>thr*peaks[0])[0]
            l=len(ibigp)
            if l>3:
                l=3
            PK[i,:l]=peaks[:l]
            IN[i,:l]=inds[:l]
        return PK,IN
    
    print "test0"
    thresh=0.5
    PK,IN=simple_peaks(ei.ODF,ei.odf_faces,thresh)
    res,me,st =do_compare(gold,vts,PK,IN,0,anglesn,axesn,type)
    #PKG,ING=simple_peaks(eig.ODF,ei.odf_faces,thresh)
    #resg,meg,stg =do_compare(gold,vts,PKG,ING,0,anglesn,axesn,type)
    PK,IN=simple_peaks(dn.ODF,dn.odf_faces,thresh)
    res2,me2,st2 =do_compare(gold,vts,PK,IN,0,anglesn,axesn,type)
    if type==3:
            x,y,z=sphere2cart(np.ones(len(angles)),np.deg2rad(angles),np.zeros(len(angles)))
            x2,y2,z2=sphere2cart(np.ones(len(angles)),np.deg2rad(angles),np.deg2rad(120*np.ones(len(angles))))
            angles2=[]
            for i in range(len(x)):
                angles2.append(np.rad2deg(np.arccos(np.dot([x[i],y[i],z[i]],[x2[i],y2[i],z2[i]]))))
            angles=angles2
    print "test1"
    plt.figure(1)
    plt.plot(angles,me,'k:',linewidth=3.,label='EITL')
    plt.plot(angles,me2,'k--',linewidth=3.,label='sDNI')
    #plt.plot(angles,me7,'r--',linewidth=3.,label='EITL2')
    plt.xlabel('angle')
    plt.ylabel('similarity')
    title='Angular similarity of ' + str(type) + '-fibres crossing with SNR ' + str(SNR)
    plt.title(title)
    plt.legend(loc='center right')
    plt.savefig('/tmp/test.png',dpi=300)
    plt.show()