@@ -73,7 +73,11 @@ class DWI2SphericalHarmonicsImage(CommandLine):
73
73
74
74
def _list_outputs (self ):
75
75
outputs = self .output_spec ().get ()
76
- outputs ['spherical_harmonics_image' ] = op .abspath (self ._gen_outfilename ())
76
+ outputs ['spherical_harmonics_image' ] = self .inputs .out_filename
77
+ if not isdefined (outputs ['spherical_harmonics_image' ]):
78
+ outputs ['spherical_harmonics_image' ] = op .abspath (self ._gen_outfilename ())
79
+ else :
80
+ outputs ['spherical_harmonics_image' ] = op .abspath (outputs ['spherical_harmonics_image' ])
77
81
return outputs
78
82
79
83
def _gen_filename (self , name ):
@@ -148,7 +152,11 @@ class ConstrainedSphericalDeconvolution(CommandLine):
148
152
149
153
def _list_outputs (self ):
150
154
outputs = self .output_spec ().get ()
151
- outputs ['spherical_harmonics_image' ] = op .abspath (self ._gen_outfilename ())
155
+ outputs ['spherical_harmonics_image' ] = self .inputs .out_filename
156
+ if not isdefined (outputs ['spherical_harmonics_image' ]):
157
+ outputs ['spherical_harmonics_image' ] = op .abspath (self ._gen_outfilename ())
158
+ else :
159
+ outputs ['spherical_harmonics_image' ] = op .abspath (outputs ['spherical_harmonics_image' ])
152
160
return outputs
153
161
154
162
def _gen_filename (self , name ):
@@ -194,7 +202,11 @@ class EstimateResponseForSH(CommandLine):
194
202
195
203
def _list_outputs (self ):
196
204
outputs = self .output_spec ().get ()
197
- outputs ['response' ] = op .abspath (self ._gen_outfilename ())
205
+ outputs ['response' ] = self .inputs .out_filename
206
+ if not isdefined (outputs ['response' ]):
207
+ outputs ['response' ] = op .abspath (self ._gen_outfilename ())
208
+ else :
209
+ outputs ['response' ] = op .abspath (outputs ['response' ])
198
210
return outputs
199
211
200
212
def _gen_filename (self , name ):
@@ -282,3 +294,109 @@ def _gen_outfilename(self):
282
294
_ , bvec , _ = split_filename (self .inputs .bvec_file )
283
295
_ , bval , _ = split_filename (self .inputs .bval_file )
284
296
return bvec + '_' + bval + '.txt'
297
+
298
+
299
+ class GenerateDirectionsInputSpec (CommandLineInputSpec ):
300
+ num_dirs = traits .Int (mandatory = True , argstr = '%s' , position = - 2 , desc = 'the number of directions to generate.' )
301
+
302
+ power = traits .Float (argstr = '-power %s' , desc = 'specify exponent to use for repulsion power law.' )
303
+ niter = traits .Int (argstr = '-niter %s' , desc = 'specify the maximum number of iterations to perform.' )
304
+ display_info = traits .Bool (argstr = '-info' , desc = 'Display information messages.' )
305
+ quiet_display = traits .Bool (argstr = '-quiet' , desc = 'do not display information messages or progress status.' )
306
+ display_debug = traits .Bool (argstr = '-debug' , desc = 'Display debugging messages.' )
307
+ out_file = File ("directions.txt" , argstr = '%s' , hash_files = False ,
308
+ position = - 1 , desc = 'the text file to write the directions to, as [ az el ] pairs.' , usedefault = True )
309
+
310
+ class GenerateDirectionsOutputSpec (TraitedSpec ):
311
+ out_file = File (exists = True , desc = 'directions file' )
312
+
313
+ class GenerateDirections (CommandLine ):
314
+ """
315
+ generate a set of directions evenly distributed over a hemisphere.
316
+
317
+ Example
318
+ -------
319
+
320
+ >>> import nipype.interfaces.mrtrix as mrt
321
+ >>> gendir = mrt.GenerateDirections()
322
+ >>> gendir.inputs.num_dirs = 300
323
+ >>> gendir.run() # doctest: +SKIP
324
+ """
325
+
326
+ _cmd = 'gendir'
327
+ input_spec = GenerateDirectionsInputSpec
328
+ output_spec = GenerateDirectionsOutputSpec
329
+
330
+
331
+ class FindShPeaksInputSpec (CommandLineInputSpec ):
332
+ in_file = File (exists = True , argstr = '%s' , mandatory = True , position = - 3 , desc = 'the input image of SH coefficients.' )
333
+ directions_file = File (exists = True , argstr = '%s' , mandatory = True , position = - 2 , desc = 'the set of directions to use as seeds for the peak finding' )
334
+ peaks_image = File (exists = True , argstr = '-peaks %s' , desc = 'the program will try to find the peaks that most closely match those in the image provided' )
335
+ num_peaks = traits .Int (argstr = '-num %s' , desc = 'the number of peaks to extract (default is 3)' )
336
+ peak_directions = traits .List (traits .Float , argstr = '-direction %s' , sep = ' ' , minlen = 2 , maxlen = 2 ,
337
+ desc = 'phi theta. the direction of a peak to estimate. The algorithm will attempt to find the same number of peaks as have been specified using this option ' \
338
+ ' phi: the azimuthal angle of the direction (in degrees). theta: the elevation angle of the direction (in degrees, from the vertical z-axis)' )
339
+ peak_threshold = traits .Float (argstr = '-threshold %s' , desc = 'only peak amplitudes greater than the threshold will be considered' )
340
+ display_info = traits .Bool (argstr = '-info' , desc = 'Display information messages.' )
341
+ quiet_display = traits .Bool (argstr = '-quiet' , desc = 'do not display information messages or progress status.' )
342
+ display_debug = traits .Bool (argstr = '-debug' , desc = 'Display debugging messages.' )
343
+ out_file = File (name_template = "%s_peak_dirs.mif" , keep_extension = False , argstr = '%s' , hash_files = False , position = - 1 ,
344
+ desc = 'the output image. Each volume corresponds to the x, y & z component of each peak direction vector in turn' , name_source = ["in_file" ])
345
+
346
+ class FindShPeaksOutputSpec (TraitedSpec ):
347
+ out_file = File (exists = True , desc = 'Peak directions image' )
348
+
349
+ class FindShPeaks (CommandLine ):
350
+ """
351
+ identify the orientations of the N largest peaks of a SH profile
352
+
353
+ Example
354
+ -------
355
+
356
+ >>> import nipype.interfaces.mrtrix as mrt
357
+ >>> shpeaks = mrt.FindShPeaks()
358
+ >>> shpeaks.inputs.in_file = 'csd.mif'
359
+ >>> shpeaks.inputs.directions_file = 'dirs.txt'
360
+ >>> shpeaks.inputs.num_peaks = 2
361
+ >>> shpeaks.run() # doctest: +SKIP
362
+ """
363
+
364
+ _cmd = 'find_SH_peaks'
365
+ input_spec = FindShPeaksInputSpec
366
+ output_spec = FindShPeaksOutputSpec
367
+
368
+
369
+
370
+ class Directions2AmplitudeInputSpec (CommandLineInputSpec ):
371
+ in_file = File (exists = True , argstr = '%s' , mandatory = True , position = - 2 , desc = 'the input directions image. Each volume corresponds to the x, y & z component of each direction vector in turn.' )
372
+ peaks_image = File (exists = True , argstr = '-peaks %s' , desc = 'the program will try to find the peaks that most closely match those in the image provided' )
373
+ num_peaks = traits .Int (argstr = '-num %s' , desc = 'the number of peaks to extract (default is 3)' )
374
+ peak_directions = traits .List (traits .Float , argstr = '-direction %s' , sep = ' ' , minlen = 2 , maxlen = 2 ,
375
+ desc = 'phi theta. the direction of a peak to estimate. The algorithm will attempt to find the same number of peaks as have been specified using this option ' \
376
+ ' phi: the azimuthal angle of the direction (in degrees). theta: the elevation angle of the direction (in degrees, from the vertical z-axis)' )
377
+ display_info = traits .Bool (argstr = '-info' , desc = 'Display information messages.' )
378
+ quiet_display = traits .Bool (argstr = '-quiet' , desc = 'do not display information messages or progress status.' )
379
+ display_debug = traits .Bool (argstr = '-debug' , desc = 'Display debugging messages.' )
380
+ out_file = File (name_template = "%s_amplitudes.mif" , keep_extension = False , argstr = '%s' , hash_files = False , position = - 1 ,
381
+ desc = 'the output amplitudes image' , name_source = ["in_file" ])
382
+
383
+ class Directions2AmplitudeOutputSpec (TraitedSpec ):
384
+ out_file = File (exists = True , desc = 'amplitudes image' )
385
+
386
+ class Directions2Amplitude (CommandLine ):
387
+ """
388
+ convert directions image to amplitudes
389
+
390
+ Example
391
+ -------
392
+
393
+ >>> import nipype.interfaces.mrtrix as mrt
394
+ >>> amplitudes = mrt.Directions2Amplitude()
395
+ >>> amplitudes.inputs.in_file = 'peak_directions.mif'
396
+ >>> amplitudes.run() # doctest: +SKIP
397
+ """
398
+
399
+ _cmd = 'dir2amp'
400
+ input_spec = Directions2AmplitudeInputSpec
401
+ output_spec = Directions2AmplitudeOutputSpec
402
+
0 commit comments