|
28 | 28 | Directory, InputMultiPath,
|
29 | 29 | OutputMultiPath, CommandLine,
|
30 | 30 | CommandLineInputSpec, isdefined)
|
31 |
| -from ..traits_extension import DictStrStr |
32 | 31 | from .base import (FSCommand, FSTraitedSpec,
|
33 | 32 | FSTraitedSpecOpenMP,
|
34 | 33 | FSCommandOpenMP, Info)
|
@@ -635,12 +634,40 @@ class ReconAllInputSpec(CommandLineInputSpec):
|
635 | 634 | desc="Enable parallel execution")
|
636 | 635 | hires = traits.Bool(argstr="-hires", min_ver='6.0.0',
|
637 | 636 | desc="Conform to minimum voxel size (for voxels < 1mm)")
|
638 |
| - expert = traits.Either(File(exists=True), DictStrStr, argstr='-expert %s', |
| 637 | + expert = File(exists=True, argstr='-expert %s', |
639 | 638 | desc="Set parameters using expert file")
|
640 | 639 | subjects_dir = Directory(exists=True, argstr='-sd %s', hash_files=False,
|
641 | 640 | desc='path to subjects directory', genfile=True)
|
642 | 641 | flags = traits.Str(argstr='%s', desc='additional parameters')
|
643 | 642 |
|
| 643 | + # Expert options |
| 644 | + talairach = traits.Str(desc="Flags to pass to talairach commands", xor=['expert']) |
| 645 | + mri_normalize = traits.Str(desc="Flags to pass to mri_normalize commands", xor=['expert']) |
| 646 | + mri_watershed = traits.Str(desc="Flags to pass to mri_watershed commands", xor=['expert']) |
| 647 | + mri_em_register = traits.Str(desc="Flags to pass to mri_em_register commands", xor=['expert']) |
| 648 | + mri_ca_normalize = traits.Str(desc="Flags to pass to mri_ca_normalize commands", xor=['expert']) |
| 649 | + mri_ca_register = traits.Str(desc="Flags to pass to mri_ca_register commands", xor=['expert']) |
| 650 | + mri_remove_neck = traits.Str(desc="Flags to pass to mri_remove_neck commands", xor=['expert']) |
| 651 | + mri_ca_label = traits.Str(desc="Flags to pass to mri_ca_label commands", xor=['expert']) |
| 652 | + mri_segstats = traits.Str(desc="Flags to pass to mri_segstats commands", xor=['expert']) |
| 653 | + mri_mask = traits.Str(desc="Flags to pass to mri_mask commands", xor=['expert']) |
| 654 | + mri_segment = traits.Str(desc="Flags to pass to mri_segment commands", xor=['expert']) |
| 655 | + mri_edit_wm_with_aseg = traits.Str(desc="Flags to pass to mri_edit_wm_with_aseg commands", xor=['expert']) |
| 656 | + mri_pretess = traits.Str(desc="Flags to pass to mri_pretess commands", xor=['expert']) |
| 657 | + mri_fill = traits.Str(desc="Flags to pass to mri_fill commands", xor=['expert']) |
| 658 | + mri_tessellate = traits.Str(desc="Flags to pass to mri_tessellate commands", xor=['expert']) |
| 659 | + mris_smooth = traits.Str(desc="Flags to pass to mri_smooth commands", xor=['expert']) |
| 660 | + mris_inflate = traits.Str(desc="Flags to pass to mri_inflate commands", xor=['expert']) |
| 661 | + mris_sphere = traits.Str(desc="Flags to pass to mris_sphere commands", xor=['expert']) |
| 662 | + mris_fix_topology = traits.Str(desc="Flags to pass to mris_fix_topology commands", xor=['expert']) |
| 663 | + mris_make_surfaces = traits.Str(desc="Flags to pass to mris_make_surfaces commands", xor=['expert']) |
| 664 | + mris_surf2vol = traits.Str(desc="Flags to pass to mris_surf2vol commands", xor=['expert']) |
| 665 | + mris_register = traits.Str(desc="Flags to pass to mris_register commands", xor=['expert']) |
| 666 | + mrisp_paint = traits.Str(desc="Flags to pass to mrisp_paint commands", xor=['expert']) |
| 667 | + mris_ca_label = traits.Str(desc="Flags to pass to mris_ca_label commands", xor=['expert']) |
| 668 | + mris_anatomical_stats = traits.Str(desc="Flags to pass to mris_anatomical_stats commands", xor=['expert']) |
| 669 | + mri_aparc2aseg = traits.Str(desc="Flags to pass to mri_aparc2aseg commands", xor=['expert']) |
| 670 | + |
644 | 671 |
|
645 | 672 | class ReconAllOutputSpec(FreeSurferSource.output_spec):
|
646 | 673 | subjects_dir = Directory(exists=True, desc='Freesurfer subjects directory.')
|
@@ -856,6 +883,16 @@ class ReconAll(CommandLine):
|
856 | 883 |
|
857 | 884 | _steps = _autorecon1_steps + _autorecon2_steps + _autorecon3_steps
|
858 | 885 |
|
| 886 | + _binaries = ['talairach', 'mri_normalize', 'mri_watershed', |
| 887 | + 'mri_em_register', 'mri_ca_normalize', 'mri_ca_register', |
| 888 | + 'mri_remove_neck', 'mri_ca_label', 'mri_segstats', |
| 889 | + 'mri_mask', 'mri_segment', 'mri_edit_wm_with_aseg', |
| 890 | + 'mri_pretess', 'mri_fill', 'mri_tessellate', 'mris_smooth', |
| 891 | + 'mris_inflate', 'mris_sphere', 'mris_fix_topology', |
| 892 | + 'mris_make_surfaces', 'mris_surf2vol', 'mris_register', |
| 893 | + 'mrisp_paint', 'mris_ca_label', 'mris_anatomical_stats', |
| 894 | + 'mri_aparc2aseg'] |
| 895 | + |
859 | 896 | def _gen_subjects_dir(self):
|
860 | 897 | return os.getcwd()
|
861 | 898 |
|
@@ -900,17 +937,16 @@ def _format_arg(self, name, trait_spec, value):
|
900 | 937 | if name == 'T1_files':
|
901 | 938 | if self._is_resuming():
|
902 | 939 | return ''
|
903 |
| - if name == 'expert' and isinstance(value, dict): |
904 |
| - expert_fname = os.path.abspath('expert.opts') |
905 |
| - expert = ['{} {}\n'.format(key, val) for key, val in value.items()] |
906 |
| - with open(expert_fname, 'w') as fobj: |
907 |
| - fobj.write(''.join(expert)) |
908 |
| - value = expert_fname |
909 | 940 | return super(ReconAll, self)._format_arg(name, trait_spec, value)
|
910 | 941 |
|
911 | 942 | @property
|
912 | 943 | def cmdline(self):
|
913 | 944 | cmd = super(ReconAll, self).cmdline
|
| 945 | + |
| 946 | + # Adds '-expert' flag if expert flags are passed |
| 947 | + # Mutually exclusive with 'expert' input parameter |
| 948 | + cmd += self._prep_expert_file() |
| 949 | + |
914 | 950 | if not self._is_resuming():
|
915 | 951 | return cmd
|
916 | 952 | subjects_dir = self.inputs.subjects_dir
|
@@ -944,6 +980,24 @@ def cmdline(self):
|
944 | 980 | iflogger.info('resume recon-all : %s' % cmd)
|
945 | 981 | return cmd
|
946 | 982 |
|
| 983 | + def _prep_expert_file(self): |
| 984 | + if isdefined(self.inputs.expert): |
| 985 | + return '' |
| 986 | + |
| 987 | + lines = [] |
| 988 | + for binary in self._binaries: |
| 989 | + args = getattr(self.inputs, binary) |
| 990 | + if isdefined(args): |
| 991 | + lines.append('{} {}\n'.format(binary, args)) |
| 992 | + |
| 993 | + if lines == []: |
| 994 | + return '' |
| 995 | + |
| 996 | + expert_fname = os.path.abspath('expert.opts') |
| 997 | + with open(expert_fname, 'w') as fobj: |
| 998 | + fobj.write(''.join(lines)) |
| 999 | + return ' -expert {}'.format(expert_fname) |
| 1000 | + |
947 | 1001 |
|
948 | 1002 | class BBRegisterInputSpec(FSTraitedSpec):
|
949 | 1003 | subject_id = traits.Str(argstr='--s %s',
|
|
0 commit comments