Skip to content

Commit b8d2b08

Browse files
committed
Re-add v5.3 steps
1 parent 8e914f3 commit b8d2b08

File tree

1 file changed

+165
-72
lines changed

1 file changed

+165
-72
lines changed

nipype/interfaces/freesurfer/preprocess.py

Lines changed: 165 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import numpy as np
2222
from nibabel import load
2323

24-
from ... import logging
24+
from ... import logging, LooseVersion
2525
from ...utils.filemanip import fname_presuffix, check_depends
2626
from ..io import FreeSurferSource
2727
from ..base import (TraitedSpec, File, traits,
@@ -30,12 +30,20 @@
3030
CommandLineInputSpec, isdefined)
3131
from .base import (FSCommand, FSTraitedSpec,
3232
FSTraitedSpecOpenMP,
33-
FSCommandOpenMP)
33+
FSCommandOpenMP, Info)
3434
from .utils import copy2subjdir
3535

3636
__docformat__ = 'restructuredtext'
3737
iflogger = logging.getLogger('interface')
3838

39+
FSVersion = "0"
40+
_ver = Info.version()
41+
if _ver:
42+
if 'dev' in _ver:
43+
FSVersion = _ver.rstrip().split('-')[-1] + '.dev'
44+
else:
45+
FSVersion = _ver.rstrip().split('-v')[-1]
46+
3947

4048
class ParseDICOMDirInputSpec(FSTraitedSpec):
4149
dicom_dir = Directory(exists=True, argstr='--d %s', mandatory=True,
@@ -656,8 +664,19 @@ class ReconAll(CommandLine):
656664
output_spec = ReconAllOutputSpec
657665
_can_resume = True
658666

659-
_steps = [
660-
# autorecon1
667+
# Steps are based off of the recon-all tables [0,1] describing, inputs,
668+
# commands, and outputs of each step of the recon-all process,
669+
# controlled by flags.
670+
#
671+
# Each step is a 3-tuple containing (flag, [outputs], [inputs])
672+
# A step is considered complete if all of its outputs exist and are newer
673+
# than the inputs. An empty input list indicates input mtimes will not
674+
# be checked. This may need updating, if users are working with manually
675+
# edited files.
676+
#
677+
# [0] https://surfer.nmr.mgh.harvard.edu/fswiki/ReconAllTableStableV5.3
678+
# [1] https://surfer.nmr.mgh.harvard.edu/fswiki/ReconAllTableStableV6.0
679+
_autorecon1_steps = [
661680
('motioncor', ['mri/rawavg.mgz', 'mri/orig.mgz'], []),
662681
('talairach', ['mri/orig_nu.mgz',
663682
'mri/transforms/talairach.auto.xfm',
@@ -669,75 +688,149 @@ class ReconAll(CommandLine):
669688
('skullstrip', ['mri/talairach_with_skull.lta',
670689
'mri/brainmask.auto.mgz',
671690
'mri/brainmask.mgz'], []),
672-
# autorecon2
673-
('gcareg', ['mri/transforms/talairach.lta'], []),
674-
('canorm', ['mri/norm.mgz'], []),
675-
('careg', ['mri/transforms/talairach.m3z'], []),
676-
('calabel', ['mri/aseg.auto_noCCseg.mgz',
677-
'mri/aseg.auto.mgz',
678-
'mri/aseg.mgz'], []),
679-
('normalization2', ['mri/brain.mgz'], []),
680-
('maskbfs', ['mri/brain.finalsurfs.mgz'], []),
681-
('segmentation', ['mri/wm.seg.mgz',
682-
'mri/wm.asegedit.mgz',
683-
'mri/wm.mgz'], []),
684-
('fill', ['mri/filled.mgz',
685-
# 'scripts/ponscc.cut.log',
686-
], []),
687-
('tessellate', ['surf/lh.orig.nofix', 'surf/rh.orig.nofix'], []),
688-
('smooth1', ['surf/lh.smoothwm.nofix', 'surf/rh.smoothwm.nofix'], []),
689-
('inflate1', ['surf/lh.inflated.nofix', 'surf/rh.inflated.nofix'], []),
690-
('qsphere', ['surf/lh.qsphere.nofix', 'surf/rh.qsphere.nofix'], []),
691-
('fix', ['surf/lh.orig', 'surf/rh.orig'], []),
692-
('white', ['surf/lh.white.preaparc', 'surf/rh.white.preaparc',
693-
'surf/lh.curv', 'surf/rh.curv',
694-
'surf/lh.area', 'surf/rh.area',
695-
'label/lh.cortex.label', 'label/rh.cortex.label'], []),
696-
('smooth2', ['surf/lh.smoothwm', 'surf/rh.smoothwm'], []),
697-
('inflate2', ['surf/lh.inflated', 'surf/rh.inflated',
698-
'surf/lh.sulc', 'surf/rh.sulc'], []),
699-
('curvHK', ['surf/lh.white.H', 'surf/rh.white.H',
700-
'surf/lh.white.K', 'surf/rh.white.K',
701-
'surf/lh.inflated.H', 'surf/rh.inflated.H',
702-
'surf/lh.inflated.K', 'surf/rh.inflated.K'], []),
703-
('curvstats', ['stats/lh.curv.stats', 'stats/rh.curv.stats'], []),
704-
# autorecon3
705-
('sphere', ['surf/lh.sphere', 'surf/rh.sphere'], []),
706-
('surfreg', ['surf/lh.sphere.reg', 'surf/rh.sphere.reg'], []),
707-
('jacobian_white', ['surf/lh.jacobian_white',
708-
'surf/rh.jacobian_white'], []),
709-
('avgcurv', ['surf/lh.avg_curv', 'surf/rh.avg_curv'], []),
710-
('cortparc', ['label/lh.aparc.annot', 'label/rh.aparc.annot'], []),
711-
('pial', ['surf/lh.pial', 'surf/rh.pial',
712-
'surf/lh.curv.pial', 'surf/rh.curv.pial',
713-
'surf/lh.area.pial', 'surf/rh.area.pial',
714-
'surf/lh.thickness', 'surf/rh.thickness'], []),
715-
('cortribbon', ['mri/lh.ribbon.mgz', 'mri/rh.ribbon.mgz',
716-
'mri/ribbon.mgz'], []),
717-
('parcstats', ['stats/lh.aparc.astats', 'stats/rh.aparc.stats',
718-
'stats/aparc.annot.ctab'], []),
719-
('cortparc2', ['label/lh.aparc.a2009s.annot',
720-
'label/rh.aparc.a2009s.annot'], []),
721-
('parcstats2', ['stats/lh.aparc.a2009s.stats',
722-
'stats/rh.aparc.a2009s.stats',
723-
'stats/aparc.annot.a2009s.ctab'], []),
724-
('cortparc3', ['label/lh.aparc.DKTatlas.annot',
725-
'label/rh.aparc.DKTatlas.annot'], []),
726-
('parcstats3', ['stats/lh.aparc.DKTatlas.stats',
727-
'stats/rh.aparc.DKTatlas.stats',
728-
'stats/aparc.annot.DKTatlas.ctab'], []),
729-
('pctsurfcon', ['surf/lh.w-g.pct.mgh', 'surf/rh.w-g.pct.mgh'], []),
730-
('hyporelabel', ['mri/aseg.presurf.hypos.mgz'], []),
731-
('aparc2aseg', ['mri/aparc+aseg.mgz',
732-
'mri/aparc.a2009s+aseg.mgz',
733-
'mri/aparc.DKTatlas+aseg.mgz'], []),
734-
('apas2aseg', ['mri/aseg.mgz'], ['mri/aparc+aseg.mgz']),
735-
('segstats', ['stats/aseg.stats'], []),
736-
('wmparc', ['mri/wmparc.mgz', 'stats/wmparc.stats'], []),
737-
('balabels', ['BA.ctab', 'BA.thresh.ctab',
738-
'label/lh.entorhinal_exvivo.label',
739-
'label/rh.entorhinal_exvivo.label'], []),
740691
]
692+
if LooseVersion(FSVersion) < LooseVersion("6.0.0"):
693+
_autorecon2_steps = [
694+
('gcareg', ['mri/transforms/talairach.lta'], []),
695+
('canorm', ['mri/norm.mgz'], []),
696+
('careg', ['mri/transforms/talairach.m3z'], []),
697+
('careginv', ['mri/transforms/talairach.m3z.inv.x.mgz',
698+
'mri/transforms/talairach.m3z.inv.y.mgz',
699+
'mri/transforms/talairach.m3z.inv.z.mgz',
700+
], []),
701+
('rmneck', ['mri/nu_noneck.mgz'], []),
702+
('skull-lta', ['mri/transforms/talairach_with_skull_2.lta'], []),
703+
('calabel', ['mri/aseg.auto_noCCseg.mgz',
704+
'mri/aseg.auto.mgz',
705+
'mri/aseg.mgz'], []),
706+
('normalization2', ['mri/brain.mgz'], []),
707+
('maskbfs', ['mri/brain.finalsurfs.mgz'], []),
708+
('segmentation', ['mri/wm.seg.mgz',
709+
'mri/wm.asegedit.mgz',
710+
'mri/wm.mgz'], []),
711+
('fill', ['mri/filled.mgz',
712+
# 'scripts/ponscc.cut.log',
713+
], []),
714+
('tessellate', ['surf/lh.orig.nofix', 'surf/rh.orig.nofix'], []),
715+
('smooth1', ['surf/lh.smoothwm.nofix', 'surf/rh.smoothwm.nofix'],
716+
[]),
717+
('inflate1', ['surf/lh.inflated.nofix', 'surf/rh.inflated.nofix'],
718+
[]),
719+
('qsphere', ['surf/lh.qsphere.nofix', 'surf/rh.qsphere.nofix'],
720+
[]),
721+
('fix', ['surf/lh.orig', 'surf/rh.orig'], []),
722+
('white', ['surf/lh.white', 'surf/rh.white',
723+
'surf/lh.curv', 'surf/rh.curv',
724+
'surf/lh.area', 'surf/rh.area',
725+
'label/lh.cortex.label', 'label/rh.cortex.label'], []),
726+
('smooth2', ['surf/lh.smoothwm', 'surf/rh.smoothwm'], []),
727+
('inflate2', ['surf/lh.inflated', 'surf/rh.inflated',
728+
'surf/lh.sulc', 'surf/rh.sulc',
729+
'surf/lh.inflated.H', 'surf/rh.inflated.H',
730+
'surf/lh.inflated.K', 'surf/rh.inflated.K'], []),
731+
]
732+
_autorecon3_steps = [
733+
('sphere', ['surf/lh.sphere', 'surf/rh.sphere'], []),
734+
('surfreg', ['surf/lh.sphere.reg', 'surf/rh.sphere.reg'], []),
735+
('jacobian_white', ['surf/lh.jacobian_white',
736+
'surf/rh.jacobian_white'], []),
737+
('avgcurv', ['surf/lh.avg_curv', 'surf/rh.avg_curv'], []),
738+
('cortparc', ['label/lh.aparc.annot', 'label/rh.aparc.annot'], []),
739+
('pial', ['surf/lh.pial', 'surf/rh.pial',
740+
'surf/lh.curv.pial', 'surf/rh.curv.pial',
741+
'surf/lh.area.pial', 'surf/rh.area.pial',
742+
'surf/lh.thickness', 'surf/rh.thickness'], []),
743+
('cortparc2', ['label/lh.aparc.a2009s.annot',
744+
'label/rh.aparc.a2009s.annot'], []),
745+
('parcstats2', ['stats/lh.aparc.a2009s.stats',
746+
'stats/rh.aparc.a2009s.stats',
747+
'stats/aparc.annot.a2009s.ctab'], []),
748+
('cortribbon', ['mri/lh.ribbon.mgz', 'mri/rh.ribbon.mgz',
749+
'mri/ribbon.mgz'], []),
750+
('segstats', ['stats/aseg.stats'], []),
751+
('aparc2aseg', ['mri/aparc+aseg.mgz',
752+
'mri/aparc.a2009s+aseg.mgz'], []),
753+
('wmparc', ['mri/wmparc.mgz', 'stats/wmparc.stats'], []),
754+
('balabels', ['BA.ctab', 'BA.thresh.ctab'], []),
755+
('label-exvivo-ec', ['label/lh.entorhinal_exvivo.label',
756+
'label/rh.entorhinal_exvivo.label'], []),
757+
]
758+
else:
759+
_autorecon2_steps = [
760+
('gcareg', ['mri/transforms/talairach.lta'], []),
761+
('canorm', ['mri/norm.mgz'], []),
762+
('careg', ['mri/transforms/talairach.m3z'], []),
763+
('calabel', ['mri/aseg.auto_noCCseg.mgz',
764+
'mri/aseg.auto.mgz',
765+
'mri/aseg.mgz'], []),
766+
('normalization2', ['mri/brain.mgz'], []),
767+
('maskbfs', ['mri/brain.finalsurfs.mgz'], []),
768+
('segmentation', ['mri/wm.seg.mgz',
769+
'mri/wm.asegedit.mgz',
770+
'mri/wm.mgz'], []),
771+
('fill', ['mri/filled.mgz',
772+
# 'scripts/ponscc.cut.log',
773+
], []),
774+
('tessellate', ['surf/lh.orig.nofix', 'surf/rh.orig.nofix'], []),
775+
('smooth1', ['surf/lh.smoothwm.nofix', 'surf/rh.smoothwm.nofix'],
776+
[]),
777+
('inflate1', ['surf/lh.inflated.nofix', 'surf/rh.inflated.nofix'],
778+
[]),
779+
('qsphere', ['surf/lh.qsphere.nofix', 'surf/rh.qsphere.nofix'],
780+
[]),
781+
('fix', ['surf/lh.orig', 'surf/rh.orig'], []),
782+
('white', ['surf/lh.white.preaparc', 'surf/rh.white.preaparc',
783+
'surf/lh.curv', 'surf/rh.curv',
784+
'surf/lh.area', 'surf/rh.area',
785+
'label/lh.cortex.label', 'label/rh.cortex.label'], []),
786+
('smooth2', ['surf/lh.smoothwm', 'surf/rh.smoothwm'], []),
787+
('inflate2', ['surf/lh.inflated', 'surf/rh.inflated',
788+
'surf/lh.sulc', 'surf/rh.sulc'], []),
789+
('curvHK', ['surf/lh.white.H', 'surf/rh.white.H',
790+
'surf/lh.white.K', 'surf/rh.white.K',
791+
'surf/lh.inflated.H', 'surf/rh.inflated.H',
792+
'surf/lh.inflated.K', 'surf/rh.inflated.K'], []),
793+
('curvstats', ['stats/lh.curv.stats', 'stats/rh.curv.stats'], []),
794+
]
795+
_autorecon3_steps = [
796+
('sphere', ['surf/lh.sphere', 'surf/rh.sphere'], []),
797+
('surfreg', ['surf/lh.sphere.reg', 'surf/rh.sphere.reg'], []),
798+
('jacobian_white', ['surf/lh.jacobian_white',
799+
'surf/rh.jacobian_white'], []),
800+
('avgcurv', ['surf/lh.avg_curv', 'surf/rh.avg_curv'], []),
801+
('cortparc', ['label/lh.aparc.annot', 'label/rh.aparc.annot'], []),
802+
('pial', ['surf/lh.pial', 'surf/rh.pial',
803+
'surf/lh.curv.pial', 'surf/rh.curv.pial',
804+
'surf/lh.area.pial', 'surf/rh.area.pial',
805+
'surf/lh.thickness', 'surf/rh.thickness'], []),
806+
('cortribbon', ['mri/lh.ribbon.mgz', 'mri/rh.ribbon.mgz',
807+
'mri/ribbon.mgz'], []),
808+
('parcstats', ['stats/lh.aparc.astats', 'stats/rh.aparc.stats',
809+
'stats/aparc.annot.ctab'], []),
810+
('cortparc2', ['label/lh.aparc.a2009s.annot',
811+
'label/rh.aparc.a2009s.annot'], []),
812+
('parcstats2', ['stats/lh.aparc.a2009s.stats',
813+
'stats/rh.aparc.a2009s.stats',
814+
'stats/aparc.annot.a2009s.ctab'], []),
815+
('cortparc3', ['label/lh.aparc.DKTatlas.annot',
816+
'label/rh.aparc.DKTatlas.annot'], []),
817+
('parcstats3', ['stats/lh.aparc.DKTatlas.stats',
818+
'stats/rh.aparc.DKTatlas.stats',
819+
'stats/aparc.annot.DKTatlas.ctab'], []),
820+
('pctsurfcon', ['surf/lh.w-g.pct.mgh', 'surf/rh.w-g.pct.mgh'], []),
821+
('hyporelabel', ['mri/aseg.presurf.hypos.mgz'], []),
822+
('aparc2aseg', ['mri/aparc+aseg.mgz',
823+
'mri/aparc.a2009s+aseg.mgz',
824+
'mri/aparc.DKTatlas+aseg.mgz'], []),
825+
('apas2aseg', ['mri/aseg.mgz'], ['mri/aparc+aseg.mgz']),
826+
('segstats', ['stats/aseg.stats'], []),
827+
('wmparc', ['mri/wmparc.mgz', 'stats/wmparc.stats'], []),
828+
('balabels', ['BA.ctab', 'BA.thresh.ctab',
829+
'label/lh.entorhinal_exvivo.label',
830+
'label/rh.entorhinal_exvivo.label'], []),
831+
]
832+
833+
_steps = _autorecon1_steps + _autorecon2_steps + _autorecon3_steps
741834

742835
def _gen_subjects_dir(self):
743836
return os.getcwd()

0 commit comments

Comments
 (0)