comparison dmri.py @ 18:f15d37b5efea draft

Uploaded
author greg
date Fri, 03 Nov 2017 14:45:44 -0400
parents b9fbc233c9c2
children 3938c3299e7b
comparison
equal deleted inserted replaced
17:947059a3876d 18:f15d37b5efea
9 from dipy.io import read_bvals_bvecs 9 from dipy.io import read_bvals_bvecs
10 from matplotlib import pyplot 10 from matplotlib import pyplot
11 11
12 parser = argparse.ArgumentParser() 12 parser = argparse.ArgumentParser()
13 parser.add_argument('--input', dest='input', help='Input dataset') 13 parser.add_argument('--input', dest='input', help='Input dataset')
14 parser.add_argument('--output_gtab', dest='output_gtab', help='Output gradient table dataset') 14 parser.add_argument('--output_nifti1', dest='output_nifti1', help='Output Nifti1 dataset')
15 parser.add_argument('--output_png', dest='output_png', help='Output dataset') 15 parser.add_argument('--output_png', dest='output_png', help='Output dataset')
16 16
17 args = parser.parse_args() 17 args = parser.parse_args()
18 18
19 input_dir = 'sherbrooke_3shell' 19 input_dir = 'sherbrooke_3shell'
38 pyplot.savefig('data.png', bbox_inches='tight') 38 pyplot.savefig('data.png', bbox_inches='tight')
39 shutil.move('data.png', args.output_png) 39 shutil.move('data.png', args.output_png)
40 # Load the b-values and b-vectors. 40 # Load the b-values and b-vectors.
41 bvals, bvecs = read_bvals_bvecs(fbval, fbvec) 41 bvals, bvecs = read_bvals_bvecs(fbval, fbvec)
42 gtab = gradient_table(bvals, bvecs) 42 gtab = gradient_table(bvals, bvecs)
43 with open(args.output_gtab, 'w') as fh: 43 # gtab can be used to tell what part of the data is the S0
44 fh.write(gtab.info) 44 # volumes (volumes which correspond to b-values of 0).
45 S0s = data[:, :, :, gtab.b0s_mask]
46 # Save this in a new Nifti file.
47 nib.save(nib.Nifti1Image(S0s, img.affine), 'HARDI193_S0.nii')
48 shutil.move('HARDI193_S0.nii', args.output_nifti1)