def load_bval_bvec_dti(self, fbval, fbvec, dti_file, dti_file_out):
"""
Takes bval and bvec files and produces a structure in dipy format
**Positional Arguments:**
"""
# Load Data
img = nb.load(dti_file)
data = img.get_data()
bvals, bvecs = read_bvals_bvecs(fbval, fbvec)
# Get rid of spurrious scans
idx = np.where((bvecs[:, 0] == 100) & (bvecs[:, 1] == 100) &
(bvecs[:, 2] == 100))
bvecs = np.delete(bvecs, idx, axis=0)
bvals = np.delete(bvals, idx, axis=0)
data = np.delete(data, idx, axis=3)
# Save corrected DTI volume
dti_new = nb.Nifti1Image(data, affine=img.get_affine(),
header=img.get_header())
dti_new.update_header()
nb.save(dti_new, dti_file_out)
gtab = gradient_table(bvals, bvecs, atol=0.01)
print(gtab.info)
return gtab
评论列表
文章目录