def main():
    #set some values to be used later
    sh_order = 6
    verts, edges, efaces = create_unit_sphere(4)

    #read_data from disk
    data, fa, bvec, bval, voxel_size = sample_hardi_data()
    data_slice = data[32:76, 32:76, 26:27]
    fa_slice = fa[32:76, 32:76, 26]

    #normalize data by dividing by b0, this is needed so we can take log later
    norm_data = normalize_data(data_slice, bval, min_signal=1)

    #create an instance of the model
    model_instance = MonoExpOpdfModel(sh_order, bval, bvec, .006)
    model_instance.set_sampling_points(verts, edges)

    #use the model it fit the data
    opdfs_sampled_at_verts = model_instance.evaluate(norm_data)
    opdfs_sph_harm_coef = model_instance.fit_data(norm_data)

    #display the opdf blobs using mayavi
    faces = edges[efaces, 0]
    show_blobs(opdfs_sampled_at_verts, verts, faces)
    mlab.imshow(fa_slice, colormap='gray', interpolate=False)
    mlab.show()
예제 #2
0
## verts = np.column_stack(sph2car(theta, phi))
## from dipy.core.meshes import faces_from_vertices
## faces = faces_from_vertices(verts)

def separation_from_odf(odf):
    # Find angles
    from dipy.reconst.recspeed import local_maxima
    p, i = local_maxima(odf, edges)
    p = p[:2]
    i = i[:2]
    print "Peaks:", p
    print "Angular separation:", np.rad2deg(np.arccos(np.abs(np.dot(verts[i[0]], verts[i[1]]))))

ODFs = []
#m = SlowAdcOpdfModel(coords['b'], sampling_xyz, sh_order=8, odf_vertices=verts)
m = MonoExpOpdfModel(coords['b'], sampling_xyz, sh_order=8, odf_vertices=verts)

for k, fn in enumerate(sorted(glob.glob(os.path.join(sph_io.data_path,
                                                     'odf_coeffs_*.npz')))):
    data = sph_io.load(os.path.basename(fn))

    print "Dipy model..."
    odf = m.evaluate_odf(data['signal'])
    ODFs.append(odf)
    separation_from_odf(odf)

    print "Quadrature model..."
    odf = kernel_reconstruct(coords['odf_theta'], coords['odf_phi'], data['beta'],
                             theta, phi,
                             kernel=even_kernel, N=data['kernel_N'])
    odf[odf < 0] = 0