diff --git a/nipype/interfaces/freesurfer/preprocess.py b/nipype/interfaces/freesurfer/preprocess.py index 0bc90af462..02ae960c5b 100644 --- a/nipype/interfaces/freesurfer/preprocess.py +++ b/nipype/interfaces/freesurfer/preprocess.py @@ -665,6 +665,7 @@ class ReconAll(CommandLine): input_spec = ReconAllInputSpec output_spec = ReconAllOutputSpec _can_resume = True + force_run = False # Steps are based off of the recon-all tables [0,1] describing, inputs, # commands, and outputs of each step of the recon-all process, @@ -687,7 +688,7 @@ class ReconAll(CommandLine): ], []), ('nuintensitycor', ['mri/nu.mgz'], []), ('normalization', ['mri/T1.mgz'], []), - ('skullstrip', ['mri/talairach_with_skull.lta', + ('skullstrip', ['mri/transforms/talairach_with_skull.lta', 'mri/brainmask.auto.mgz', 'mri/brainmask.mgz'], []), ] @@ -730,6 +731,8 @@ class ReconAll(CommandLine): 'surf/lh.sulc', 'surf/rh.sulc', 'surf/lh.inflated.H', 'surf/rh.inflated.H', 'surf/lh.inflated.K', 'surf/rh.inflated.K'], []), + # Undocumented in ReconAllTableStableV5.3 + ('curvstats', ['stats/lh.curv.stats', 'stats/rh.curv.stats'], []), ] _autorecon3_steps = [ ('sphere', ['surf/lh.sphere', 'surf/rh.sphere'], []), @@ -742,18 +745,29 @@ class ReconAll(CommandLine): 'surf/lh.curv.pial', 'surf/rh.curv.pial', 'surf/lh.area.pial', 'surf/rh.area.pial', 'surf/lh.thickness', 'surf/rh.thickness'], []), + # Misnamed outputs in ReconAllTableStableV5.3: ?h.w-c.pct.mgz + ('pctsurfcon', ['surf/lh.w-g.pct.mgh', 'surf/rh.w-g.pct.mgh'], []), + ('parcstats', ['stats/lh.aparc.stats', 'stats/rh.aparc.stats', + 'label/aparc.annot.a2009s.ctab'], []), ('cortparc2', ['label/lh.aparc.a2009s.annot', 'label/rh.aparc.a2009s.annot'], []), ('parcstats2', ['stats/lh.aparc.a2009s.stats', 'stats/rh.aparc.a2009s.stats', - 'stats/aparc.annot.a2009s.ctab'], []), + 'label/aparc.annot.a2009s.ctab'], []), + # Undocumented in ReconAllTableStableV5.3 + ('cortparc3', ['label/lh.aparc.DKTatlas40.annot', + 'label/rh.aparc.DKTatlas40.annot'], []), + # Undocumented in ReconAllTableStableV5.3 + ('parcstats3', ['stats/lh.aparc.a2009s.stats', + 'stats/rh.aparc.a2009s.stats', + 'label/aparc.annot.a2009s.ctab'], []), ('cortribbon', ['mri/lh.ribbon.mgz', 'mri/rh.ribbon.mgz', 'mri/ribbon.mgz'], []), ('segstats', ['stats/aseg.stats'], []), ('aparc2aseg', ['mri/aparc+aseg.mgz', 'mri/aparc.a2009s+aseg.mgz'], []), ('wmparc', ['mri/wmparc.mgz', 'stats/wmparc.stats'], []), - ('balabels', ['BA.ctab', 'BA.thresh.ctab'], []), + ('balabels', ['label/BA.ctab', 'label/BA.thresh.ctab'], []), ('label-exvivo-ec', ['label/lh.entorhinal_exvivo.label', 'label/rh.entorhinal_exvivo.label'], []), ] @@ -807,18 +821,18 @@ class ReconAll(CommandLine): 'surf/lh.thickness', 'surf/rh.thickness'], []), ('cortribbon', ['mri/lh.ribbon.mgz', 'mri/rh.ribbon.mgz', 'mri/ribbon.mgz'], []), - ('parcstats', ['stats/lh.aparc.astats', 'stats/rh.aparc.stats', - 'stats/aparc.annot.ctab'], []), + ('parcstats', ['stats/lh.aparc.stats', 'stats/rh.aparc.stats', + 'label/aparc.annot.ctab'], []), ('cortparc2', ['label/lh.aparc.a2009s.annot', 'label/rh.aparc.a2009s.annot'], []), ('parcstats2', ['stats/lh.aparc.a2009s.stats', 'stats/rh.aparc.a2009s.stats', - 'stats/aparc.annot.a2009s.ctab'], []), + 'label/aparc.annot.a2009s.ctab'], []), ('cortparc3', ['label/lh.aparc.DKTatlas.annot', 'label/rh.aparc.DKTatlas.annot'], []), ('parcstats3', ['stats/lh.aparc.DKTatlas.stats', 'stats/rh.aparc.DKTatlas.stats', - 'stats/aparc.annot.DKTatlas.ctab'], []), + 'label/aparc.annot.DKTatlas.ctab'], []), ('pctsurfcon', ['surf/lh.w-g.pct.mgh', 'surf/rh.w-g.pct.mgh'], []), ('hyporelabel', ['mri/aseg.presurf.hypos.mgz'], []), ('aparc2aseg', ['mri/aparc+aseg.mgz', @@ -827,7 +841,10 @@ class ReconAll(CommandLine): ('apas2aseg', ['mri/aseg.mgz'], ['mri/aparc+aseg.mgz']), ('segstats', ['stats/aseg.stats'], []), ('wmparc', ['mri/wmparc.mgz', 'stats/wmparc.stats'], []), - ('balabels', ['BA.ctab', 'BA.thresh.ctab', + # Note that this is a very incomplete list; however the ctab + # files are last to be touched, so this should be reasonable + ('balabels', ['label/BA_exvivo.ctab', + 'label/BA_exvivo.thresh.ctab', 'label/lh.entorhinal_exvivo.label', 'label/rh.entorhinal_exvivo.label'], []), ] @@ -889,20 +906,30 @@ def cmdline(self): if not isdefined(subjects_dir): subjects_dir = self._gen_subjects_dir() + no_run = True flags = [] for idx, step in enumerate(self._steps): step, outfiles, infiles = step flag = '-{}'.format(step) noflag = '-no{}'.format(step) - if flag in cmd or noflag in cmd: + if noflag in cmd: + continue + elif flag in cmd: + no_run = False continue subj_dir = os.path.join(subjects_dir, self.inputs.subject_id) if check_depends([os.path.join(subj_dir, f) for f in outfiles], [os.path.join(subj_dir, f) for f in infiles]): flags.append(noflag) - cmd += ' ' + ' '.join(flags) + else: + no_run = False + if no_run and not self.force_run: + iflogger.info('recon-all complete : Not running') + return "echo recon-all: nothing to do" + + cmd += ' ' + ' '.join(flags) iflogger.info('resume recon-all : %s' % cmd) return cmd