@@ -3080,3 +3080,76 @@ def _normalize_filenames(self):
3080
3080
thickness_name)
3081
3081
3082
3082
self.inputs.sphere = self._associated_file(in_file, self.inputs.sphere)
3083
+
3084
+
3085
+ class LTAConvertInputSpec(CommandLineInputSpec):
3086
+ # Inputs
3087
+ _in_xor = ('in_lta', 'in_fsl', 'in_mni', 'in_reg', 'in_niftyreg')
3088
+ in_lta = traits.Either(
3089
+ File(exists=True), 'identity.nofile', argstr='--inlta %s',
3090
+ mandatory=True, xor=_in_xor, desc='input transform of LTA type')
3091
+ in_fsl = File(
3092
+ exists=True, argstr='--infsl %s', mandatory=True, xor=_in_xor,
3093
+ desc='input transform of FSL type')
3094
+ in_mni = File(
3095
+ exists=True, argstr='--inmni %s', mandatory=True, xor=_in_xor,
3096
+ desc='input transform of MNI/XFM type')
3097
+ in_reg = File(
3098
+ exists=True, argstr='--inreg %s', mandatory=True, xor=_in_xor,
3099
+ desc='input transform of TK REG type (deprecated format)')
3100
+ in_niftyreg = File(
3101
+ exists=True, argstr='--inniftyreg %s', mandatory=True, xor=_in_xor,
3102
+ desc='input transform of Nifty Reg type (inverse RAS2RAS)')
3103
+ # Outputs
3104
+ out_lta = traits.Either(
3105
+ traits.Bool, File, argstr='--outlta %s',
3106
+ desc='output linear transform (LTA Freesurfer format)')
3107
+ out_fsl = traits.Either(traits.Bool, File, argstr='--outfsl %s',
3108
+ desc='output transform in FSL format')
3109
+ out_mni = traits.Either(traits.Bool, File, argstr='--outmni %s',
3110
+ desc='output transform in MNI/XFM format')
3111
+ out_reg = traits.Either(traits.Bool, File, argstr='--outreg %s',
3112
+ desc='output transform in reg dat format')
3113
+ # Optional flags
3114
+ invert = traits.Bool(argstr='--invert')
3115
+ ltavox2vox = traits.Bool(argstr='--ltavox2vox', requires=['out_lta'])
3116
+ source_file = File(exists=True, argstr='--src %s')
3117
+ target_file = File(exists=True, argstr='--trg %s')
3118
+ target_conform = traits.Bool(argstr='--trgconform')
3119
+
3120
+
3121
+ class LTAConvertOutputSpec(TraitedSpec):
3122
+ out_lta = File(exists=True,
3123
+ desc='output linear transform (LTA Freesurfer format)')
3124
+ out_fsl = File(exists=True, desc='output transform in FSL format')
3125
+ out_mni = File(exists=True, desc='output transform in MNI/XFM format')
3126
+ out_reg = File(exists=True, desc='output transform in reg dat format')
3127
+
3128
+
3129
+ class LTAConvert(CommandLine):
3130
+ """Convert different transformation formats.
3131
+ Some formats may require you to pass an image if the geometry information
3132
+ is missing form the transform file format.
3133
+
3134
+ For complete details, see the `lta_convert documentation.
3135
+ <https://ftp.nmr.mgh.harvard.edu/pub/docs/html/lta_convert.help.xml.html>`_
3136
+ """
3137
+ input_spec = LTAConvertInputSpec
3138
+ output_spec = LTAConvertOutputSpec
3139
+ _cmd = 'lta_convert'
3140
+
3141
+ def _format_arg(self, name, spec, value):
3142
+ if name.startswith('out_') and value is True:
3143
+ value = self._list_outputs()[name]
3144
+ return super(LTAConvert, self)._format_arg(name, spec, value)
3145
+
3146
+ def _list_outputs(self):
3147
+ outputs = self.output_spec().get()
3148
+ for name, default in (('out_lta', 'out.lta'), ('out_fsl', 'out.mat'),
3149
+ ('out_mni', 'out.xfm'), ('out_reg', 'out.dat')):
3150
+ attr = getattr(self.inputs, name)
3151
+ if attr:
3152
+ fname = default if attr is True else attr
3153
+ outputs[name] = os.path.abspath(fname)
3154
+
3155
+ return outputs
0 commit comments