本文整理汇总了Python中dipy.reconst.dti.TensorModel.bvec[idx]方法的典型用法代码示例。如果您正苦于以下问题:Python TensorModel.bvec[idx]方法的具体用法?Python TensorModel.bvec[idx]怎么用?Python TensorModel.bvec[idx]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dipy.reconst.dti.TensorModel
的用法示例。
在下文中一共展示了TensorModel.bvec[idx]方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1:
# 需要导入模块: from dipy.reconst.dti import TensorModel [as 别名]
# 或者: from dipy.reconst.dti.TensorModel import bvec[idx] [as 别名]
mask_noise[..., :mask_noise.shape[-1]//2] = 1
mask_noise = ~mask_noise
mask_noise_img = nib.Nifti1Image(mask_noise.astype(np.uint8), affine)
nib.save(mask_noise_img, 'mask_noise.nii.gz')
noise_std = np.std(data[mask_noise, :])
"""We can now compute the SNR for each dwi using the formula above. Let's find
the position of the gradient direction that lies the closest to the X, Y and Z
axis.
"""
# Exclude null bvecs from the search
idx = np.sum(tenmodel.bvec, axis=-1) == 0
tenmodel.bvec[idx] = np.inf
axis_X = np.argmin(np.sum((tenmodel.bvec-np.array([1, 0, 0]))**2, axis=-1))
axis_Y = np.argmin(np.sum((tenmodel.bvec-np.array([0, 1, 0]))**2, axis=-1))
axis_Z = np.argmin(np.sum((tenmodel.bvec-np.array([0, 0, 1]))**2, axis=-1))
"""Now that we have the closest b-vectors to each of the cartesian axis,
let's compute their respective SNR and compare them to a b0 image's SNR.
"""
for direction in [0, axis_X, axis_Y, axis_Z]:
SNR = mean_signal[direction]/noise_std
print("SNR for direction", direction, "is :", SNR)
"""SNR for direction 0 is : ``39.7490994429``"""
"""SNR for direction 58 is : ``4.84444879426``"""