Mercurial > repos > greg > drmi
comparison dmri.py @ 14:2b914b6a0c83 draft
Uploaded
| author | greg |
|---|---|
| date | Fri, 03 Nov 2017 14:13:37 -0400 |
| parents | 1467f96db74a |
| children | b9fbc233c9c2 |
comparison
equal
deleted
inserted
replaced
| 13:85b0aa4ab75f | 14:2b914b6a0c83 |
|---|---|
| 2 import argparse | 2 import argparse |
| 3 import os | 3 import os |
| 4 import nibabel | 4 import nibabel |
| 5 import shutil | 5 import shutil |
| 6 | 6 |
| 7 from dipy.core.gradients import gradient_table | |
| 7 from dipy.data import fetch_sherbrooke_3shell | 8 from dipy.data import fetch_sherbrooke_3shell |
| 9 from dipy.io import read_bvals_bvecs | |
| 8 from matplotlib import pyplot | 10 from matplotlib import pyplot |
| 9 | 11 |
| 10 parser = argparse.ArgumentParser() | 12 parser = argparse.ArgumentParser() |
| 11 parser.add_argument('--input', dest='input', help='Input dataset') | 13 parser.add_argument('--input', dest='input', help='Input dataset') |
| 12 parser.add_argument('--output', dest='output', help='Output dataset') | 14 parser.add_argument('--output_gtab', dest='output_gtab', help='Output gradient table dataset') |
| 15 parser.add_argument('--output_png', dest='output_png', help='Output dataset') | |
| 13 | 16 |
| 14 args = parser.parse_args() | 17 args = parser.parse_args() |
| 15 | 18 |
| 16 input_dir = 'sherbrooke_3shell' | 19 input_dir = 'sherbrooke_3shell' |
| 17 # Get input data. | 20 # Get input data. |
| 31 pyplot.subplot(1, 2, 1).set_axis_off() | 34 pyplot.subplot(1, 2, 1).set_axis_off() |
| 32 pyplot.imshow(data[:, :, axial_middle, 0].T, cmap='gray', origin='lower') | 35 pyplot.imshow(data[:, :, axial_middle, 0].T, cmap='gray', origin='lower') |
| 33 pyplot.subplot(1, 2, 2).set_axis_off() | 36 pyplot.subplot(1, 2, 2).set_axis_off() |
| 34 pyplot.imshow(data[:, :, axial_middle, 10].T, cmap='gray', origin='lower') | 37 pyplot.imshow(data[:, :, axial_middle, 10].T, cmap='gray', origin='lower') |
| 35 pyplot.savefig('data.png', bbox_inches='tight') | 38 pyplot.savefig('data.png', bbox_inches='tight') |
| 36 shutil.move('data.png', args.output) | 39 shutil.move('data.png', args.output_png) |
| 40 # Load the b-values and b-vectors. | |
| 41 bvals, bvecs = read_bvals_bvecs(fbval, fbvec) | |
| 42 gtab = gradient_table(bvals, bvecs) | |
| 43 with open(args.output_gtab) as fh: | |
| 44 fh.write(gtab.info) |
