Mercurial > repos > greg > drmi
comparison dmri.py @ 30:6c1fd6d2c07e draft
Uploaded
author | greg |
---|---|
date | Thu, 30 Nov 2017 09:39:31 -0500 |
parents | 6e7ed2b633dc |
children | 221c1fe8be2c |
comparison
equal
deleted
inserted
replaced
29:da507620bd74 | 30:6c1fd6d2c07e |
---|---|
10 | 10 |
11 import nibabel | 11 import nibabel |
12 | 12 |
13 parser = argparse.ArgumentParser() | 13 parser = argparse.ArgumentParser() |
14 parser.add_argument('--drmi_dataset', dest='drmi_dataset', help='Input dataset') | 14 parser.add_argument('--drmi_dataset', dest='drmi_dataset', help='Input dataset') |
15 parser.add_argument('--drmi_dataset_type', dest='drmi_dataset_type', help='Input dataset type') | |
15 parser.add_argument('--output_nifti1', dest='output_nifti1', help='Output Nifti1 dataset') | 16 parser.add_argument('--output_nifti1', dest='output_nifti1', help='Output Nifti1 dataset') |
16 parser.add_argument('--output_nifti1_extra_files', dest='output_nifti1_extra_files', help='Output Nifti1 extra files') | 17 parser.add_argument('--output_nifti1_extra_files', dest='output_nifti1_extra_files', help='Output Nifti1 extra files') |
17 parser.add_argument('--output_png', dest='output_png', help='Output dataset') | 18 parser.add_argument('--output_png', dest='output_png', help='Output dataset') |
18 | 19 |
19 args = parser.parse_args() | 20 args = parser.parse_args() |
32 if remove_source_dir: | 33 if remove_source_dir: |
33 os.rmdir(source_directory) | 34 os.rmdir(source_directory) |
34 | 35 |
35 # Get input data. | 36 # Get input data. |
36 input_dir = args.drmi_dataset | 37 input_dir = args.drmi_dataset |
37 if input_dir == 'stanford_hardi': | 38 #if input_dir == 'stanford_hardi': |
39 if args.drmi_dataset_type == "dataset": | |
38 fetch_stanford_hardi() | 40 fetch_stanford_hardi() |
39 fdwi = os.path.join(input_dir, 'HARDI150.nii.gz') | 41 fdwi = os.path.join(input_dir, 'HARDI150.nii.gz') |
40 fbval = os.path.join(input_dir, 'HARDI150.bval') | 42 fbval = os.path.join(input_dir, 'HARDI150.bval') |
41 fbvec = os.path.join(input_dir, 'HARDI150.bvec') | 43 fbvec = os.path.join(input_dir, 'HARDI150.bvec') |
42 elif input_dir == 'sherbrooke_3shell': | 44 img = nibabel.load(fdwi) |
43 fetch_sherbrooke_3shell() | 45 else: |
44 fdwi = os.path.join(input_dir, 'HARDI193.nii.gz') | 46 img, gtab, labels = read_stanford_labels() |
45 fbval = os.path.join(input_dir, 'HARDI193.bval') | |
46 fbvec = os.path.join(input_dir, 'HARDI193.bvec') | |
47 # Load the dMRI datasets. | |
48 img = nibabel.load(fdwi) | |
49 data = img.get_data() | 47 data = img.get_data() |
50 # data is a 4D array where the first 3 dimensions are the i, j, | 48 # data is a 4D array where the first 3 dimensions are the i, j, |
51 # k voxel coordinates and the last dimension is the number of | 49 # k voxel coordinates and the last dimension is the number of |
52 # non-weighted (S0s) and diffusion-weighted volumes. | 50 # non-weighted (S0s) and diffusion-weighted volumes. |
53 # Visualize the results using matplotlib. | 51 # Visualize the results using matplotlib. |