forked from childmindresearch/quick-viz
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_nii_3dheatmap.py
More file actions
34 lines (22 loc) · 862 Bytes
/
plot_nii_3dheatmap.py
File metadata and controls
34 lines (22 loc) · 862 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env python
"""
Example usage:
python plot_nii_3dheatmap.py /path/to/my/data.nii.gz /path/to/my/image.png
"""
from argparse import ArgumentParser
from nilearn.plotting import plot_img
import matplotlib.pyplot as plt
import nibabel as nib
def main():
parser = ArgumentParser("Produce a 3D intensity view of the brain")
parser.add_argument('in_nii', help="3D Nifti data to visualize")
parser.add_argument('plot_loc', help="Target location for plot")
# TODO:
# - accept function option, to turn 4D data into 3D (e.g., mean)
# - accept coordinates option to ensure reproduc- and customiz-ability
# - support contrasting images
results = parser.parse_args()
im = nib.load(results.in_nii)
plot_img(im, black_bg=True, output_file=results.plot_loc, threshold='auto')
if __name__ == "__main__":
main()