-
Notifications
You must be signed in to change notification settings - Fork 2
/
full.py
114 lines (106 loc) · 3 KB
/
full.py
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
"""
"""
import nipype.pipeline.engine as pe
from nipype.interfaces import utility
from mrproc.pipelines.diffusion import create_diffusion_pipeline
from sctva.pipelines.streamlines_selection import (
create_streamline_selection_from_functional_contrast_pipeline,
)
# Constants
N_TRACKS = 5000000
MIN_LENGTH = 10 # mm
MAX_LENGTH = 300 # mm
RADIUS = 5 # selection sphere radius mm
def create_study_pipeline(radius=RADIUS):
"""
:return:
"""
# Nodes composing the pipeline
# Input and Output Nodes
inputnode = pe.Node(
utility.IdentityInterface(
fields=[
"diffusion_volume",
"bvals",
"bvecs",
"t1_volume",
"func_contrast_volume",
],
mandatory_inputs=False,
),
name="inputnode",
)
diffusion_pipeline = create_diffusion_pipeline()
apply_rigid_transform = create_apply_linear_transform_node()
tva_streamlines_selection = create_streamline_selection_from_functional_contrast_pipeline(
radius
)
outputnode = pe.Node(
utility.IdentityInterface(
fields=[
"corrected_diffusion_volume",
"wm_fod",
"tractogram",
"peaks",
"sub-tractograms",
],
mandatory_inputs=False,
),
name="outputnode",
)
study_pipeline = pe.Workflow(name="sctva_pipeline")
# Pipeline structure
study_pipeline.connect(
[
(
inputnode,
diffusion_pipeline,
[
("diffusion_volume", "inputnode.diffusion_volume"),
("bvals", "inputnode.bvals"),
("bvecs", "inputnode.bvecs"),
("t1_volume", "inputnode.t1_volume"),
],
)
]
)
study_pipeline.connect(
inputnode, "func_contrast_volume", apply_rigid_transform, "in_file"
)
study_pipeline.connect(
diffusion_pipeline,
"outputnode.diffusion_to_t1_transform",
apply_rigid_transform,
"transform",
)
study_pipeline.connect(
apply_rigid_transform,
"out_file",
tva_streamlines_selection,
"inputnode.functional_contrast",
)
study_pipeline.connect(
diffusion_pipeline,
"outputnode.tractogram",
tva_streamlines_selection,
"inputnode.tractogram",
)
study_pipeline.connect(
tva_streamlines_selection, "outputnode.peaks", outputnode, "peaks"
)
study_pipeline.connect(
tva_streamlines_selection,
"outputnode.tractograms",
outputnode,
"sub-tractograms",
)
study_pipeline.connect(
diffusion_pipeline,
"outputnode.corrected_diffusion_volume",
outputnode,
"corrected_diffusion_volume",
)
study_pipeline.connect(
diffusion_pipeline, "outputnode.wm_fod", outputnode, "wm_fod"
)
return study_pipeline