Skip to content

Commit eaacfbb

Browse files
author
David Ellis
committed
FIX: freesurfer workflow fixes.
1 parent df3f9b3 commit eaacfbb

File tree

5 files changed

+51
-19
lines changed

5 files changed

+51
-19
lines changed

nipype/interfaces/freesurfer/utils.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2416,6 +2416,8 @@ class ParcellationStatsInputSpec(FSTraitedSpec):
24162416
desc="Input file must be <subject_id>/mri/aseg.presurf.mgz")
24172417
ribbon = File(mandatory=True, exists=True,
24182418
desc="Input file must be <subject_id>/mri/ribbon.mgz")
2419+
cortex_label = File(exists=True,
2420+
desc="implicit input file {hemi}.cortex.label")
24192421
# optional
24202422
surface = traits.String(position=-1, argstr="%s", mandatory=False,
24212423
desc="Input surface (e.g. 'white')")
@@ -2437,7 +2439,7 @@ class ParcellationStatsInputSpec(FSTraitedSpec):
24372439
desc="If running as a node, set this to True." +
24382440
"This will copy the input files to the node " +
24392441
"directory.")
2440-
th3 = traits.Bool(argstr="-th3",
2442+
th3 = traits.Bool(argstr="-th3", requires=["cortex_label"],
24412443
desc="turns on new vertex-wise volume calc for mris_anat_stats")
24422444

24432445

@@ -2497,6 +2499,10 @@ def run(self, **inputs):
24972499
copy2subjdir(self, self.inputs.ribbon, 'mri', 'ribbon.mgz')
24982500
copy2subjdir(self, self.inputs.thickness, 'surf',
24992501
'{0}.thickness'.format(self.inputs.hemisphere))
2502+
if isdefined(self.inputs.cortex_label):
2503+
copy2subjdir(
2504+
self, self.inputs.cortex_label, 'label',
2505+
'{0}.cortex.label'.format(self.inputs.hemisphere))
25002506
createoutputdirs(self._list_outputs())
25012507
return super(ParcellationStats, self).run(**inputs)
25022508

nipype/workflows/smri/freesurfer/autorecon2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ def create_AutoRecon2(name="AutoRecon2", longitudinal=False,
637637

638638
hemi_wf.connect([(extract_main_component, hemi_outputspec, [('out_file', 'orig_nofix')]),
639639
(inflate1, hemi_outputspec, [('out_file', 'inflated_nofix')]),
640-
(smooth1, hemi_outputspec, [('out_file', 'smoothwm_nofix')]),
640+
(smooth1, hemi_outputspec, [('surface', 'smoothwm_nofix')]),
641641
(qsphere, hemi_outputspec, [('out_file', 'qsphere_nofix')]),
642642
(remove_intersection, hemi_outputspec, [('out_file', 'orig')]),
643643
(make_surfaces, hemi_outputspec, [('out_white', 'white'),

nipype/workflows/smri/freesurfer/autorecon3.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ def create_AutoRecon3(name="AutoRecon3", qcache=False, plugin_args=None,
352352
('brainmask', 'brainmask'),
353353
('aseg_presurf', 'aseg'),
354354
('cortex_label', 'in_cortex'),
355+
('cortex_label', 'cortex_label'),
355356
('lh_pial', 'lh_pial'),
356357
('rh_pial', 'rh_pial'),
357358
('thickness', 'thickness'),
@@ -378,6 +379,7 @@ def create_AutoRecon3(name="AutoRecon3", qcache=False, plugin_args=None,
378379
('transform', 'transform'),
379380
('brainmask', 'brainmask'),
380381
('aseg_presurf', 'aseg'),
382+
('cortex_label', 'cortex_label'),
381383
('cortex_label', 'in_cortex'),
382384
('lh_pial', 'lh_pial'),
383385
('rh_pial', 'rh_pial'),
@@ -415,6 +417,7 @@ def create_AutoRecon3(name="AutoRecon3", qcache=False, plugin_args=None,
415417
('transform', 'transform'),
416418
('brainmask', 'brainmask'),
417419
('aseg_presurf', 'aseg'),
420+
('cortex_label', 'cortex_label'),
418421
('cortex_label', 'in_cortex'),
419422
('lh_pial', 'lh_pial'),
420423
('rh_pial', 'rh_pial'),
@@ -453,6 +456,7 @@ def create_AutoRecon3(name="AutoRecon3", qcache=False, plugin_args=None,
453456
('transform', 'transform'),
454457
('brainmask', 'brainmask'),
455458
('aseg_presurf', 'aseg'),
459+
('cortex_label', 'cortex_label'),
456460
('cortex_label', 'in_cortex'),
457461
('lh_pial', 'lh_pial'),
458462
('rh_pial', 'rh_pial'),
@@ -701,7 +705,7 @@ def create_AutoRecon3(name="AutoRecon3", qcache=False, plugin_args=None,
701705
])
702706

703707
# add brodman area maps to the workflow
704-
ba_WF = create_ba_maps_wf(th3=th3)
708+
ba_WF, ba_outputs = create_ba_maps_wf(th3=th3)
705709

706710
ar3_wf.connect([(ar3_lh_wf1, ba_WF, [('outputspec.sphere_reg', 'inputspec.lh_sphere_reg'),
707711
('outputspec.thickness_pial', 'inputspec.lh_thickness'),
@@ -719,6 +723,8 @@ def create_AutoRecon3(name="AutoRecon3", qcache=False, plugin_args=None,
719723
('wm', 'inputspec.wm'),
720724
('lh_orig', 'inputspec.lh_orig'),
721725
('rh_orig', 'inputspec.rh_orig'),
726+
('lh_cortex_label', 'inputspec.lh_cortex_label'),
727+
('rh_cortex_label', 'inputspec.rh_cortex_label'),
722728
('src_subject_dir', 'inputspec.src_subject_dir'),
723729
('src_subject_id', 'inputspec.src_subject_id'),
724730
('color_table', 'inputspec.color_table'),
@@ -876,6 +882,9 @@ def create_AutoRecon3(name="AutoRecon3", qcache=False, plugin_args=None,
876882
ar3_outputs.append(hemi + output)
877883
if qcache:
878884
ar3_outputs.extend(qcache_outputs)
885+
886+
ar3_outputs.extend(ba_outputs)
887+
879888
outputspec = pe.Node(IdentityInterface(fields=ar3_outputs),
880889
name="outputspec")
881890

@@ -902,6 +911,9 @@ def create_AutoRecon3(name="AutoRecon3", qcache=False, plugin_args=None,
902911
ar3_wf.connect([(lhwf, outputspec, [('outputspec.' + output, 'lh_' + output)]),
903912
(rhwf, outputspec, [('outputspec.' + output, 'rh_' + output)])])
904913

914+
for output in ba_outputs:
915+
ar3_wf.connect([(ba_WF, outputspec, [('outputspec.' + output, output)])])
916+
905917
if qcache:
906918
for output in qcache_outputs:
907919
ar3_wf.connect([(qcache_wf, outputspec, [('outputspec.' + output, output)])])

nipype/workflows/smri/freesurfer/ba_maps.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ def create_ba_maps_wf(name="Brodmann_Area_Maps", th3=True):
1919
'transform',
2020
'lh_thickness',
2121
'rh_thickness',
22+
'lh_cortex_label',
23+
'rh_cortex_label',
2224
'brainmask',
2325
'aseg',
2426
'ribbon',
@@ -31,15 +33,17 @@ def create_ba_maps_wf(name="Brodmann_Area_Maps", th3=True):
3133
name="inputspec")
3234

3335
ba_WF = pe.Workflow(name=name)
34-
35-
outputSpec = pe.Node(IdentityInterface(fields=['lh_table',
36-
'lh_color',
37-
'lh_thresh_table',
38-
'lh_thresh_color',
39-
'rh_table',
40-
'rh_color',
41-
'rh_thresh_table',
42-
'rh_thresh_color']),
36+
37+
ba_outputs = ['lh_table',
38+
'lh_color',
39+
'lh_thresh_table',
40+
'lh_thresh_color',
41+
'rh_table',
42+
'rh_color',
43+
'rh_thresh_table',
44+
'rh_thresh_color']
45+
46+
outputSpec = pe.Node(IdentityInterface(fields=ba_outputs),
4347
name="outputspec")
4448

4549
labels = ["BA1", "BA2", "BA3a", "BA3b", "BA4a", "BA4p", "BA6",
@@ -126,6 +130,8 @@ def create_ba_maps_wf(name="Brodmann_Area_Maps", th3=True):
126130
[('out_file', 'in_annotation')]),
127131
(inputspec, stats_node, [('{0}_thickness'.format(hemisphere),
128132
'thickness'),
133+
('{0}_cortex_label'.format(hemisphere),
134+
'cortex_label'),
129135
('lh_white', 'lh_white'),
130136
('rh_white', 'rh_white'),
131137
('lh_pial', 'lh_pial'),
@@ -137,4 +143,4 @@ def create_ba_maps_wf(name="Brodmann_Area_Maps", th3=True):
137143
('ribbon', 'ribbon')])])
138144

139145

140-
return ba_WF
146+
return ba_WF, ba_outputs

nipype/workflows/smri/freesurfer/recon.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -301,15 +301,15 @@ def getDSTransformPath(subjects_dir, subject_id):
301301
('lh_white', 'surf.@lh_white'),
302302
('lh_curv', 'surf.@lh_curv'),
303303
('lh_area', 'surf.@lh_area'),
304-
('lh_cortex', 'surf.@lh_cortex'),
304+
('lh_cortex', 'label.@lh_cortex'),
305305
('lh_smoothwm', 'surf.@lh_smoothwm'),
306306
('lh_sulc', 'surf.@lh_sulc'),
307307
('lh_inflated', 'surf.@lh_inflated'),
308308
('lh_white_H', 'surf.@lh_white_H'),
309309
('lh_white_K', 'surf.@lh_white_K'),
310310
('lh_inflated_H', 'surf.@lh_inflated_H'),
311311
('lh_inflated_K', 'surf.@lh_inflated_K'),
312-
('lh_curv_stats', 'surf.@lh_curv_stats'),
312+
('lh_curv_stats', 'stats.@lh_curv_stats'),
313313
('rh_orig_nofix', 'surf.@rh_orig_nofix'),
314314
('rh_orig', 'surf.@rh_orig'),
315315
('rh_smoothwm_nofix', 'surf.@rh_smoothwm_nofix'),
@@ -318,15 +318,15 @@ def getDSTransformPath(subjects_dir, subject_id):
318318
('rh_white', 'surf.@rh_white'),
319319
('rh_curv', 'surf.@rh_curv'),
320320
('rh_area', 'surf.@rh_area'),
321-
('rh_cortex', 'surf.@rh_cortex'),
321+
('rh_cortex', 'label.@rh_cortex'),
322322
('rh_smoothwm', 'surf.@rh_smoothwm'),
323323
('rh_sulc', 'surf.@rh_sulc'),
324324
('rh_inflated', 'surf.@rh_inflated'),
325325
('rh_white_H', 'surf.@rh_white_H'),
326326
('rh_white_K', 'surf.@rh_white_K'),
327327
('rh_inflated_H', 'surf.@rh_inflated_H'),
328328
('rh_inflated_K', 'surf.@rh_inflated_K'),
329-
('rh_curv_stats', 'surf.@rh_curv_stats'),
329+
('rh_curv_stats', 'stats.@rh_curv_stats'),
330330
('lh_aparc_annot_ctab', 'label.@aparc_annot_ctab'),
331331
('aseg', 'mri.@aseg'),
332332
('wmparc', 'mri.@wmparc'),
@@ -346,8 +346,8 @@ def getDSTransformPath(subjects_dir, subject_id):
346346
('rh_jacobian_white', 'surf.@rh_jacobian_white'),
347347
('lh_avg_curv', 'surf.@lh_avg_curv'),
348348
('rh_avg_curv', 'surf.@rh_avg_curv'),
349-
('lh_aparc_annot', 'surf.@lh_aparc_annot'),
350-
('rh_aparc_annot', 'surf.@rh_aparc_annot'),
349+
('lh_aparc_annot', 'label.@lh_aparc_annot'),
350+
('rh_aparc_annot', 'label.@rh_aparc_annot'),
351351
('lh_area_pial', 'surf.@lh_area_pial'),
352352
('rh_area_pial', 'surf.@rh_area_pial'),
353353
('lh_curv_pial', 'surf.@lh_curv_pial'),
@@ -394,6 +394,14 @@ def getDSTransformPath(subjects_dir, subject_id):
394394
('rh_wg_pct_stats', 'stats.@rh_wg_pct_stats'),
395395
('lh_pctsurfcon_log', 'log.@lh_pctsurfcon_log'),
396396
('rh_pctsurfcon_log', 'log.@rh_pctsurfcon_log'),
397+
('lh_table', 'label.@lh_table'),
398+
('lh_color', 'label.@lh_color'),
399+
('lh_thresh_table', 'label.@lh_thresh_table'),
400+
('lh_thresh_color', 'label.@lh_thresh_color'),
401+
('rh_table', 'label.@rh_table'),
402+
('rh_color', 'label.@rh_color'),
403+
('rh_thresh_table', 'label.@rh_thresh_table'),
404+
('rh_thresh_color', 'label.@rh_thresh_color')
397405
]),
398406
])
399407

0 commit comments

Comments
 (0)