@@ -630,8 +630,26 @@ class ReconAllInputSpec(CommandLineInputSpec):
630
630
desc = "Enable parallel execution" )
631
631
hires = traits .Bool (argstr = "-hires" , min_ver = '6.0.0' ,
632
632
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)' ))
633
649
expert = File (exists = True , argstr = '-expert %s' ,
634
650
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" )
635
653
subjects_dir = Directory (exists = True , argstr = '-sd %s' , hash_files = False ,
636
654
desc = 'path to subjects directory' , genfile = True )
637
655
flags = traits .Str (argstr = '%s' , desc = 'additional parameters' )
@@ -933,6 +951,13 @@ def _format_arg(self, name, trait_spec, value):
933
951
if name == 'T1_files' :
934
952
if self ._is_resuming ():
935
953
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' )
936
961
return super (ReconAll , self )._format_arg (name , trait_spec , value )
937
962
938
963
@property
@@ -949,10 +974,22 @@ def cmdline(self):
949
974
if not isdefined (subjects_dir ):
950
975
subjects_dir = self ._gen_subjects_dir ()
951
976
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
+
952
990
no_run = True
953
991
flags = []
954
- for idx , step in enumerate (self ._steps ):
955
- step , outfiles , infiles = step
992
+ for step , outfiles , infiles in steps :
956
993
flag = '-{}' .format (step )
957
994
noflag = '-no{}' .format (step )
958
995
if noflag in cmd :
@@ -989,11 +1026,30 @@ def _prep_expert_file(self):
989
1026
if lines == []:
990
1027
return ''
991
1028
1029
+ contents = '' .join (lines )
1030
+ if not isdefined (self .inputs .xopts ) and \
1031
+ self .get_expert_file () == contents :
1032
+ return ' -xopts-use'
1033
+
992
1034
expert_fname = os .path .abspath ('expert.opts' )
993
1035
with open (expert_fname , 'w' ) as fobj :
994
- fobj .write ('' . join ( lines ) )
1036
+ fobj .write (contents )
995
1037
return ' -expert {}' .format (expert_fname )
996
1038
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
+
997
1053
998
1054
class BBRegisterInputSpec (FSTraitedSpec ):
999
1055
subject_id = traits .Str (argstr = '--s %s' ,
0 commit comments