@@ -374,8 +374,11 @@ def _detect_outliers_core(self, imgfile, motionfile, runidx, cwd=None):
374
374
for t0 in range (timepoints ):
375
375
vol = data [:, :, :, t0 ]
376
376
# Use an SPM like approach
377
+ mask_tmp = vol > \
378
+ (_nanmean (vol ) / self .inputs .global_threshold )
379
+ g_vol = np .nansum (vol * mask_tmp )/ np .nansum (mask_tmp )
377
380
mask = mask * \
378
- (vol > ( _nanmean ( vol ) / self . inputs . global_threshold ) )
381
+ (vol > g_vol )
379
382
for t0 in range (timepoints ):
380
383
vol = data [:, :, :, t0 ]
381
384
g [t0 ] = _nanmean (vol [mask ])
@@ -384,10 +387,13 @@ def _detect_outliers_core(self, imgfile, motionfile, runidx, cwd=None):
384
387
g = np .zeros ((timepoints , 1 ))
385
388
if not intersect_mask :
386
389
iflogger .info ('not intersect_mask is True' )
390
+ mask = np .zeros ((x , y , z , timepoints ))
387
391
for t0 in range (timepoints ):
388
392
vol = data [:, :, :, t0 ]
389
- mask = vol > (_nanmean (vol ) / 8 )
390
- g [t0 ] = _nanmean (vol [mask ])
393
+ mask_tmp = vol > \
394
+ (_nanmean (vol ) / self .inputs .global_threshold )
395
+ mask [:, :, :, t0 ] = mask_tmp
396
+ g [t0 ] = np .nansum (vol * mask_tmp )/ np .nansum (mask_tmp )
391
397
elif masktype == 'file' : # uses a mask image to determine intensity
392
398
maskimg = load (self .inputs .mask_file )
393
399
mask = maskimg .get_data ()
0 commit comments