Ejemplo n.º 1
0
def show_simulated_multiple_crossings():
    
    '''
    S=np.array([[-1,0,0],[0,1,0],[0,0,1]])
    #T=np.array([[1,0,0],[0,0,]])
    T=np.array([[1,0,0],[-0.76672114,  0.26105963, -0.58650369]])
    print 'yo ',compare_orientation_sets(S,T)
    '''
    
    btable=np.loadtxt(get_data('dsi515btable'))
    bvals=btable[:,0]
    bvecs=btable[:,1:]
    
    """
    path='/home/eg309/Data/PROC_MR10032/subj_03/101_32/1312211075232351192010121313490254679236085ep2dadvdiffDSI10125x25x25STs004a001'    
    #path='/home/eg309/Data/101_32/1312211075232351192010121313490254679236085ep2dadvdiffDSI10125x25x25STs004a001'
    bvals=np.loadtxt(path+'.bval')
    bvecs=np.loadtxt(path+'.bvec').T   
    bvals=np.append(bvals.copy(),bvals[1:].copy())
    bvecs=np.append(bvecs.copy(),-bvecs[1:].copy(),axis=0)        
    """
    #bvals=np.load('/tmp/bvals.npy')
    #bvecs=np.load('/tmp/bvecs.npy')    
    #data=create_data(bvals,bvecs,d=0.00075,S0=100,snr=None)    
    #dvals=[0.0003, 0.0006, 0.0012, 0.0024, 0.0048]
    dvals=[0.0003, 0.0005, 0.0010, 0.0015, 0.0020, 0.0025, 0.0030]
    data = multi_d_isotropic_data(bvals,bvecs,dvals=dvals,S0=100,snr=None)
    dn=DiffusionNabla(data,bvals,bvecs,odf_sphere='symmetric362',
                      auto=False,save_odfs=True,fast=False,rotation=None)
    #rotation=np.array([[0,0,1],[np.sqrt(0.5),np.sqrt(0.5),0.],[np.sqrt(0.5),-np.sqrt(0.5),0.]])
    dn.peak_thr=.4
    dn.iso_thr=.05
    dn.radius=np.arange(0,6,0.2)
    dn.radiusn=len(dn.radius)
    
    dn.create_qspace(bvals,bvecs,16,8)
    dn.radon_params(64)
    dn.precompute_interp_coords()
    dn.precompute_fast_coords()
    dn.precompute_equator_indices(5.)
    dn.precompute_angular(0.01)
    dn.fit()
    
    '''

    ds=DiffusionSpectrum(data,bvals,bvecs,odf_sphere='symmetric642',auto=True,save_odfs=True)
    
    gq=GeneralizedQSampling(data,bvals,bvecs,1.2,odf_sphere='symmetric642',squared=False,auto=False,save_odfs=True)
    gq.peak_thr=.6
    gq.iso_thr=.7
    gq.fit()
    
    gq2=GeneralizedQSampling(data,bvals,bvecs,2.,odf_sphere='symmetric642',squared=True,auto=False,save_odfs=True)
    gq2.peak_thr=.6
    gq2.iso_thr=.7
    gq2.fit()
    '''
        
    dn_odfs=dn.odfs()
   
    #blobs=np.zeros((1,19,4,dn.odfn))
    blobs=np.zeros((1,len(dvals),1,dn.odfn))
    #blobs=np.zeros((1,19,1,dn.odfn))
    #blobs[0,:,0]=dn.odfs()
    for i,d in enumerate(dvals):
        blobs[0,i,0]=dn.ODF[i]/dn.ODF[i].mean()
        
    '''        
    blobs[0,:,1]=ds.odfs()
    blobs[0,:,2]=gq.odfs()    
    gq2odfs=gq2.odfs()
    gq2odfs[gq2odfs<0]=0
    
    print 'gq2',gq2odfs.min(),gq2odfs.max()
    blobs[0,:,3]=gq2odfs
    '''
    '''
    peaknos=np.array([0,1,2,3,3,3,3,3,3,2,2,1,1,2,3,0,3,3,3])    
    print peaknos
    print np.sum(dn.pk()>0,axis=1),np.sum(np.sum(dn.pk()>0,axis=1)-peaknos),len(peaknos)
    '''
    '''
    print np.sum(ds.qa()>0,axis=1),np.sum(np.sum(ds.qa()>0,axis=1)-peaknos),len(peaknos)
    print np.sum(gq.qa()>0,axis=1),np.sum(np.sum(gq.qa()>0,axis=1)-peaknos),len(peaknos)
    print np.sum(gq2.qa()>0,axis=1),np.sum(np.sum(gq2.qa()>0,axis=1)-peaknos),len(peaknos)
    '''
    show_blobs(blobs,dn.odf_vertices,dn.odf_faces,colormap='jet')

    for i, d in enumerate(dvals):
        m = dn.ODF[i].min()
        M = dn.ODF[i].max()
        vM = np.argmax(dn.ODF[i])
        print i, d, 50*(M-m)/(M+m), dn.odf_vertices[vM]
        
    #odf=dn.fast_odf(data[0])
    #r=fvtk.ren()
    #fvtk.add(r,fvtk.volume(dn.Eq))
    #fvtk.show(r)
    
    """
    blobs2=np.zeros((1,1,3,dn.odfn))    
    blobs2[0,:,0]=dn.log_fast_odf(data[15])
    blobs2[0,:,1]=dn.fast_odf(data[15])
    blobs2[0,:,2]=dn.log_slow_odf(data[15])
    show_blobs(blobs2,dn.odf_vertices,dn.odf_faces)
    
    e=data[15]/data[15,0]    
    ne=np.sqrt(-np.log(e))
    norm=np.sum(dn.qtable**2,axis=1)
    """
        
    """
Ejemplo n.º 2
0
def show_simulated_2fiber_crossings():

    btable=np.loadtxt(get_data('dsi515btable'))
    bvals=btable[:,0]
    bvecs=btable[:,1:]
    
    data=create_data_2fibers(bvals,bvecs,d=0.0015,S0=100,angles=np.arange(0,47,5),snr=None)
    #data=create_data_2fibers(bvals,bvecs,d=0.0015,S0=100,angles=np.arange(0,92,5),snr=None)
    
    print data.shape
    #stop
    
    
    #"""
    dn=DiffusionNabla(data,bvals,bvecs,odf_sphere='symmetric642',
                      auto=False,save_odfs=True,fast=True)    
    dn.peak_thr=.4
    dn.iso_thr=.05
    dn.radius=np.arange(0,5,0.1)
    dn.radiusn=len(dn.radius)    
    dn.create_qspace(bvals,bvecs,16,8)
    dn.radon_params(64)
    dn.precompute_interp_coords()
    dn.precompute_fast_coords()
    dn.precompute_equator_indices(5.)
    dn.precompute_angular(None)#0.01)
    dn.fit()
    
    dn2=DiffusionNabla(data,bvals,bvecs,odf_sphere='symmetric642',
                      auto=False,save_odfs=True,fast=False)    
    dn2.peak_thr=.4
    dn2.iso_thr=.05
    dn2.radius=np.arange(0,5,0.1)
    dn2.radiusn=len(dn.radius)    
    dn2.create_qspace(bvals,bvecs,16,8)
    dn2.radon_params(64)
    dn2.precompute_interp_coords()
    dn2.precompute_fast_coords()
    dn2.precompute_equator_indices(5.)
    dn2.precompute_angular(None)#0.01)
    dn2.fit()
    #"""
    
        
    eis=EquatorialInversion(data,bvals,bvecs,odf_sphere='symmetric642',
                      auto=False,save_odfs=True,fast=True)    
    #eis.radius=np.arange(0,6,0.2)
    eis.radius=np.arange(0,5,0.1)    
    eis.gaussian_weight=None
    eis.set_operator('signal')#'laplap')
    eis.update()
    eis.fit()
    
    eil=EquatorialInversion(data,bvals,bvecs,odf_sphere='symmetric642',
                      auto=False,save_odfs=True,fast=True)
    #eil.radius=np.arange(0,6,0.2)
    eil.radius=np.arange(0,5,0.1)    
    eil.gaussian_weight=None
    eil.set_operator('laplacian')#'laplap')
    eil.update()
    eil.fit()
    
    eil2=EquatorialInversion(data,bvals,bvecs,odf_sphere='symmetric642',
                      auto=False,save_odfs=True,fast=True)    
    #eil2.radius=np.arange(0,6,0.2)
    eil2.radius=np.arange(0,5,0.1)
    eil2.gaussian_weight=None
    eil2.set_operator('laplap')
    eil2.update()
    eil2.fit()
        
    ds=DiffusionSpectrum(data,bvals,bvecs,odf_sphere='symmetric642',auto=True,save_odfs=True)

    gq=GeneralizedQSampling(data,bvals,bvecs,1.2,odf_sphere='symmetric642',squared=False,auto=False,save_odfs=True)
    gq.fit()
    
    gq2=GeneralizedQSampling(data,bvals,bvecs,3.,odf_sphere='symmetric642',squared=True,auto=False,save_odfs=True)
    gq2.fit()    

    #blobs=np.zeros((19,1,8,dn.odfn))
    blobs=np.zeros((10,1,6,dn.odfn))
    """
    blobs[:,0,0]=dn.odfs()
    blobs[:,0,1]=dn2.odfs()
    blobs[:,0,2]=eis.odfs()
    blobs[:,0,3]=eil.odfs()    
    blobs[:,0,4]=eil2.odfs()         
    blobs[:,0,5]=ds.odfs()
    blobs[:,0,6]=gq.odfs()
    blobs[:,0,7]=gq2.odfs()
    """
    blobs[:,0,0]=dn2.odfs()
    blobs[:,0,1]=eil.odfs()
    eo=eil2.odfs()
    #eo[eo<0.05*eo.max()]=0
    blobs[:,0,2]=eo         
    blobs[:,0,3]=ds.odfs()
    blobs[:,0,4]=gq.odfs()
    blobs[:,0,5]=gq2.odfs()
        
    show_blobs(blobs,dn.odf_vertices,dn.odf_faces,scale=0.5)
Ejemplo n.º 3
0
    #bvecs=np.load('/tmp/bvecs.npy')    
    #data=create_data(bvals,bvecs,d=0.00075,S0=100,snr=None)    
    #dvals=[0.0003, 0.0006, 0.0012, 0.0024, 0.0048]
    dvals=[0.0003, 0.0005, 0.0010, 0.0015, 0.0020, 0.0025, 0.0030]
    data = multi_d_isotropic_data(bvals,bvecs,dvals=dvals,S0=100,snr=None)
    dn=DiffusionNabla(data,bvals,bvecs,odf_sphere='symmetric362',
                      auto=False,save_odfs=True,fast=False,rotation=None)
    #rotation=np.array([[0,0,1],[np.sqrt(0.5),np.sqrt(0.5),0.],[np.sqrt(0.5),-np.sqrt(0.5),0.]])
    dn.peak_thr=.4
    dn.iso_thr=.05
    dn.radius=np.arange(0,6,0.2)
    dn.radiusn=len(dn.radius)
    
    dn.create_qspace(bvals,bvecs,16,8)
    dn.radon_params(64)
    dn.precompute_interp_coords()
    dn.precompute_fast_coords()
    dn.precompute_equator_indices(5.)
    dn.precompute_angular(0.01)
    dn.fit()
    
    '''

    ds=DiffusionSpectrum(data,bvals,bvecs,odf_sphere='symmetric642',auto=True,save_odfs=True)
    
    gq=GeneralizedQSampling(data,bvals,bvecs,1.2,odf_sphere='symmetric642',squared=False,auto=False,save_odfs=True)
    gq.peak_thr=.6
    gq.iso_thr=.7
    gq.fit()
    
    gq2=GeneralizedQSampling(data,bvals,bvecs,20,odf_sphere='symmetric642',squared=True,auto=False,save_odfs=True)