def kernel_plot(kernel, grid_density=150, N=14): theta_grid = np.linspace(0, np.pi, grid_density) phi_grid = np.linspace(0, 2 * np.pi, grid_density) kernel_vals = kernel(sphere.cos_inc_angle(0, 0, theta_grid[:, None], phi_grid), N) plot.surf_grid_3D(kernel_vals, theta_grid, phi_grid, scale_radius=True)
rotation = np.eye(3) out_shape = r.shape[:r.ndim - 1] R = np.asarray(rotation) Di = np.linalg.inv(R.dot(np.diag(evals)).dot(R.T)) r = r.reshape(-1, 3) P = np.zeros(len(r)) for (i, u) in enumerate(r): P[i] = u.T.dot(Di).dot(u)**(3 / 2) return (1 / (4 * np.pi * np.prod(evals)**(1/2) * P)).reshape(out_shape) if __name__ == "__main__": import sphere, coord, plot npts = 150 theta, phi = sphere.mesh(npts) xyz = np.dstack(coord.sph2car(theta, phi)) ODF = single_tensor_ODF(xyz, rotation=None) signal = single_tensor(gradients=xyz, bvals=1000 * np.ones(npts * npts), rotation=None, S0=1, SNR=None) plot.surf_grid_3D(ODF, theta, phi, scale_radius=True) plot.show() plot.surf_grid_3D(signal, theta, phi, scale_radius=True) plot.show()