From 4a7e6f63a190d8f0cf26490d42f30702ba208dc4 Mon Sep 17 00:00:00 2001 From: "Christopher J. Markiewicz" Date: Fri, 17 Feb 2017 12:29:09 -0500 Subject: [PATCH 1/5] BF: Update ctab file locations to under label/ Mislabeled locations caused some parts of ReconAll to be re-done unnecessarily --- nipype/interfaces/freesurfer/preprocess.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/nipype/interfaces/freesurfer/preprocess.py b/nipype/interfaces/freesurfer/preprocess.py index 0bc90af462..c069c46e10 100644 --- a/nipype/interfaces/freesurfer/preprocess.py +++ b/nipype/interfaces/freesurfer/preprocess.py @@ -746,14 +746,14 @@ class ReconAll(CommandLine): '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'], []), ('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'], []), ] @@ -808,17 +808,17 @@ class ReconAll(CommandLine): ('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'], []), + '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 +827,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'], []), ] From d42218382f8fb44b4d8a5347b26ee67b7fc0bf6f Mon Sep 17 00:00:00 2001 From: "Christopher J. Markiewicz" Date: Fri, 17 Feb 2017 13:07:16 -0500 Subject: [PATCH 2/5] Missing/mislocated v5.3.0 recon-all steps --- nipype/interfaces/freesurfer/preprocess.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nipype/interfaces/freesurfer/preprocess.py b/nipype/interfaces/freesurfer/preprocess.py index c069c46e10..886967cd61 100644 --- a/nipype/interfaces/freesurfer/preprocess.py +++ b/nipype/interfaces/freesurfer/preprocess.py @@ -687,7 +687,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'], []), ] @@ -742,6 +742,9 @@ 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'], []), + ('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', From 9b3e6565e57885a1568ccd5ccacb669fbc452514 Mon Sep 17 00:00:00 2001 From: "Christopher J. Markiewicz" Date: Fri, 17 Feb 2017 13:38:40 -0500 Subject: [PATCH 3/5] Add undocumented v5.3 steps --- nipype/interfaces/freesurfer/preprocess.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/nipype/interfaces/freesurfer/preprocess.py b/nipype/interfaces/freesurfer/preprocess.py index 886967cd61..0a6b1d49eb 100644 --- a/nipype/interfaces/freesurfer/preprocess.py +++ b/nipype/interfaces/freesurfer/preprocess.py @@ -730,6 +730,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,6 +744,7 @@ 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'], []), @@ -750,6 +753,13 @@ class ReconAll(CommandLine): ('parcstats2', ['stats/lh.aparc.a2009s.stats', 'stats/rh.aparc.a2009s.stats', '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'], []), From 03b512c93c59b41aea4cf739291d5b146ce341db Mon Sep 17 00:00:00 2001 From: "Christopher J. Markiewicz" Date: Fri, 17 Feb 2017 13:38:55 -0500 Subject: [PATCH 4/5] Do not run recon-all if all steps complete - Recon-all considers "nothing to do" an error - Add ``force_run`` instance variable to permit user override --- nipype/interfaces/freesurfer/preprocess.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/nipype/interfaces/freesurfer/preprocess.py b/nipype/interfaces/freesurfer/preprocess.py index 0a6b1d49eb..bf68d71bd2 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, @@ -905,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 From cc5d9c9ef5f9b9d6a7a7bffdbd0ac79ebf065345 Mon Sep 17 00:00:00 2001 From: "Christopher J. Markiewicz" Date: Fri, 17 Feb 2017 14:59:02 -0500 Subject: [PATCH 5/5] Fix typo in FSv6 steps --- nipype/interfaces/freesurfer/preprocess.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nipype/interfaces/freesurfer/preprocess.py b/nipype/interfaces/freesurfer/preprocess.py index bf68d71bd2..02ae960c5b 100644 --- a/nipype/interfaces/freesurfer/preprocess.py +++ b/nipype/interfaces/freesurfer/preprocess.py @@ -821,7 +821,7 @@ 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', + ('parcstats', ['stats/lh.aparc.stats', 'stats/rh.aparc.stats', 'label/aparc.annot.ctab'], []), ('cortparc2', ['label/lh.aparc.a2009s.annot', 'label/rh.aparc.a2009s.annot'], []),