0
|
1 #!/usr/bin/env python
|
|
2 import argparse
|
3
|
3 import shutil
|
|
4
|
0
|
5 import dipy.core.optimize as opt
|
|
6 import dipy.tracking.life as life
|
3
|
7 from dipy.data import fetch_stanford_t1, read_stanford_labels, read_stanford_t1
|
|
8 from dipy.viz import fvtk
|
0
|
9 from dipy.viz.colormap import line_colors
|
3
|
10
|
|
11 import matplotlib
|
|
12 import matplotlib.pyplot as plt
|
|
13
|
0
|
14 from mpl_toolkits.axes_grid1 import AxesGrid
|
3
|
15
|
|
16 import nibabel as nib
|
|
17
|
|
18 import numpy as np
|
0
|
19
|
|
20 parser = argparse.ArgumentParser()
|
3
|
21 parser.add_argument('--input', dest='input', help='Track Visualization Header dataset')
|
0
|
22 parser.add_argument('--output_life_candidates', dest='output_life_candidates', help='Output life candidates')
|
|
23
|
|
24 args = parser.parse_args()
|
|
25
|
1
|
26 # We'll need to know where the corpus callosum is from these variables.
|
|
27 hardi_img, gtab, labels_img = read_stanford_labels()
|
|
28 labels = labels_img.get_data()
|
|
29 cc_slice = labels == 2
|
|
30 fetch_stanford_t1()
|
|
31 t1 = read_stanford_t1()
|
|
32 t1_data = t1.get_data()
|
|
33 data = hardi_img.get_data()
|
0
|
34
|
|
35 # Read the candidates from file in voxel space:
|
3
|
36 candidate_sl = [s[0] for s in nib.trackvis.read(args.input, points_space='voxel')[0]]
|
0
|
37 # Visualize the initial candidate group of streamlines
|
|
38 # in 3D, relative to the anatomical structure of this brain.
|
|
39 candidate_streamlines_actor = fvtk.streamtube(candidate_sl, line_colors(candidate_sl))
|
|
40 cc_ROI_actor = fvtk.contour(cc_slice, levels=[1], colors=[(1., 1., 0.)], opacities=[1.])
|
|
41 vol_actor = fvtk.slicer(t1_data)
|
|
42 vol_actor.display(40, None, None)
|
|
43 vol_actor2 = vol_actor.copy()
|
|
44 vol_actor2.display(None, None, 35)
|
|
45 # Add display objects to canvas.
|
|
46 ren = fvtk.ren()
|
|
47 fvtk.add(ren, candidate_streamlines_actor)
|
|
48 fvtk.add(ren, cc_ROI_actor)
|
|
49 fvtk.add(ren, vol_actor)
|
|
50 fvtk.add(ren, vol_actor2)
|
3
|
51 fvtk.record(ren, n_frames=1, out_path="life_candidates.png", size=(800, 800))
|
|
52 shutil.move("life_candidates.png", args.output_life_candidates)
|