@@ -219,3 +219,91 @@ def _list_outputs(self):
219219 outputs = self .output_spec ().get ()
220220 outputs ['out_file' ] = op .abspath (self .inputs .out_file )
221221 return outputs
222+
223+
224+ class LabelConvertInputSpec (CommandLineInputSpec ):
225+ in_file = File (
226+ exists = True ,
227+ argstr = '%s' ,
228+ mandatory = True ,
229+ position = - 4 ,
230+ desc = 'input anatomical image' )
231+ in_lut = File (
232+ exists = True ,
233+ argstr = '%s' ,
234+ mandatory = True ,
235+ position = - 3 ,
236+ desc = 'get information from '
237+ 'a basic lookup table consisting of index / name pairs' )
238+ in_config = File (
239+ exists = True ,
240+ argstr = '%s' ,
241+ position = - 2 ,
242+ desc = 'connectome configuration file' )
243+ out_file = File (
244+ 'parcellation.mif' ,
245+ argstr = '%s' ,
246+ mandatory = True ,
247+ position = - 1 ,
248+ usedefault = True ,
249+ desc = 'output file after processing' )
250+ spine = File (
251+ argstr = '-spine %s' ,
252+ desc = 'provide a manually-defined '
253+ 'segmentation of the base of the spine where the streamlines'
254+ ' terminate, so that this can become a node in the connection'
255+ ' matrix.' )
256+ num_threads = traits .Int (
257+ argstr = '-nthreads %d' ,
258+ desc = 'number of threads. if zero, the number'
259+ ' of available cpus will be used' ,
260+ nohash = True )
261+
262+
263+ class LabelConvertOutputSpec (TraitedSpec ):
264+ out_file = File (exists = True , desc = 'the output response file' )
265+
266+
267+ class LabelConvert (MRTrix3Base ):
268+ """
269+ Re-configure parcellation to be incrementally defined.
270+
271+ Example
272+ -------
273+
274+ >>> import nipype.interfaces.mrtrix3 as mrt
275+ >>> labels = mrt.LabelConvert()
276+ >>> labels.inputs.in_file = 'aparc+aseg.nii'
277+ >>> labels.inputs.in_config = 'mrtrix3_labelconfig.txt'
278+ >>> labels.inputs.in_lut = 'FreeSurferColorLUT.txt'
279+ >>> labels.cmdline
280+ 'labelconvert aparc+aseg.nii FreeSurferColorLUT.txt mrtrix3_labelconfig.txt parcellation.mif'
281+ >>> labels.run() # doctest: +SKIP
282+ """
283+
284+ _cmd = 'labelconvert'
285+ input_spec = LabelConvertInputSpec
286+ output_spec = LabelConvertOutputSpec
287+
288+ def _parse_inputs (self , skip = None ):
289+ if skip is None :
290+ skip = []
291+
292+ if not isdefined (self .inputs .in_config ):
293+ from nipype .utils .filemanip import which
294+ path = which (self ._cmd )
295+ if path is None :
296+ path = os .getenv (MRTRIX3_HOME , '/opt/mrtrix3' )
297+ else :
298+ path = op .dirname (op .dirname (path ))
299+
300+ self .inputs .in_config = op .join (
301+ path , 'src/dwi/tractography/connectomics/'
302+ 'example_configs/fs_default.txt' )
303+
304+ return super (LabelConvert , self )._parse_inputs (skip = skip )
305+
306+ def _list_outputs (self ):
307+ outputs = self .output_spec ().get ()
308+ outputs ['out_file' ] = op .abspath (self .inputs .out_file )
309+ return outputs
0 commit comments