Skip to content

Commit cd3d917

Browse files
committed
Refine step checking for partial directives
1 parent fcf16d6 commit cd3d917

File tree

1 file changed

+104
-91
lines changed

1 file changed

+104
-91
lines changed

nipype/interfaces/freesurfer/preprocess.py

Lines changed: 104 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,7 @@ class ReconAll(CommandLine):
778778
'mri/brainmask.mgz'], []),
779779
]
780780
if Info.looseversion() < LooseVersion("6.0.0"):
781-
_autorecon2_steps = [
781+
_autorecon2_volonly_steps = [
782782
('gcareg', ['mri/transforms/talairach.lta'], []),
783783
('canorm', ['mri/norm.mgz'], []),
784784
('careg', ['mri/transforms/talairach.m3z'], []),
@@ -799,65 +799,51 @@ class ReconAll(CommandLine):
799799
('fill', ['mri/filled.mgz',
800800
# 'scripts/ponscc.cut.log',
801801
], []),
802-
('tessellate', ['surf/lh.orig.nofix', 'surf/rh.orig.nofix'], []),
803-
('smooth1', ['surf/lh.smoothwm.nofix', 'surf/rh.smoothwm.nofix'],
804-
[]),
805-
('inflate1', ['surf/lh.inflated.nofix', 'surf/rh.inflated.nofix'],
806-
[]),
807-
('qsphere', ['surf/lh.qsphere.nofix', 'surf/rh.qsphere.nofix'],
808-
[]),
809-
('fix', ['surf/lh.orig', 'surf/rh.orig'], []),
810-
('white', ['surf/lh.white', 'surf/rh.white',
811-
'surf/lh.curv', 'surf/rh.curv',
812-
'surf/lh.area', 'surf/rh.area',
813-
'label/lh.cortex.label', 'label/rh.cortex.label'], []),
814-
('smooth2', ['surf/lh.smoothwm', 'surf/rh.smoothwm'], []),
815-
('inflate2', ['surf/lh.inflated', 'surf/rh.inflated',
816-
'surf/lh.sulc', 'surf/rh.sulc',
817-
'surf/lh.inflated.H', 'surf/rh.inflated.H',
818-
'surf/lh.inflated.K', 'surf/rh.inflated.K'], []),
802+
]
803+
_autorecon2_lh_steps = [
804+
('tessellate', ['surf/lh.orig.nofix'], []),
805+
('smooth1', ['surf/lh.smoothwm.nofix'], []),
806+
('inflate1', ['surf/lh.inflated.nofix'], []),
807+
('qsphere', ['surf/lh.qsphere.nofix'], []),
808+
('fix', ['surf/lh.orig'], []),
809+
('white', ['surf/lh.white', 'surf/lh.curv', 'surf/lh.area',
810+
'label/lh.cortex.label'], []),
811+
('smooth2', ['surf/lh.smoothwm'], []),
812+
('inflate2', ['surf/lh.inflated', 'surf/lh.sulc',
813+
'surf/lh.inflated.H', 'surf/lh.inflated.K'], []),
819814
# Undocumented in ReconAllTableStableV5.3
820-
('curvstats', ['stats/lh.curv.stats', 'stats/rh.curv.stats'], []),
815+
('curvstats', ['stats/lh.curv.stats'], []),
821816
]
822-
_autorecon3_steps = [
823-
('sphere', ['surf/lh.sphere', 'surf/rh.sphere'], []),
824-
('surfreg', ['surf/lh.sphere.reg', 'surf/rh.sphere.reg'], []),
825-
('jacobian_white', ['surf/lh.jacobian_white',
826-
'surf/rh.jacobian_white'], []),
827-
('avgcurv', ['surf/lh.avg_curv', 'surf/rh.avg_curv'], []),
828-
('cortparc', ['label/lh.aparc.annot', 'label/rh.aparc.annot'], []),
829-
('pial', ['surf/lh.pial', 'surf/rh.pial',
830-
'surf/lh.curv.pial', 'surf/rh.curv.pial',
831-
'surf/lh.area.pial', 'surf/rh.area.pial',
832-
'surf/lh.thickness', 'surf/rh.thickness'], []),
817+
_autorecon3_lh_steps = [
818+
('sphere', ['surf/lh.sphere'], []),
819+
('surfreg', ['surf/lh.sphere.reg'], []),
820+
('jacobian_white', ['surf/lh.jacobian_white'], []),
821+
('avgcurv', ['surf/lh.avg_curv'], []),
822+
('cortparc', ['label/lh.aparc.annot'], []),
823+
('pial', ['surf/lh.pial', 'surf/lh.curv.pial', 'surf/lh.area.pial',
824+
'surf/lh.thickness'], []),
833825
# Misnamed outputs in ReconAllTableStableV5.3: ?h.w-c.pct.mgz
834-
('pctsurfcon', ['surf/lh.w-g.pct.mgh', 'surf/rh.w-g.pct.mgh'], []),
835-
('parcstats', ['stats/lh.aparc.stats', 'stats/rh.aparc.stats',
836-
'label/aparc.annot.a2009s.ctab'], []),
837-
('cortparc2', ['label/lh.aparc.a2009s.annot',
838-
'label/rh.aparc.a2009s.annot'], []),
839-
('parcstats2', ['stats/lh.aparc.a2009s.stats',
840-
'stats/rh.aparc.a2009s.stats',
841-
'label/aparc.annot.a2009s.ctab'], []),
826+
('pctsurfcon', ['surf/lh.w-g.pct.mgh'], []),
827+
('parcstats', ['stats/lh.aparc.stats'], []),
828+
('cortparc2', ['label/lh.aparc.a2009s.annot'], []),
829+
('parcstats2', ['stats/lh.aparc.a2009s.stats'], []),
842830
# Undocumented in ReconAllTableStableV5.3
843-
('cortparc3', ['label/lh.aparc.DKTatlas40.annot',
844-
'label/rh.aparc.DKTatlas40.annot'], []),
831+
('cortparc3', ['label/lh.aparc.DKTatlas40.annot'], []),
845832
# Undocumented in ReconAllTableStableV5.3
846-
('parcstats3', ['stats/lh.aparc.a2009s.stats',
847-
'stats/rh.aparc.a2009s.stats',
848-
'label/aparc.annot.a2009s.ctab'], []),
833+
('parcstats3', ['stats/lh.aparc.a2009s.stats'], []),
834+
('label-exvivo-ec', ['label/lh.entorhinal_exvivo.label'], []),
835+
]
836+
_autorecon3_added_steps = [
849837
('cortribbon', ['mri/lh.ribbon.mgz', 'mri/rh.ribbon.mgz',
850838
'mri/ribbon.mgz'], []),
851839
('segstats', ['stats/aseg.stats'], []),
852840
('aparc2aseg', ['mri/aparc+aseg.mgz',
853841
'mri/aparc.a2009s+aseg.mgz'], []),
854842
('wmparc', ['mri/wmparc.mgz', 'stats/wmparc.stats'], []),
855843
('balabels', ['label/BA.ctab', 'label/BA.thresh.ctab'], []),
856-
('label-exvivo-ec', ['label/lh.entorhinal_exvivo.label',
857-
'label/rh.entorhinal_exvivo.label'], []),
858844
]
859845
else:
860-
_autorecon2_steps = [
846+
_autorecon2_volonly_steps = [
861847
('gcareg', ['mri/transforms/talairach.lta'], []),
862848
('canorm', ['mri/norm.mgz'], []),
863849
('careg', ['mri/transforms/talairach.m3z'], []),
@@ -872,53 +858,39 @@ class ReconAll(CommandLine):
872858
('fill', ['mri/filled.mgz',
873859
# 'scripts/ponscc.cut.log',
874860
], []),
875-
('tessellate', ['surf/lh.orig.nofix', 'surf/rh.orig.nofix'], []),
876-
('smooth1', ['surf/lh.smoothwm.nofix', 'surf/rh.smoothwm.nofix'],
877-
[]),
878-
('inflate1', ['surf/lh.inflated.nofix', 'surf/rh.inflated.nofix'],
879-
[]),
880-
('qsphere', ['surf/lh.qsphere.nofix', 'surf/rh.qsphere.nofix'],
881-
[]),
882-
('fix', ['surf/lh.orig', 'surf/rh.orig'], []),
883-
('white', ['surf/lh.white.preaparc', 'surf/rh.white.preaparc',
884-
'surf/lh.curv', 'surf/rh.curv',
885-
'surf/lh.area', 'surf/rh.area',
886-
'label/lh.cortex.label', 'label/rh.cortex.label'], []),
887-
('smooth2', ['surf/lh.smoothwm', 'surf/rh.smoothwm'], []),
888-
('inflate2', ['surf/lh.inflated', 'surf/rh.inflated',
889-
'surf/lh.sulc', 'surf/rh.sulc'], []),
890-
('curvHK', ['surf/lh.white.H', 'surf/rh.white.H',
891-
'surf/lh.white.K', 'surf/rh.white.K',
892-
'surf/lh.inflated.H', 'surf/rh.inflated.H',
893-
'surf/lh.inflated.K', 'surf/rh.inflated.K'], []),
894-
('curvstats', ['stats/lh.curv.stats', 'stats/rh.curv.stats'], []),
895861
]
896-
_autorecon3_steps = [
897-
('sphere', ['surf/lh.sphere', 'surf/rh.sphere'], []),
898-
('surfreg', ['surf/lh.sphere.reg', 'surf/rh.sphere.reg'], []),
899-
('jacobian_white', ['surf/lh.jacobian_white',
900-
'surf/rh.jacobian_white'], []),
901-
('avgcurv', ['surf/lh.avg_curv', 'surf/rh.avg_curv'], []),
902-
('cortparc', ['label/lh.aparc.annot', 'label/rh.aparc.annot'], []),
903-
('pial', ['surf/lh.pial', 'surf/rh.pial',
904-
'surf/lh.curv.pial', 'surf/rh.curv.pial',
905-
'surf/lh.area.pial', 'surf/rh.area.pial',
906-
'surf/lh.thickness', 'surf/rh.thickness'], []),
862+
_autorecon2_lh_steps = [
863+
('tessellate', ['surf/lh.orig.nofix'], []),
864+
('smooth1', ['surf/lh.smoothwm.nofix'], []),
865+
('inflate1', ['surf/lh.inflated.nofix'], []),
866+
('qsphere', ['surf/lh.qsphere.nofix'], []),
867+
('fix', ['surf/lh.orig'], []),
868+
('white', ['surf/lh.white.preaparc', 'surf/lh.curv',
869+
'surf/lh.area', 'label/lh.cortex.label'], []),
870+
('smooth2', ['surf/lh.smoothwm'], []),
871+
('inflate2', ['surf/lh.inflated', 'surf/lh.sulc'], []),
872+
('curvHK', ['surf/lh.white.H', 'surf/lh.white.K',
873+
'surf/lh.inflated.H', 'surf/lh.inflated.K'], []),
874+
('curvstats', ['stats/lh.curv.stats'], []),
875+
]
876+
_autorecon3_lh_steps = [
877+
('sphere', ['surf/lh.sphere'], []),
878+
('surfreg', ['surf/lh.sphere.reg'], []),
879+
('jacobian_white', ['surf/lh.jacobian_white'], []),
880+
('avgcurv', ['surf/lh.avg_curv'], []),
881+
('cortparc', ['label/lh.aparc.annot'], []),
882+
('pial', ['surf/lh.pial', 'surf/lh.curv.pial',
883+
'surf/lh.area.pial', 'surf/lh.thickness'], []),
884+
('parcstats', ['stats/lh.aparc.stats'], []),
885+
('cortparc2', ['label/lh.aparc.a2009s.annot'], []),
886+
('parcstats2', ['stats/lh.aparc.a2009s.stats'], []),
887+
('cortparc3', ['label/lh.aparc.DKTatlas.annot'], []),
888+
('parcstats3', ['stats/lh.aparc.DKTatlas.stats'], []),
889+
('pctsurfcon', ['surf/lh.w-g.pct.mgh'], []),
890+
]
891+
_autorecon3_added_steps = [
907892
('cortribbon', ['mri/lh.ribbon.mgz', 'mri/rh.ribbon.mgz',
908893
'mri/ribbon.mgz'], []),
909-
('parcstats', ['stats/lh.aparc.stats', 'stats/rh.aparc.stats',
910-
'label/aparc.annot.ctab'], []),
911-
('cortparc2', ['label/lh.aparc.a2009s.annot',
912-
'label/rh.aparc.a2009s.annot'], []),
913-
('parcstats2', ['stats/lh.aparc.a2009s.stats',
914-
'stats/rh.aparc.a2009s.stats',
915-
'label/aparc.annot.a2009s.ctab'], []),
916-
('cortparc3', ['label/lh.aparc.DKTatlas.annot',
917-
'label/rh.aparc.DKTatlas.annot'], []),
918-
('parcstats3', ['stats/lh.aparc.DKTatlas.stats',
919-
'stats/rh.aparc.DKTatlas.stats',
920-
'label/aparc.annot.DKTatlas.ctab'], []),
921-
('pctsurfcon', ['surf/lh.w-g.pct.mgh', 'surf/rh.w-g.pct.mgh'], []),
922894
('hyporelabel', ['mri/aseg.presurf.hypos.mgz'], []),
923895
('aparc2aseg', ['mri/aparc+aseg.mgz',
924896
'mri/aparc.a2009s+aseg.mgz',
@@ -934,6 +906,30 @@ class ReconAll(CommandLine):
934906
'label/rh.entorhinal_exvivo.label'], []),
935907
]
936908

909+
# Fill out autorecon2 steps
910+
_autorecon2_rh_steps = [
911+
(step, [out.replace('lh', 'rh') for out in outs], ins)
912+
for step, outs, ins in _autorecon2_lh_steps]
913+
_autorecon2_perhemi_steps = [
914+
(step, [of for out in outs
915+
for of in (out, out.replace('lh', 'rh'))], ins)
916+
for step, outs, ins in _autorecon2_lh_steps]
917+
_autorecon2_steps = _autorecon2_volonly_steps + _autorecon2_perhemi_steps
918+
919+
# Fill out autorecon3 steps
920+
_autorecon3_rh_steps = [
921+
(step, [out.replace('lh', 'rh') for out in outs], ins)
922+
for step, outs, ins in _autorecon3_lh_steps]
923+
_autorecon3_perhemi_steps = [
924+
(step, [of for out in outs
925+
for of in (out, out.replace('lh', 'rh'))], ins)
926+
for step, outs, ins in _autorecon3_lh_steps]
927+
_autorecon3_steps = _autorecon3_perhemi_steps + _autorecon3_added_steps
928+
929+
# Fill out autorecon-hemi lh/rh steps
930+
_autorecon_lh_steps = (_autorecon2_lh_steps + _autorecon3_lh_steps)
931+
_autorecon_rh_steps = (_autorecon2_rh_steps + _autorecon3_rh_steps)
932+
937933
_steps = _autorecon1_steps + _autorecon2_steps + _autorecon3_steps
938934

939935
_binaries = ['talairach', 'mri_normalize', 'mri_watershed',
@@ -1029,8 +1025,25 @@ def cmdline(self):
10291025
steps = []
10301026
elif directive == 'autorecon1':
10311027
steps = self._autorecon1_steps
1028+
elif directive == 'autorecon2-volonly':
1029+
steps = self._autorecon2_volonly_steps
1030+
elif directive == 'autorecon2-perhemi':
1031+
steps = self._autorecon2_perhemi_steps
10321032
elif directive.startswith('autorecon2'):
1033-
steps = self._autorecon2_steps
1033+
if isdefined(self.inputs.hemi):
1034+
if self.inputs.hemi == 'lh':
1035+
steps = (self._autorecon2_volonly_steps +
1036+
self._autorecon2_lh_steps)
1037+
else:
1038+
steps = (self._autorecon2_volonly_steps +
1039+
self._autorecon2_rh_steps)
1040+
else:
1041+
steps = self._autorecon2_steps
1042+
elif directive == 'autorecon-hemi':
1043+
if self.inputs.hemi == 'lh':
1044+
steps = self._autorecon_lh_steps
1045+
else:
1046+
steps = self._autorecon_rh_steps
10341047
elif directive == 'autorecon3':
10351048
steps = self._autorecon3_steps
10361049
else:

0 commit comments

Comments
 (0)