Skip to content

Commit e9ed516

Browse files
committed
Refine step checking for partial directives
1 parent 3a4afc1 commit e9ed516

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
@@ -784,7 +784,7 @@ class ReconAll(CommandLine):
784784
'mri/brainmask.mgz'], []),
785785
]
786786
if Info.looseversion() < LooseVersion("6.0.0"):
787-
_autorecon2_steps = [
787+
_autorecon2_volonly_steps = [
788788
('gcareg', ['mri/transforms/talairach.lta'], []),
789789
('canorm', ['mri/norm.mgz'], []),
790790
('careg', ['mri/transforms/talairach.m3z'], []),
@@ -805,65 +805,51 @@ class ReconAll(CommandLine):
805805
('fill', ['mri/filled.mgz',
806806
# 'scripts/ponscc.cut.log',
807807
], []),
808-
('tessellate', ['surf/lh.orig.nofix', 'surf/rh.orig.nofix'], []),
809-
('smooth1', ['surf/lh.smoothwm.nofix', 'surf/rh.smoothwm.nofix'],
810-
[]),
811-
('inflate1', ['surf/lh.inflated.nofix', 'surf/rh.inflated.nofix'],
812-
[]),
813-
('qsphere', ['surf/lh.qsphere.nofix', 'surf/rh.qsphere.nofix'],
814-
[]),
815-
('fix', ['surf/lh.orig', 'surf/rh.orig'], []),
816-
('white', ['surf/lh.white', 'surf/rh.white',
817-
'surf/lh.curv', 'surf/rh.curv',
818-
'surf/lh.area', 'surf/rh.area',
819-
'label/lh.cortex.label', 'label/rh.cortex.label'], []),
820-
('smooth2', ['surf/lh.smoothwm', 'surf/rh.smoothwm'], []),
821-
('inflate2', ['surf/lh.inflated', 'surf/rh.inflated',
822-
'surf/lh.sulc', 'surf/rh.sulc',
823-
'surf/lh.inflated.H', 'surf/rh.inflated.H',
824-
'surf/lh.inflated.K', 'surf/rh.inflated.K'], []),
808+
]
809+
_autorecon2_lh_steps = [
810+
('tessellate', ['surf/lh.orig.nofix'], []),
811+
('smooth1', ['surf/lh.smoothwm.nofix'], []),
812+
('inflate1', ['surf/lh.inflated.nofix'], []),
813+
('qsphere', ['surf/lh.qsphere.nofix'], []),
814+
('fix', ['surf/lh.orig'], []),
815+
('white', ['surf/lh.white', 'surf/lh.curv', 'surf/lh.area',
816+
'label/lh.cortex.label'], []),
817+
('smooth2', ['surf/lh.smoothwm'], []),
818+
('inflate2', ['surf/lh.inflated', 'surf/lh.sulc',
819+
'surf/lh.inflated.H', 'surf/lh.inflated.K'], []),
825820
# Undocumented in ReconAllTableStableV5.3
826-
('curvstats', ['stats/lh.curv.stats', 'stats/rh.curv.stats'], []),
821+
('curvstats', ['stats/lh.curv.stats'], []),
827822
]
828-
_autorecon3_steps = [
829-
('sphere', ['surf/lh.sphere', 'surf/rh.sphere'], []),
830-
('surfreg', ['surf/lh.sphere.reg', 'surf/rh.sphere.reg'], []),
831-
('jacobian_white', ['surf/lh.jacobian_white',
832-
'surf/rh.jacobian_white'], []),
833-
('avgcurv', ['surf/lh.avg_curv', 'surf/rh.avg_curv'], []),
834-
('cortparc', ['label/lh.aparc.annot', 'label/rh.aparc.annot'], []),
835-
('pial', ['surf/lh.pial', 'surf/rh.pial',
836-
'surf/lh.curv.pial', 'surf/rh.curv.pial',
837-
'surf/lh.area.pial', 'surf/rh.area.pial',
838-
'surf/lh.thickness', 'surf/rh.thickness'], []),
823+
_autorecon3_lh_steps = [
824+
('sphere', ['surf/lh.sphere'], []),
825+
('surfreg', ['surf/lh.sphere.reg'], []),
826+
('jacobian_white', ['surf/lh.jacobian_white'], []),
827+
('avgcurv', ['surf/lh.avg_curv'], []),
828+
('cortparc', ['label/lh.aparc.annot'], []),
829+
('pial', ['surf/lh.pial', 'surf/lh.curv.pial', 'surf/lh.area.pial',
830+
'surf/lh.thickness'], []),
839831
# Misnamed outputs in ReconAllTableStableV5.3: ?h.w-c.pct.mgz
840-
('pctsurfcon', ['surf/lh.w-g.pct.mgh', 'surf/rh.w-g.pct.mgh'], []),
841-
('parcstats', ['stats/lh.aparc.stats', 'stats/rh.aparc.stats',
842-
'label/aparc.annot.a2009s.ctab'], []),
843-
('cortparc2', ['label/lh.aparc.a2009s.annot',
844-
'label/rh.aparc.a2009s.annot'], []),
845-
('parcstats2', ['stats/lh.aparc.a2009s.stats',
846-
'stats/rh.aparc.a2009s.stats',
847-
'label/aparc.annot.a2009s.ctab'], []),
832+
('pctsurfcon', ['surf/lh.w-g.pct.mgh'], []),
833+
('parcstats', ['stats/lh.aparc.stats'], []),
834+
('cortparc2', ['label/lh.aparc.a2009s.annot'], []),
835+
('parcstats2', ['stats/lh.aparc.a2009s.stats'], []),
848836
# Undocumented in ReconAllTableStableV5.3
849-
('cortparc3', ['label/lh.aparc.DKTatlas40.annot',
850-
'label/rh.aparc.DKTatlas40.annot'], []),
837+
('cortparc3', ['label/lh.aparc.DKTatlas40.annot'], []),
851838
# Undocumented in ReconAllTableStableV5.3
852-
('parcstats3', ['stats/lh.aparc.a2009s.stats',
853-
'stats/rh.aparc.a2009s.stats',
854-
'label/aparc.annot.a2009s.ctab'], []),
839+
('parcstats3', ['stats/lh.aparc.a2009s.stats'], []),
840+
('label-exvivo-ec', ['label/lh.entorhinal_exvivo.label'], []),
841+
]
842+
_autorecon3_added_steps = [
855843
('cortribbon', ['mri/lh.ribbon.mgz', 'mri/rh.ribbon.mgz',
856844
'mri/ribbon.mgz'], []),
857845
('segstats', ['stats/aseg.stats'], []),
858846
('aparc2aseg', ['mri/aparc+aseg.mgz',
859847
'mri/aparc.a2009s+aseg.mgz'], []),
860848
('wmparc', ['mri/wmparc.mgz', 'stats/wmparc.stats'], []),
861849
('balabels', ['label/BA.ctab', 'label/BA.thresh.ctab'], []),
862-
('label-exvivo-ec', ['label/lh.entorhinal_exvivo.label',
863-
'label/rh.entorhinal_exvivo.label'], []),
864850
]
865851
else:
866-
_autorecon2_steps = [
852+
_autorecon2_volonly_steps = [
867853
('gcareg', ['mri/transforms/talairach.lta'], []),
868854
('canorm', ['mri/norm.mgz'], []),
869855
('careg', ['mri/transforms/talairach.m3z'], []),
@@ -878,53 +864,39 @@ class ReconAll(CommandLine):
878864
('fill', ['mri/filled.mgz',
879865
# 'scripts/ponscc.cut.log',
880866
], []),
881-
('tessellate', ['surf/lh.orig.nofix', 'surf/rh.orig.nofix'], []),
882-
('smooth1', ['surf/lh.smoothwm.nofix', 'surf/rh.smoothwm.nofix'],
883-
[]),
884-
('inflate1', ['surf/lh.inflated.nofix', 'surf/rh.inflated.nofix'],
885-
[]),
886-
('qsphere', ['surf/lh.qsphere.nofix', 'surf/rh.qsphere.nofix'],
887-
[]),
888-
('fix', ['surf/lh.orig', 'surf/rh.orig'], []),
889-
('white', ['surf/lh.white.preaparc', 'surf/rh.white.preaparc',
890-
'surf/lh.curv', 'surf/rh.curv',
891-
'surf/lh.area', 'surf/rh.area',
892-
'label/lh.cortex.label', 'label/rh.cortex.label'], []),
893-
('smooth2', ['surf/lh.smoothwm', 'surf/rh.smoothwm'], []),
894-
('inflate2', ['surf/lh.inflated', 'surf/rh.inflated',
895-
'surf/lh.sulc', 'surf/rh.sulc'], []),
896-
('curvHK', ['surf/lh.white.H', 'surf/rh.white.H',
897-
'surf/lh.white.K', 'surf/rh.white.K',
898-
'surf/lh.inflated.H', 'surf/rh.inflated.H',
899-
'surf/lh.inflated.K', 'surf/rh.inflated.K'], []),
900-
('curvstats', ['stats/lh.curv.stats', 'stats/rh.curv.stats'], []),
901867
]
902-
_autorecon3_steps = [
903-
('sphere', ['surf/lh.sphere', 'surf/rh.sphere'], []),
904-
('surfreg', ['surf/lh.sphere.reg', 'surf/rh.sphere.reg'], []),
905-
('jacobian_white', ['surf/lh.jacobian_white',
906-
'surf/rh.jacobian_white'], []),
907-
('avgcurv', ['surf/lh.avg_curv', 'surf/rh.avg_curv'], []),
908-
('cortparc', ['label/lh.aparc.annot', 'label/rh.aparc.annot'], []),
909-
('pial', ['surf/lh.pial', 'surf/rh.pial',
910-
'surf/lh.curv.pial', 'surf/rh.curv.pial',
911-
'surf/lh.area.pial', 'surf/rh.area.pial',
912-
'surf/lh.thickness', 'surf/rh.thickness'], []),
868+
_autorecon2_lh_steps = [
869+
('tessellate', ['surf/lh.orig.nofix'], []),
870+
('smooth1', ['surf/lh.smoothwm.nofix'], []),
871+
('inflate1', ['surf/lh.inflated.nofix'], []),
872+
('qsphere', ['surf/lh.qsphere.nofix'], []),
873+
('fix', ['surf/lh.orig'], []),
874+
('white', ['surf/lh.white.preaparc', 'surf/lh.curv',
875+
'surf/lh.area', 'label/lh.cortex.label'], []),
876+
('smooth2', ['surf/lh.smoothwm'], []),
877+
('inflate2', ['surf/lh.inflated', 'surf/lh.sulc'], []),
878+
('curvHK', ['surf/lh.white.H', 'surf/lh.white.K',
879+
'surf/lh.inflated.H', 'surf/lh.inflated.K'], []),
880+
('curvstats', ['stats/lh.curv.stats'], []),
881+
]
882+
_autorecon3_lh_steps = [
883+
('sphere', ['surf/lh.sphere'], []),
884+
('surfreg', ['surf/lh.sphere.reg'], []),
885+
('jacobian_white', ['surf/lh.jacobian_white'], []),
886+
('avgcurv', ['surf/lh.avg_curv'], []),
887+
('cortparc', ['label/lh.aparc.annot'], []),
888+
('pial', ['surf/lh.pial', 'surf/lh.curv.pial',
889+
'surf/lh.area.pial', 'surf/lh.thickness'], []),
890+
('parcstats', ['stats/lh.aparc.stats'], []),
891+
('cortparc2', ['label/lh.aparc.a2009s.annot'], []),
892+
('parcstats2', ['stats/lh.aparc.a2009s.stats'], []),
893+
('cortparc3', ['label/lh.aparc.DKTatlas.annot'], []),
894+
('parcstats3', ['stats/lh.aparc.DKTatlas.stats'], []),
895+
('pctsurfcon', ['surf/lh.w-g.pct.mgh'], []),
896+
]
897+
_autorecon3_added_steps = [
913898
('cortribbon', ['mri/lh.ribbon.mgz', 'mri/rh.ribbon.mgz',
914899
'mri/ribbon.mgz'], []),
915-
('parcstats', ['stats/lh.aparc.stats', 'stats/rh.aparc.stats',
916-
'label/aparc.annot.ctab'], []),
917-
('cortparc2', ['label/lh.aparc.a2009s.annot',
918-
'label/rh.aparc.a2009s.annot'], []),
919-
('parcstats2', ['stats/lh.aparc.a2009s.stats',
920-
'stats/rh.aparc.a2009s.stats',
921-
'label/aparc.annot.a2009s.ctab'], []),
922-
('cortparc3', ['label/lh.aparc.DKTatlas.annot',
923-
'label/rh.aparc.DKTatlas.annot'], []),
924-
('parcstats3', ['stats/lh.aparc.DKTatlas.stats',
925-
'stats/rh.aparc.DKTatlas.stats',
926-
'label/aparc.annot.DKTatlas.ctab'], []),
927-
('pctsurfcon', ['surf/lh.w-g.pct.mgh', 'surf/rh.w-g.pct.mgh'], []),
928900
('hyporelabel', ['mri/aseg.presurf.hypos.mgz'], []),
929901
('aparc2aseg', ['mri/aparc+aseg.mgz',
930902
'mri/aparc.a2009s+aseg.mgz',
@@ -940,6 +912,30 @@ class ReconAll(CommandLine):
940912
'label/rh.entorhinal_exvivo.label'], []),
941913
]
942914

915+
# Fill out autorecon2 steps
916+
_autorecon2_rh_steps = [
917+
(step, [out.replace('lh', 'rh') for out in outs], ins)
918+
for step, outs, ins in _autorecon2_lh_steps]
919+
_autorecon2_perhemi_steps = [
920+
(step, [of for out in outs
921+
for of in (out, out.replace('lh', 'rh'))], ins)
922+
for step, outs, ins in _autorecon2_lh_steps]
923+
_autorecon2_steps = _autorecon2_volonly_steps + _autorecon2_perhemi_steps
924+
925+
# Fill out autorecon3 steps
926+
_autorecon3_rh_steps = [
927+
(step, [out.replace('lh', 'rh') for out in outs], ins)
928+
for step, outs, ins in _autorecon3_lh_steps]
929+
_autorecon3_perhemi_steps = [
930+
(step, [of for out in outs
931+
for of in (out, out.replace('lh', 'rh'))], ins)
932+
for step, outs, ins in _autorecon3_lh_steps]
933+
_autorecon3_steps = _autorecon3_perhemi_steps + _autorecon3_added_steps
934+
935+
# Fill out autorecon-hemi lh/rh steps
936+
_autorecon_lh_steps = (_autorecon2_lh_steps + _autorecon3_lh_steps)
937+
_autorecon_rh_steps = (_autorecon2_rh_steps + _autorecon3_rh_steps)
938+
943939
_steps = _autorecon1_steps + _autorecon2_steps + _autorecon3_steps
944940

945941
_binaries = ['talairach', 'mri_normalize', 'mri_watershed',
@@ -1035,8 +1031,25 @@ def cmdline(self):
10351031
steps = []
10361032
elif directive == 'autorecon1':
10371033
steps = self._autorecon1_steps
1034+
elif directive == 'autorecon2-volonly':
1035+
steps = self._autorecon2_volonly_steps
1036+
elif directive == 'autorecon2-perhemi':
1037+
steps = self._autorecon2_perhemi_steps
10381038
elif directive.startswith('autorecon2'):
1039-
steps = self._autorecon2_steps
1039+
if isdefined(self.inputs.hemi):
1040+
if self.inputs.hemi == 'lh':
1041+
steps = (self._autorecon2_volonly_steps +
1042+
self._autorecon2_lh_steps)
1043+
else:
1044+
steps = (self._autorecon2_volonly_steps +
1045+
self._autorecon2_rh_steps)
1046+
else:
1047+
steps = self._autorecon2_steps
1048+
elif directive == 'autorecon-hemi':
1049+
if self.inputs.hemi == 'lh':
1050+
steps = self._autorecon_lh_steps
1051+
else:
1052+
steps = self._autorecon_rh_steps
10401053
elif directive == 'autorecon3':
10411054
steps = self._autorecon3_steps
10421055
else:

0 commit comments

Comments
 (0)