Mercurial > repos > greg > drmi
comparison dmri.py @ 11:173c5c07b2f9 draft
Uploaded
author | greg |
---|---|
date | Fri, 03 Nov 2017 13:51:40 -0400 |
parents | 5014ba48e15e |
children | 1467f96db74a |
comparison
equal
deleted
inserted
replaced
10:5014ba48e15e | 11:173c5c07b2f9 |
---|---|
3 import os | 3 import os |
4 import nibabel | 4 import nibabel |
5 import shutil | 5 import shutil |
6 | 6 |
7 from dipy.data import fetch_sherbrooke_3shell | 7 from dipy.data import fetch_sherbrooke_3shell |
8 from matplotlib import pyplot | |
8 | 9 |
9 parser = argparse.ArgumentParser() | 10 parser = argparse.ArgumentParser() |
10 parser.add_argument('--input', dest='input', help='Input dataset') | 11 parser.add_argument('--input', dest='input', help='Input dataset') |
11 parser.add_argument('--output', dest='output', help='Output dataset') | 12 parser.add_argument('--output', dest='output', help='Output dataset') |
12 | 13 |
24 # data is a 4D array where the first 3 dimensions are the i, j, | 25 # data is a 4D array where the first 3 dimensions are the i, j, |
25 # k voxel coordinates and the last dimension is the number of | 26 # k voxel coordinates and the last dimension is the number of |
26 # non-weighted (S0s) and diffusion-weighted volumes. | 27 # non-weighted (S0s) and diffusion-weighted volumes. |
27 # Visualize the results using matplotlib. | 28 # Visualize the results using matplotlib. |
28 axial_middle = data.shape[2] // 2 | 29 axial_middle = data.shape[2] // 2 |
29 plt.figure('Showing the datasets') | 30 pyplot.figure('Showing the datasets') |
30 plt.subplot(1, 2, 1).set_axis_off() | 31 pyplot.subplot(1, 2, 1).set_axis_off() |
31 plt.imshow(data[:, :, axial_middle, 0].T, cmap='gray', origin='lower') | 32 pyplot.imshow(data[:, :, axial_middle, 0].T, cmap='gray', origin='lower') |
32 plt.subplot(1, 2, 2).set_axis_off() | 33 pyplot.subplot(1, 2, 2).set_axis_off() |
33 plt.imshow(data[:, :, axial_middle, 10].T, cmap='gray', origin='lower') | 34 pyplot.imshow(data[:, :, axial_middle, 10].T, cmap='gray', origin='lower') |
34 plt.show() | 35 pyplot.show() |
35 plt.savefig(args.output, bbox_inches='tight') | 36 pyplot.savefig(args.output, bbox_inches='tight') |