@@ -424,6 +424,8 @@ class EddyInputSpec(FSLCommandInputSpec):
424
424
'squares)' ))
425
425
repol = traits .Bool (False , argstr = '--repol' ,
426
426
desc = 'Detect and replace outlier slices' )
427
+ num_threads = traits .Int (1 , usedefault = True , nohash = True ,
428
+ desc = "Number of openmp threads to use" )
427
429
428
430
429
431
class EddyOutputSpec (TraitedSpec ):
@@ -465,6 +467,25 @@ class Eddy(FSLCommand):
465
467
input_spec = EddyInputSpec
466
468
output_spec = EddyOutputSpec
467
469
470
+ _num_threads = 1
471
+
472
+ def __init__ (self , ** inputs ):
473
+ super (Eddy , self ).__init__ (** inputs )
474
+ self .inputs .on_trait_change (self ._num_threads_update , 'num_threads' )
475
+
476
+ if not isdefined (self .inputs .num_threads ):
477
+ self .inputs .num_threads = self ._num_threads
478
+ else :
479
+ self ._num_threads_update ()
480
+
481
+ def _num_threads_update (self ):
482
+ self ._num_threads = self .inputs .num_threads
483
+ if not isdefined (self .inputs .num_threads ):
484
+ if 'OMP_NUM_THREADS' in self .inputs .environ :
485
+ del self .inputs .environ ['OMP_NUM_THREADS' ]
486
+ else :
487
+ self .inputs .environ ['OMP_NUM_THREADS' ] = self .inputs .num_threads
488
+
468
489
def _format_arg (self , name , spec , value ):
469
490
if name == 'in_topup_fieldcoef' :
470
491
return spec .argstr % value .split ('_fieldcoef' )[0 ]
0 commit comments