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