@@ -1000,6 +1000,13 @@ def _list_outputs(self):
10001000 return self ._results
10011001
10021002
1003+ def _AR_est_YW (x , order , rxx = None ):
1004+ """Retrieve AR coefficients while dropping the sig_sq return value"""
1005+ from nitime .algorithms import AR_est_YW
1006+
1007+ return AR_est_YW (x , order , rxx = rxx )[0 ]
1008+
1009+
10031010def compute_dvars (
10041011 in_file ,
10051012 in_mask ,
@@ -1037,37 +1044,35 @@ def compute_dvars(
10371044 """
10381045 import numpy as np
10391046 import nibabel as nb
1040- from nitime .algorithms import AR_est_YW
10411047 import warnings
10421048
1043- func = nb .load (in_file ).get_fdata ( dtype = np . float32 )
1044- mask = np .asanyarray (nb .load (in_mask ).dataobj ). astype ( np . uint8 )
1049+ func = np . float32 ( nb .load (in_file ).dataobj )
1050+ mask = np .bool_ (nb .load (in_mask ).dataobj )
10451051
10461052 if len (func .shape ) != 4 :
10471053 raise RuntimeError ("Input fMRI dataset should be 4-dimensional" )
10481054
1049- idx = np .where (mask > 0 )
1050- mfunc = func [idx [0 ], idx [1 ], idx [2 ], :]
1055+ mfunc = func [mask ]
10511056
10521057 if intensity_normalization != 0 :
10531058 mfunc = (mfunc / np .median (mfunc )) * intensity_normalization
10541059
10551060 # Robust standard deviation (we are using "lower" interpolation
10561061 # because this is what FSL is doing
10571062 func_sd = (
1058- np .percentile (mfunc , 75 , axis = 1 , interpolation = "lower" )
1059- - np .percentile (mfunc , 25 , axis = 1 , interpolation = "lower" )
1063+ np .percentile (mfunc , 75 , axis = 1 , method = "lower" )
1064+ - np .percentile (mfunc , 25 , axis = 1 , method = "lower" )
10601065 ) / 1.349
10611066
10621067 if remove_zerovariance :
1063- zero_variance_voxels = func_sd > self . inputs . variance_tol
1068+ zero_variance_voxels = func_sd > variance_tol
10641069 mfunc = mfunc [zero_variance_voxels , :]
10651070 func_sd = func_sd [zero_variance_voxels ]
10661071
10671072 # Compute (non-robust) estimate of lag-1 autocorrelation
10681073 ar1 = np .apply_along_axis (
1069- AR_est_YW , 1 , regress_poly (0 , mfunc , remove_mean = True )[0 ].astype (np .float32 ), 1
1070- )[:, 0 ]
1074+ _AR_est_YW , 1 , regress_poly (0 , mfunc , remove_mean = True )[0 ].astype (np .float32 ), 1
1075+ )
10711076
10721077 # Compute (predicted) standard deviation of temporal difference time series
10731078 diff_sdhat = np .squeeze (np .sqrt (((1 - ar1 ) * 2 ).tolist ())) * func_sd
0 commit comments