@@ -1000,6 +1000,12 @@ def _list_outputs(self):
1000
1000
return self ._results
1001
1001
1002
1002
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
+ return AR_est_YW (x , order , rxx = rxx )[0 ]
1007
+
1008
+
1003
1009
def compute_dvars (
1004
1010
in_file ,
1005
1011
in_mask ,
@@ -1037,37 +1043,35 @@ def compute_dvars(
1037
1043
"""
1038
1044
import numpy as np
1039
1045
import nibabel as nb
1040
- from nitime .algorithms import AR_est_YW
1041
1046
import warnings
1042
1047
1043
- func = nb .load (in_file ).get_fdata ( dtype = np . float32 )
1044
- mask = np .asanyarray (nb .load (in_mask ).dataobj ). astype ( np . uint8 )
1048
+ func = np . float32 ( nb .load (in_file ).dataobj )
1049
+ mask = np .bool_ (nb .load (in_mask ).dataobj )
1045
1050
1046
1051
if len (func .shape ) != 4 :
1047
1052
raise RuntimeError ("Input fMRI dataset should be 4-dimensional" )
1048
1053
1049
- idx = np .where (mask > 0 )
1050
- mfunc = func [idx [0 ], idx [1 ], idx [2 ], :]
1054
+ mfunc = func [mask ]
1051
1055
1052
1056
if intensity_normalization != 0 :
1053
1057
mfunc = (mfunc / np .median (mfunc )) * intensity_normalization
1054
1058
1055
1059
# Robust standard deviation (we are using "lower" interpolation
1056
1060
# because this is what FSL is doing
1057
1061
func_sd = (
1058
- np .percentile (mfunc , 75 , axis = 1 , interpolation = "lower" )
1059
- - np .percentile (mfunc , 25 , axis = 1 , interpolation = "lower" )
1062
+ np .percentile (mfunc , 75 , axis = 1 , method = "lower" )
1063
+ - np .percentile (mfunc , 25 , axis = 1 , method = "lower" )
1060
1064
) / 1.349
1061
1065
1062
1066
if remove_zerovariance :
1063
- zero_variance_voxels = func_sd > self . inputs . variance_tol
1067
+ zero_variance_voxels = func_sd > variance_tol
1064
1068
mfunc = mfunc [zero_variance_voxels , :]
1065
1069
func_sd = func_sd [zero_variance_voxels ]
1066
1070
1067
1071
# Compute (non-robust) estimate of lag-1 autocorrelation
1068
1072
ar1 = np .apply_along_axis (
1069
- AR_est_YW , 1 , regress_poly (0 , mfunc , remove_mean = True )[0 ].astype (np .float32 ), 1
1070
- )[:, 0 ]
1073
+ _AR_est_YW , 1 , regress_poly (0 , mfunc , remove_mean = True )[0 ].astype (np .float32 ), 1
1074
+ )
1071
1075
1072
1076
# Compute (predicted) standard deviation of temporal difference time series
1073
1077
diff_sdhat = np .squeeze (np .sqrt (((1 - ar1 ) * 2 ).tolist ())) * func_sd
0 commit comments