7
7
from nipype import LooseVersion
8
8
9
9
10
- def create_modelfit_workflow (name = 'modelfit' ):
10
+ def create_modelfit_workflow (name = 'modelfit' , f_contrasts = False ):
11
11
"""Create an FSL individual modelfitting workflow
12
12
13
13
Example
@@ -27,19 +27,17 @@ def create_modelfit_workflow(name='modelfit'):
27
27
inputspec.interscan_interval : interscan interval
28
28
inputspec.contrasts : list of contrasts
29
29
inputspec.film_threshold : image threshold for FILM estimation
30
+ inputspec.model_serial_correlations
31
+ inputspec.bases
30
32
31
33
Outputs::
32
34
33
- outputspec.realignment_parameters : realignment parameter files
34
- outputspec.smoothed_files : smoothed functional files
35
- outputspec.outlier_files : list of outliers
36
- outputspec.outlier_stats : statistics of outliers
37
- outputspec.outlier_plots : images of outliers
38
- outputspec.mask_file : binary mask file in reference image space
39
- outputspec.reg_file : registration file that maps reference image to
40
- freesurfer space
41
- outputspec.reg_cost : cost of registration (useful for detecting
42
- misalignment)
35
+ outputspec.copes
36
+ outputspec.varcopes
37
+ outputspec.dof_file
38
+ outputspec.pfiles
39
+ outputspec.zfiles
40
+ outputspec.parameter_estimates
43
41
"""
44
42
45
43
version = 0
@@ -70,31 +68,46 @@ def create_modelfit_workflow(name='modelfit'):
70
68
name = 'modelestimate' ,
71
69
iterfield = ['design_file' , 'in_file' ])
72
70
else :
71
+ if f_contrasts :
72
+ iterfield = ['design_file' , 'in_file' , 'tcon_file' , 'fcon_file' ]
73
+ else :
74
+ iterfield = ['design_file' , 'in_file' , 'tcon_file' ]
73
75
modelestimate = pe .MapNode (interface = fsl .FILMGLS (smooth_autocorr = True ,
74
76
mask_size = 5 ),
75
77
name = 'modelestimate' ,
76
- iterfield = ['design_file' , 'in_file' ,
77
- 'tcon_file' ])
78
+ iterfield = iterfield )
78
79
79
80
if version < 507 :
81
+ if f_contrasts :
82
+ iterfield = ['tcon_file' , 'fcon_file' , 'param_estimates' ,
83
+ 'sigmasquareds' , 'corrections' ,
84
+ 'dof_file' ]
85
+ else :
86
+ iterfield = ['tcon_file' , 'param_estimates' ,
87
+ 'sigmasquareds' , 'corrections' ,
88
+ 'dof_file' ]
80
89
conestimate = pe .MapNode (interface = fsl .ContrastMgr (), name = 'conestimate' ,
81
- iterfield = ['tcon_file' , 'param_estimates' ,
90
+ iterfield = ['tcon_file' , 'fcon_file' , ' param_estimates' ,
82
91
'sigmasquareds' , 'corrections' ,
83
92
'dof_file' ])
93
+
94
+ if f_contrasts :
95
+ iterfield = ['in1' , 'in2' ]
96
+ else :
97
+ iterfield = ['in1' ]
98
+ merge_contrasts = pe .MapNode (interface = util .Merge (2 ), name = 'merge_contrasts' ,
99
+ iterfield = iterfield )
84
100
ztopval = pe .MapNode (interface = fsl .ImageMaths (op_string = '-ztop' ,
85
101
suffix = '_pval' ),
102
+ nested = True ,
86
103
name = 'ztop' ,
87
104
iterfield = ['in_file' ])
88
105
outputspec = pe .Node (util .IdentityInterface (fields = ['copes' , 'varcopes' ,
89
106
'dof_file' , 'pfiles' ,
107
+ 'zfiles' ,
90
108
'parameter_estimates' ]),
91
109
name = 'outputspec' )
92
110
93
- """
94
- Utility function
95
- """
96
-
97
- pop_lambda = lambda x : x [0 ]
98
111
99
112
"""
100
113
Setup the connections
@@ -112,25 +125,32 @@ def create_modelfit_workflow(name='modelfit'):
112
125
(level1design , modelgen , [('fsf_files' , 'fsf_file' ),
113
126
('ev_files' , 'ev_files' )]),
114
127
(modelgen , modelestimate , [('design_file' , 'design_file' )]),
128
+
129
+ (merge_contrasts , ztopval ,[('out' , 'in_file' )]),
115
130
(ztopval , outputspec , [('out_file' , 'pfiles' )]),
131
+ (merge_contrasts , outputspec ,[('out' , 'zfiles' )]),
116
132
(modelestimate , outputspec , [('param_estimates' , 'parameter_estimates' ),
117
133
('dof_file' , 'dof_file' )]),
118
134
])
119
135
if version < 507 :
120
136
modelfit .connect ([
121
- (modelgen , conestimate , [('con_file' , 'tcon_file' )]),
137
+ (modelgen , conestimate , [('con_file' , 'tcon_file' ),
138
+ ('fcon_file' , 'fcon_file' )]),
122
139
(modelestimate , conestimate , [('param_estimates' , 'param_estimates' ),
123
140
('sigmasquareds' , 'sigmasquareds' ),
124
141
('corrections' , 'corrections' ),
125
142
('dof_file' , 'dof_file' )]),
126
- (conestimate , ztopval , [(('zstats' , pop_lambda ), 'in_file' )]),
143
+ (conestimate , merge_contrasts , [('zstats' , 'in1' ),
144
+ ('zfstats' , 'in2' )]),
127
145
(conestimate , outputspec , [('copes' , 'copes' ),
128
146
('varcopes' , 'varcopes' )]),
129
147
])
130
148
else :
131
149
modelfit .connect ([
132
- (modelgen , modelestimate , [('con_file' , 'tcon_file' )]),
133
- (modelestimate , ztopval , [(('zstats' , pop_lambda ), 'in_file' )]),
150
+ (modelgen , modelestimate , [('con_file' , 'tcon_file' ),
151
+ ('fcon_file' , 'fcon_file' )]),
152
+ (modelestimate , merge_contrasts , [('zstats' , 'in1' ),
153
+ ('zfstats' , 'in2' )]),
134
154
(modelestimate , outputspec , [('copes' , 'copes' ),
135
155
('varcopes' , 'varcopes' )]),
136
156
])
0 commit comments