def two_fiber_signal(bvals, bvecs, angle, w=[0.5, 0.5], SNR=0): R0 = rotation_around_axis([0, 1, 0], 0) R1 = rotation_around_axis([0, 1, 0], np.deg2rad(angle)) E = w[0] * single_tensor(gradients=bvecs, bvals=bvals, S0=1, evecs=R0, snr=SNR) E += w[1] * single_tensor(gradients=bvecs, bvals=bvals, S0=1, evecs=R1, snr=SNR) return E
for k, gamma in enumerate(angles): print "Angle:", np.rad2deg(gamma) # Gamma is the angle separating fibres # ================ # Set up test data # ================ # b is tau * |q|^2 in s/mm^2 # If b is too low, the signal does not attenuate enough to measure. # Too high, the signal to noise ratio increases. angles = np.array([gamma / 2., -gamma / 2]) R0 = rotation_around_axis([0, 1, 0], 0) R1 = rotation_around_axis([0, 1, 0], angles[0] - angles[1]) # ================ # Q-Space Sampling # ================ # Note: We sample our signal in Q-space on the low-order quadrature points # here, but wwe could just as well have used other, random points on the # sphere. E = w[0] * single_tensor(gradients=xyz, bvals=b, S0=1, rotation=R0, SNR=SNR) E += w[1] * single_tensor(gradients=xyz, bvals=b, S0=1, rotation=R1, SNR=SNR) print "Signal mean:", E.mean()