def show_coverage_3d(rg, field, rm=None, vmin=None, sphere_colormap='jet'): """ """ # Resolution with which the small spheres are drawn pt_resolution = 20 # Size factor for small spheres scale_factor = 0.1 # missing directions in red, if any if rm is not None: xm, ym, zm = rm theta, phi, rho = coord.car2sph(xm, ym, zm) plot.scatter_3D(theta, phi, resolution=pt_resolution, scale_factor=scale_factor, name='Bad direction') # 'good' directions in green xg, yg, zg = rg theta, phi, rho = coord.car2sph(xg, yg, zg) # As simple spheres plot.scatter_3D(theta, phi, color=(0, 1, 0), scale_factor=scale_factor, resolution=pt_resolution, name='Good directions') npts_lat, npts_lon = field.shape theta = np.linspace(0, np.pi, npts_lat) phi = np.linspace(0, 2 * np.pi, npts_lon) s = plot.surf_grid_3D(field, theta, phi, vmin=vmin, name='Coverage') mlab = plot.get_mlab() mlab.colorbar(s, orientation='horizontal') mlab.show()
sphere = create_unit_sphere(6) bb = np.ones(len(sphere.vertices)) * b.mean() E_ = w[0] * single_tensor(gradients=sphere.vertices, bvals=bb, S0=1, rotation=R0, SNR=SNR) E_ += w[1] * single_tensor(gradients=sphere.vertices, bvals=bb, S0=1, rotation=R1, SNR=SNR) ODF = w[0] * single_tensor_ODF(sphere.vertices, rotation=R0) ODF += w[1] * single_tensor_ODF(sphere.vertices, rotation=R1) from dipy.viz import show_odfs show_odfs([[[E_, ODF]]], (sphere.vertices, sphere.faces)) if visualize_odf: plot_ODF(grid_density=D) mlab = plot.get_mlab() mlab.show() # ===========================-===== # ODF-domain: Sparse reconstruction # ================================= # Minimising the L1 penalized system # # ||Xb - y||_2^2 + lambda ||x||_1 subject to x_i >= 0. # # Here, X is reproducing Q-space kernel, y is the Q-space signal vector # and b are the coefficents. # # Note that the L1 penalization of b forces it to be sparse. This also implies # that the ODF-domain signal is sparse, since the kernels in A (the reproducing
"""Visualize inverse Funk-Radon transform elements with mayavi. """ from sphdif.kernel import kernel_plot, inv_funk_radon_even_kernel from sphdif.plot import get_mlab mlab = get_mlab() mlab.figure(bgcolor=(1, 1, 1), fgcolor=(0, 0, 0)) kernel_plot(inv_funk_radon_even_kernel, N=14) mlab.show()