|
22 | 22 | from nibabel import load
|
23 | 23 |
|
24 | 24 | from ... import logging
|
25 |
| -from ...utils.filemanip import fname_presuffix |
| 25 | +from ...utils.filemanip import fname_presuffix, check_depends |
26 | 26 | from ..io import FreeSurferSource
|
27 | 27 | from ..base import (TraitedSpec, File, traits,
|
28 | 28 | Directory, InputMultiPath,
|
@@ -658,86 +658,85 @@ class ReconAll(CommandLine):
|
658 | 658 |
|
659 | 659 | _steps = [
|
660 | 660 | # autorecon1
|
661 |
| - ('motioncor', ['mri/rawavg.mgz', 'mri/orig.mgz']), |
| 661 | + ('motioncor', ['mri/rawavg.mgz', 'mri/orig.mgz'], []), |
662 | 662 | ('talairach', ['mri/orig_nu.mgz',
|
663 | 663 | 'mri/transforms/talairach.auto.xfm',
|
664 | 664 | 'mri/transforms/talairach.xfm',
|
665 | 665 | # 'mri/transforms/talairach_avi.log',
|
666 |
| - ]), |
667 |
| - ('nuintensitycor', ['mri/nu.mgz']), |
668 |
| - ('normalization', ['mri/T1.mgz']), |
| 666 | + ], []), |
| 667 | + ('nuintensitycor', ['mri/nu.mgz'], []), |
| 668 | + ('normalization', ['mri/T1.mgz'], []), |
669 | 669 | ('skullstrip', ['mri/talairach_with_skull.lta',
|
670 | 670 | 'mri/brainmask.auto.mgz',
|
671 |
| - 'mri/brainmask.mgz']), |
| 671 | + 'mri/brainmask.mgz'], []), |
672 | 672 | # autorecon2
|
673 |
| - ('gcareg', ['mri/transforms/talairach.lta']), |
674 |
| - ('canorm', ['mri/norm.mgz']), |
675 |
| - ('careg', ['mri/transforms/talairach.m3z']), |
| 673 | + ('gcareg', ['mri/transforms/talairach.lta'], []), |
| 674 | + ('canorm', ['mri/norm.mgz'], []), |
| 675 | + ('careg', ['mri/transforms/talairach.m3z'], []), |
676 | 676 | ('calabel', ['mri/aseg.auto_noCCseg.mgz',
|
677 | 677 | 'mri/aseg.auto.mgz',
|
678 |
| - 'mri/aseg.mgz']), |
679 |
| - ('normalization2', ['mri/brain.mgz']), |
680 |
| - ('maskbfs', ['mri/brain.finalsurfs.mgz']), |
| 678 | + 'mri/aseg.mgz'], []), |
| 679 | + ('normalization2', ['mri/brain.mgz'], []), |
| 680 | + ('maskbfs', ['mri/brain.finalsurfs.mgz'], []), |
681 | 681 | ('segmentation', ['mri/wm.seg.mgz',
|
682 | 682 | 'mri/wm.asegedit.mgz',
|
683 |
| - 'mri/wm.mgz']), |
| 683 | + 'mri/wm.mgz'], []), |
684 | 684 | ('fill', ['mri/filled.mgz',
|
685 | 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']), |
| 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 | 692 | ('white', ['surf/lh.white.preaparc', 'surf/rh.white.preaparc',
|
693 | 693 | 'surf/lh.curv', 'surf/rh.curv',
|
694 | 694 | 'surf/lh.area', 'surf/rh.area',
|
695 |
| - 'label/lh.cortex.label', 'label/rh.cortex.label']), |
696 |
| - ('smooth2', ['surf/lh.smoothwm', 'surf/rh.smoothwm']), |
| 695 | + 'label/lh.cortex.label', 'label/rh.cortex.label'], []), |
| 696 | + ('smooth2', ['surf/lh.smoothwm', 'surf/rh.smoothwm'], []), |
697 | 697 | ('inflate2', ['surf/lh.inflated', 'surf/rh.inflated',
|
698 |
| - 'surf/lh.sulc', 'surf/rh.sulc']), |
| 698 | + 'surf/lh.sulc', 'surf/rh.sulc'], []), |
699 | 699 | ('curvHK', ['surf/lh.white.H', 'surf/rh.white.H',
|
700 | 700 | 'surf/lh.white.K', 'surf/rh.white.K',
|
701 | 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']), |
| 702 | + 'surf/lh.inflated.K', 'surf/rh.inflated.K'], []), |
| 703 | + ('curvstats', ['stats/lh.curv.stats', 'stats/rh.curv.stats'], []), |
704 | 704 | # autorecon3
|
705 |
| - ('sphere', ['surf/lh.sphere', 'surf/rh.sphere']), |
706 |
| - ('surfreg', ['surf/lh.sphere.reg', 'surf/rh.sphere.reg']), |
| 705 | + ('sphere', ['surf/lh.sphere', 'surf/rh.sphere'], []), |
| 706 | + ('surfreg', ['surf/lh.sphere.reg', 'surf/rh.sphere.reg'], []), |
707 | 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']), |
| 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 | 711 | ('pial', ['surf/lh.pial', 'surf/rh.pial',
|
712 | 712 | 'surf/lh.curv.pial', 'surf/rh.curv.pial',
|
713 | 713 | 'surf/lh.area.pial', 'surf/rh.area.pial',
|
714 |
| - 'surf/lh.thickness', 'surf/rh.thickness']), |
715 |
| - # TODO: Optional -T2pial / -FLAIRpial |
| 714 | + 'surf/lh.thickness', 'surf/rh.thickness'], []), |
716 | 715 | ('cortribbon', ['mri/lh.ribbon.mgz', 'mri/rh.ribbon.mgz',
|
717 |
| - 'mri/ribbon.mgz']), |
| 716 | + 'mri/ribbon.mgz'], []), |
718 | 717 | ('parcstats', ['stats/lh.aparc.astats', 'stats/rh.aparc.stats',
|
719 |
| - 'stats/aparc.annot.ctab']), |
| 718 | + 'stats/aparc.annot.ctab'], []), |
720 | 719 | ('cortparc2', ['label/lh.aparc.a2009s.annot',
|
721 |
| - 'label/rh.aparc.a2009s.annot']), |
| 720 | + 'label/rh.aparc.a2009s.annot'], []), |
722 | 721 | ('parcstats2', ['stats/lh.aparc.a2009s.stats',
|
723 | 722 | 'stats/rh.aparc.a2009s.stats',
|
724 |
| - 'stats/aparc.annot.a2009s.ctab']), |
| 723 | + 'stats/aparc.annot.a2009s.ctab'], []), |
725 | 724 | ('cortparc3', ['label/lh.aparc.DKTatlas.annot',
|
726 |
| - 'label/rh.aparc.DKTatlas.annot']), |
| 725 | + 'label/rh.aparc.DKTatlas.annot'], []), |
727 | 726 | ('parcstats3', ['stats/lh.aparc.DKTatlas.stats',
|
728 | 727 | 'stats/rh.aparc.DKTatlas.stats',
|
729 |
| - 'stats/aparc.annot.DKTatlas.ctab']), |
730 |
| - ('pctsurfcon', ['surf/lh.w-g.pct.mgh', 'surf/rh.w-g.pct.mgh']), |
731 |
| - ('hyporelabel', ['mri/aseg.presurf.hypos.mgz']), |
| 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'], []), |
732 | 731 | ('aparc2aseg', ['mri/aparc+aseg.mgz',
|
733 | 732 | 'mri/aparc.a2009s+aseg.mgz',
|
734 |
| - 'mri/aparc.DKTatlas+aseg.mgz']), |
735 |
| - ('apas2aseg', ['mri/aseg.mgz']), # XXX: Will not run because of calabel |
736 |
| - ('segstats', ['stats/aseg.stats']), |
737 |
| - ('wmparc', ['mri/wmparc.mgz', 'stats/wmparc.stats']), |
| 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'], []), |
738 | 737 | ('balabels', ['BA.ctab', 'BA.thresh.ctab',
|
739 | 738 | 'label/lh.entorhinal_exvivo.label',
|
740 |
| - 'label/rh.entorhinal_exvivo.label']), |
| 739 | + 'label/rh.entorhinal_exvivo.label'], []), |
741 | 740 | ]
|
742 | 741 |
|
743 | 742 | def _gen_subjects_dir(self):
|
@@ -799,15 +798,15 @@ def cmdline(self):
|
799 | 798 | flags = []
|
800 | 799 | directive = 'all'
|
801 | 800 | for idx, step in enumerate(self._steps):
|
802 |
| - step, outfiles = step |
| 801 | + step, outfiles, infiles = step |
803 | 802 | flag = '-{}'.format(step)
|
804 | 803 | noflag = '-no{}'.format(step)
|
805 | 804 | if flag in cmd or noflag in cmd:
|
806 | 805 | continue
|
807 | 806 |
|
808 |
| - if all([os.path.exists(os.path.join(subjects_dir, |
809 |
| - self.inputs.subject_id, f)) for |
810 |
| - f in outfiles]): |
| 807 | + subj_dir = os.path.join(subjects_dir, self.inputs.subject_id) |
| 808 | + if check_depends([os.path.join(subj_dir, f) for f in outfiles], |
| 809 | + [os.path.join(subj_dir, f) for f in infiles]): |
811 | 810 | flags.append(noflag)
|
812 | 811 | if idx > 4:
|
813 | 812 | directive = 'autorecon2'
|
|
0 commit comments