@@ -651,22 +651,22 @@ def compute_dvars(in_file, in_mask, remove_zerovariance=False,
651651 idx = np .where (mask > 0 )
652652 mfunc = func [idx [0 ], idx [1 ], idx [2 ], :]
653653
654- # Demean
655- mfunc = regress_poly (0 , mfunc , remove_mean = True ).astype (np .float32 )
656-
657654 if intensity_normalization != 0 :
658655 mfunc = (mfunc / np .median (mfunc )) * intensity_normalization
659656
660- # Robust standard deviation
661- func_sd = (np .percentile (mfunc , 75 , axis = 1 ) -
662- np .percentile (mfunc , 25 , axis = 1 )) / 1.349
657+ # Robust standard deviation (we are using "lower" interpolation
658+ # because this is what FSL is doing
659+ func_sd = (np .percentile (mfunc , 75 , axis = 1 , interpolation = "lower" ) -
660+ np .percentile (mfunc , 25 , axis = 1 , interpolation = "lower" )) / 1.349
663661
664662 if remove_zerovariance :
665663 mfunc = mfunc [func_sd != 0 , :]
666664 func_sd = func_sd [func_sd != 0 ]
667665
668666 # Compute (non-robust) estimate of lag-1 autocorrelation
669- ar1 = np .apply_along_axis (AR_est_YW , 1 , mfunc , 1 )[:, 0 ]
667+ ar1 = np .apply_along_axis (AR_est_YW , 1 ,
668+ regress_poly (0 , mfunc , remove_mean = True ).astype (
669+ np .float32 ), 1 )[:, 0 ]
670670
671671 # Compute (predicted) standard deviation of temporal difference time series
672672 diff_sdhat = np .squeeze (np .sqrt (((1 - ar1 ) * 2 ).tolist ())) * func_sd
@@ -681,11 +681,12 @@ def compute_dvars(in_file, in_mask, remove_zerovariance=False,
681681 # standardization
682682 dvars_stdz = dvars_nstd / diff_sd_mean
683683
684- with warnings .catch_warnings (): # catch, e.g., divide by zero errors
684+ with warnings .catch_warnings (): # catch, e.g., divide by zero errors
685685 warnings .filterwarnings ('error' )
686686
687687 # voxelwise standardization
688- diff_vx_stdz = np .square (func_diff ) / np .array ([diff_sdhat ] * func_diff .shape [- 1 ]).T
688+ diff_vx_stdz = np .square (
689+ func_diff / np .array ([diff_sdhat ] * func_diff .shape [- 1 ]).T )
689690 dvars_vx_stdz = np .sqrt (diff_vx_stdz .mean (axis = 0 ))
690691
691692 return (dvars_stdz , dvars_nstd , dvars_vx_stdz )
0 commit comments