@@ -165,10 +165,9 @@ class ArtifactDetectInputSpec(BaseInterfaceInputSpec):
165
165
desc = ("Use differences between successive motion (first element)"
166
166
"and intensity paramter (second element) estimates in order"
167
167
"to determine outliers. (default is [True, False])" ))
168
- use_norm = traits .Bool (True , requires = ['norm_threshold' ],
168
+ use_norm = traits .Bool (requires = ['norm_threshold' ],
169
169
desc = ("Uses a composite of the motion parameters in "
170
- "order to determine outliers." ),
171
- usedefault = True )
170
+ "order to determine outliers." ))
172
171
norm_threshold = traits .Float (desc = ("Threshold to use to detect motion-rela"
173
172
"ted outliers when composite motion is "
174
173
"being used" ), mandatory = True ,
@@ -307,7 +306,7 @@ def _list_outputs(self):
307
306
outputs ['intensity_files' ] = []
308
307
outputs ['statistic_files' ] = []
309
308
outputs ['mask_files' ] = []
310
- if isdefined (self .inputs .use_norm ) and self . inputs . use_norm :
309
+ if isdefined (self .inputs .norm_threshold ) :
311
310
outputs ['norm_files' ] = []
312
311
if self .inputs .bound_by_brainmask :
313
312
outputs ['displacement_files' ] = []
@@ -321,7 +320,7 @@ def _list_outputs(self):
321
320
outputs ['intensity_files' ].insert (i , intensityfile )
322
321
outputs ['statistic_files' ].insert (i , statsfile )
323
322
outputs ['mask_files' ].insert (i , maskfile )
324
- if isdefined (self .inputs .use_norm ) and self . inputs . use_norm :
323
+ if isdefined (self .inputs .norm_threshold ) :
325
324
outputs ['norm_files' ].insert (i , normfile )
326
325
if self .inputs .bound_by_brainmask :
327
326
outputs ['displacement_files' ].insert (i , displacementfile )
@@ -427,7 +426,7 @@ def _detect_outliers_core(self, imgfile, motionfile, runidx, cwd=None):
427
426
mask_img = Nifti1Image (mask .astype (np .uint8 ), affine )
428
427
mask_img .to_filename (maskfile )
429
428
430
- if self .inputs .use_norm :
429
+ if isdefined ( self .inputs .norm_threshold ) :
431
430
brain_pts = None
432
431
if self .inputs .bound_by_brainmask :
433
432
voxel_coords = np .nonzero (mask )
@@ -470,20 +469,20 @@ def _detect_outliers_core(self, imgfile, motionfile, runidx, cwd=None):
470
469
# write output to outputfile
471
470
np .savetxt (artifactfile , outliers , fmt = b'%d' , delimiter = ' ' )
472
471
np .savetxt (intensityfile , g , fmt = b'%.2f' , delimiter = ' ' )
473
- if self .inputs .use_norm :
472
+ if isdefined ( self .inputs .norm_threshold ) :
474
473
np .savetxt (normfile , normval , fmt = b'%.4f' , delimiter = ' ' )
475
474
476
475
if isdefined (self .inputs .save_plot ) and self .inputs .save_plot :
477
476
import matplotlib
478
477
matplotlib .use (config .get ("execution" , "matplotlib_backend" ))
479
478
import matplotlib .pyplot as plt
480
479
fig = plt .figure ()
481
- if isdefined (self .inputs .use_norm ) and self . inputs . use_norm :
480
+ if isdefined (self .inputs .norm_threshold ) :
482
481
plt .subplot (211 )
483
482
else :
484
483
plt .subplot (311 )
485
484
self ._plot_outliers_with_wave (gz , iidx , 'Intensity' )
486
- if isdefined (self .inputs .use_norm ) and self . inputs . use_norm :
485
+ if isdefined (self .inputs .norm_threshold ) :
487
486
plt .subplot (212 )
488
487
self ._plot_outliers_with_wave (normval , np .union1d (tidx , ridx ),
489
488
'Norm (mm)' )
@@ -521,7 +520,7 @@ def _detect_outliers_core(self, imgfile, motionfile, runidx, cwd=None):
521
520
'std' : np .std (gz , axis = 0 ).tolist ()},
522
521
]},
523
522
]
524
- if self .inputs .use_norm :
523
+ if isdefined ( self .inputs .norm_threshold ) :
525
524
stats .insert (3 , {'motion_norm' :
526
525
{'mean' : np .mean (normval , axis = 0 ).tolist (),
527
526
'min' : np .min (normval , axis = 0 ).tolist (),
0 commit comments