@@ -630,8 +630,26 @@ class ReconAllInputSpec(CommandLineInputSpec):
630630 desc = "Enable parallel execution" )
631631 hires = traits .Bool (argstr = "-hires" , min_ver = '6.0.0' ,
632632 desc = "Conform to minimum voxel size (for voxels < 1mm)" )
633+ mprage = traits .Bool (argstr = '-mprage' ,
634+ desc = ('Assume scan parameters are MGH MP-RAGE '
635+ 'protocol, which produces darker gray matter' ))
636+ big_ventricles = traits .Bool (argstr = '-bigventricles' ,
637+ desc = ('For use in subjects with enlarged '
638+ 'ventricles' ))
639+ brainstem = traits .Bool (argstr = '-brainstem-structures' ,
640+ desc = 'Segment brainstem structures' )
641+ hippocampal_subfields_T1 = traits .Bool (
642+ argstr = '-hippocampal-subfields-T1' , min_ver = '6.0.0' ,
643+ desc = 'segment hippocampal subfields using input T1 scan' )
644+ hippocampal_subfields_T2 = traits .Tuple (
645+ File (exists = True ), traits .Str (),
646+ argstr = '-hippocampal-subfields-T2 %s %s' , min_ver = '6.0.0' ,
647+ desc = ('segment hippocampal subfields using T2 scan, identified by '
648+ 'ID (may be combined with hippocampal_subfields_T1)' ))
633649 expert = File (exists = True , argstr = '-expert %s' ,
634650 desc = "Set parameters using expert file" )
651+ xopts = traits .Enum ("use" , "clean" , "overwrite" , argstr = '-xopts-%s' ,
652+ desc = "Use, delete or overwrite existing expert options file" )
635653 subjects_dir = Directory (exists = True , argstr = '-sd %s' , hash_files = False ,
636654 desc = 'path to subjects directory' , genfile = True )
637655 flags = traits .Str (argstr = '%s' , desc = 'additional parameters' )
@@ -933,6 +951,13 @@ def _format_arg(self, name, trait_spec, value):
933951 if name == 'T1_files' :
934952 if self ._is_resuming ():
935953 return ''
954+ if name == 'hippocampal_subfields_T1' and \
955+ isdefined (self .inputs .hippocampal_subfields_T2 ):
956+ return ''
957+ if all ((name == 'hippocampal_subfields_T2' ,
958+ isdefined (self .inputs .hippocampal_subfields_T1 ) and
959+ self .inputs .hippocampal_subfields_T1 )):
960+ trait_spec .argstr = trait_spec .argstr .replace ('T2' , 'T1T2' )
936961 return super (ReconAll , self )._format_arg (name , trait_spec , value )
937962
938963 @property
@@ -949,10 +974,22 @@ def cmdline(self):
949974 if not isdefined (subjects_dir ):
950975 subjects_dir = self ._gen_subjects_dir ()
951976
977+ # Check only relevant steps
978+ directive = self .inputs .directive
979+ if not isdefined (directive ):
980+ steps = []
981+ elif directive == 'autorecon1' :
982+ steps = self ._autorecon1_steps
983+ elif directive .startswith ('autorecon2' ):
984+ steps = self ._autorecon2_steps
985+ elif directive == 'autorecon3' :
986+ steps = self ._autorecon3_steps
987+ else :
988+ steps = self ._steps
989+
952990 no_run = True
953991 flags = []
954- for idx , step in enumerate (self ._steps ):
955- step , outfiles , infiles = step
992+ for step , outfiles , infiles in steps :
956993 flag = '-{}' .format (step )
957994 noflag = '-no{}' .format (step )
958995 if noflag in cmd :
@@ -989,11 +1026,30 @@ def _prep_expert_file(self):
9891026 if lines == []:
9901027 return ''
9911028
1029+ contents = '' .join (lines )
1030+ if not isdefined (self .inputs .xopts ) and \
1031+ self .get_expert_file () == contents :
1032+ return ' -xopts-use'
1033+
9921034 expert_fname = os .path .abspath ('expert.opts' )
9931035 with open (expert_fname , 'w' ) as fobj :
994- fobj .write ('' . join ( lines ) )
1036+ fobj .write (contents )
9951037 return ' -expert {}' .format (expert_fname )
9961038
1039+ def _get_expert_file (self ):
1040+ # Read pre-existing options file, if it exists
1041+ if isdefined (self .inputs .subjects_dir ):
1042+ subjects_dir = self .inputs .subjects_dir
1043+ else :
1044+ subjects_dir = self ._gen_subjects_dir ()
1045+
1046+ xopts_file = os .path .join (subjects_dir , self .inputs .subject_id ,
1047+ 'scripts' , 'expert-options' )
1048+ if not os .path .exists (xopts_file ):
1049+ return ''
1050+ with open (xopts_file , 'r' ) as fobj :
1051+ return fobj .read ()
1052+
9971053
9981054class BBRegisterInputSpec (FSTraitedSpec ):
9991055 subject_id = traits .Str (argstr = '--s %s' ,
0 commit comments