@@ -591,17 +591,22 @@ def _gen_filename(self, name):
591
591
592
592
593
593
class ReconAllInputSpec (CommandLineInputSpec ):
594
- subject_id = traits .Str ("recon_all" , argstr = '-subjid %s' , desc = 'subject name' ,
595
- usedefault = True )
594
+ subject_id = traits .Str ("recon_all" , argstr = '-subjid %s' ,
595
+ desc = 'subject name' , usedefault = True )
596
596
directive = traits .Enum ('all' , 'autorecon1' , 'autorecon2' , 'autorecon2-cp' ,
597
- 'autorecon2-wm' , 'autorecon2-inflate1' , 'autorecon2-perhemi' ,
598
- 'autorecon3' , 'localGI' , 'qcache' , argstr = '-%s' ,
599
- desc = 'process directive' , usedefault = True ,
600
- position = 0 )
601
- hemi = traits .Enum ('lh' , 'rh' , desc = 'hemisphere to process' , argstr = "-hemi %s" )
597
+ 'autorecon2-wm' , 'autorecon2-inflate1' ,
598
+ 'autorecon2-perhemi' , 'autorecon3' , 'localGI' ,
599
+ 'qcache' , argstr = '-%s' , desc = 'process directive' ,
600
+ usedefault = True , position = 0 )
601
+ hemi = traits .Enum ('lh' , 'rh' , desc = 'hemisphere to process' ,
602
+ argstr = "-hemi %s" )
602
603
T1_files = InputMultiPath (File (exists = True ), argstr = '-i %s...' ,
603
604
desc = 'name of T1 file to process' )
604
- subjects_dir = Directory (exists = True , argstr = '-sd %s' ,
605
+ T2_file = File (exists = True , argstr = "-T2 %s" , min_ver = '5.3.0' ,
606
+ desc = 'Use a T2 image to refine the cortical surface' )
607
+ openmp = traits .Int (argstr = "-openmp %d" ,
608
+ desc = "Number of processors to use in parallel" )
609
+ subjects_dir = Directory (exists = True , argstr = '-sd %s' , hash_files = False ,
605
610
desc = 'path to subjects directory' , genfile = True )
606
611
flags = traits .Str (argstr = '%s' , desc = 'additional parameters' )
607
612
@@ -742,44 +747,59 @@ def _list_outputs(self):
742
747
outputs = self ._outputs ().get ()
743
748
744
749
outputs .update (FreeSurferSource (subject_id = self .inputs .subject_id ,
745
- subjects_dir = subjects_dir , hemi = hemi )._list_outputs ())
750
+ subjects_dir = subjects_dir ,
751
+ hemi = hemi )._list_outputs ())
746
752
outputs ['subject_id' ] = self .inputs .subject_id
747
753
outputs ['subjects_dir' ] = subjects_dir
748
754
return outputs
749
755
750
- @property
751
- def cmdline (self ):
756
+ def _is_resuming (self ):
752
757
subjects_dir = self .inputs .subjects_dir
753
758
if not isdefined (subjects_dir ):
754
759
subjects_dir = self ._gen_subjects_dir ()
755
- if not os .path .isdir (
756
- os .path .join (subjects_dir ,self .inputs .subject_id ,'mri' )):
757
- return super (ReconAll , self ).cmdline
758
- self ._check_mandatory_inputs ()
759
- skip = ['T1_files' ]
760
+ if os .path .isdir (os .path .join (subjects_dir , self .inputs .subject_id ,
761
+ 'mri' )):
762
+ return True
763
+ return False
764
+
765
+ def _format_arg (self , name , trait_spec , value ):
766
+ if name == 'T1_files' :
767
+ if self ._is_resuming ():
768
+ return ''
769
+ return super (ReconAll , self )._format_arg (name , trait_spec , value )
770
+
771
+ @property
772
+ def cmdline (self ):
773
+ cmd = super (ReconAll , self ).cmdline
774
+ if not self ._is_resuming ():
775
+ return cmd
760
776
subjects_dir = self .inputs .subjects_dir
761
777
if not isdefined (subjects_dir ):
762
778
subjects_dir = self ._gen_subjects_dir ()
779
+ #cmd = cmd.replace(' -all ', ' -make all ')
780
+ iflogger .info ('Overriding recon-all directive' )
763
781
flags = []
764
782
directive = 'all'
765
783
for idx , step in enumerate (self ._steps ):
766
784
step , outfiles = step
767
- if all ([os .path .exists (os .path .join (subjects_dir ,self .inputs .subject_id ,f )) for f in outfiles ]):
785
+ if all ([os .path .exists (os .path .join (subjects_dir ,
786
+ self .inputs .subject_id ,f )) for
787
+ f in outfiles ]):
768
788
flags .append ('-no%s' % step )
769
789
if idx > 4 :
770
790
directive = 'autorecon2'
771
791
elif idx > 23 :
772
792
directive = 'autorecon3'
773
793
else :
774
794
flags .append ('-%s' % step )
775
- self .inputs .args = ' ' .join ([self .inputs .args ] + flags )
776
- self .inputs .directive = directive
777
- allargs = self ._parse_inputs (skip = skip )
778
- allargs .insert (0 , self .cmd )
779
- cmd = ' ' .join (allargs )
780
- iflogger .info ('resume recon-all : %s' % cmd )
795
+ cmd = cmd .replace (' -%s ' % self .inputs .directive , ' -%s ' % directive )
796
+ cmd += ' ' + ' ' .join (flags )
797
+ iflogger .info ('resume recon-all : %s' % cmd )
781
798
return cmd
782
799
800
+ def _run_interface (self , runtime , correct_return_codes = [0 ]):
801
+ runtime .returncode = 0
802
+ return runtime
783
803
784
804
class BBRegisterInputSpec (FSTraitedSpec ):
785
805
subject_id = traits .Str (argstr = '--s %s' ,
0 commit comments