Skip to content

Commit 5391565

Browse files
committed
Fixes and improvementsto standard FSL pipelines
1 parent f95bc73 commit 5391565

File tree

2 files changed

+44
-23
lines changed

2 files changed

+44
-23
lines changed

nipype/workflows/fmri/fsl/estimate.py

Lines changed: 43 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from nipype import LooseVersion
88

99

10-
def create_modelfit_workflow(name='modelfit'):
10+
def create_modelfit_workflow(name='modelfit', f_contrasts=False):
1111
"""Create an FSL individual modelfitting workflow
1212
1313
Example
@@ -27,19 +27,17 @@ def create_modelfit_workflow(name='modelfit'):
2727
inputspec.interscan_interval : interscan interval
2828
inputspec.contrasts : list of contrasts
2929
inputspec.film_threshold : image threshold for FILM estimation
30+
inputspec.model_serial_correlations
31+
inputspec.bases
3032
3133
Outputs::
3234
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
4341
"""
4442

4543
version = 0
@@ -70,31 +68,46 @@ def create_modelfit_workflow(name='modelfit'):
7068
name='modelestimate',
7169
iterfield=['design_file', 'in_file'])
7270
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']
7375
modelestimate = pe.MapNode(interface=fsl.FILMGLS(smooth_autocorr=True,
7476
mask_size=5),
7577
name='modelestimate',
76-
iterfield=['design_file', 'in_file',
77-
'tcon_file'])
78+
iterfield=iterfield)
7879

7980
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']
8089
conestimate = pe.MapNode(interface=fsl.ContrastMgr(), name='conestimate',
81-
iterfield=['tcon_file', 'param_estimates',
90+
iterfield=['tcon_file', 'fcon_file', 'param_estimates',
8291
'sigmasquareds', 'corrections',
8392
'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)
84100
ztopval = pe.MapNode(interface=fsl.ImageMaths(op_string='-ztop',
85101
suffix='_pval'),
102+
nested=True,
86103
name='ztop',
87104
iterfield=['in_file'])
88105
outputspec = pe.Node(util.IdentityInterface(fields=['copes', 'varcopes',
89106
'dof_file', 'pfiles',
107+
'zfiles',
90108
'parameter_estimates']),
91109
name='outputspec')
92110

93-
"""
94-
Utility function
95-
"""
96-
97-
pop_lambda = lambda x: x[0]
98111

99112
"""
100113
Setup the connections
@@ -112,25 +125,32 @@ def create_modelfit_workflow(name='modelfit'):
112125
(level1design, modelgen, [('fsf_files', 'fsf_file'),
113126
('ev_files', 'ev_files')]),
114127
(modelgen, modelestimate, [('design_file', 'design_file')]),
128+
129+
(merge_contrasts, ztopval,[('out', 'in_file')]),
115130
(ztopval, outputspec, [('out_file', 'pfiles')]),
131+
(merge_contrasts, outputspec,[('out', 'zfiles')]),
116132
(modelestimate, outputspec, [('param_estimates', 'parameter_estimates'),
117133
('dof_file', 'dof_file')]),
118134
])
119135
if version < 507:
120136
modelfit.connect([
121-
(modelgen, conestimate, [('con_file', 'tcon_file')]),
137+
(modelgen, conestimate, [('con_file', 'tcon_file'),
138+
('fcon_file', 'fcon_file')]),
122139
(modelestimate, conestimate, [('param_estimates', 'param_estimates'),
123140
('sigmasquareds', 'sigmasquareds'),
124141
('corrections', 'corrections'),
125142
('dof_file', 'dof_file')]),
126-
(conestimate, ztopval, [(('zstats', pop_lambda), 'in_file')]),
143+
(conestimate, merge_contrasts, [('zstats', 'in1'),
144+
('zfstats', 'in2')]),
127145
(conestimate, outputspec, [('copes', 'copes'),
128146
('varcopes', 'varcopes')]),
129147
])
130148
else:
131149
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')]),
134154
(modelestimate, outputspec, [('copes', 'copes'),
135155
('varcopes', 'varcopes')]),
136156
])

nipype/workflows/fmri/fsl/preprocess.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,6 +1198,7 @@ def create_reg_workflow(name='registration'):
11981198

11991199
warpall = pe.MapNode(fsl.ApplyWarp(interp='spline'),
12001200
iterfield=['in_file'],
1201+
nested=True,
12011202
name='warpall')
12021203
register.connect(inputnode, 'source_files', warpall, 'in_file')
12031204
register.connect(mean2anatbbr, 'out_matrix_file', warpall, 'premat')

0 commit comments

Comments
 (0)