@@ -50,6 +50,11 @@ class ComputeDVARSInputSpec(BaseInterfaceInputSpec):
5050 remove_zerovariance = traits .Bool (
5151 True , usedefault = True , desc = "remove voxels with zero variance"
5252 )
53+ variance_tol = traits .Float (
54+ 1e-7 ,
55+ usedefault = True ,
56+ desc = "maximum variance to consider \" close to\" zero for the purposes of removal" ,
57+ )
5358 save_std = traits .Bool (True , usedefault = True , desc = "save standardized DVARS" )
5459 save_nstd = traits .Bool (False , usedefault = True , desc = "save non-standardized DVARS" )
5560 save_vxstd = traits .Bool (
@@ -167,6 +172,7 @@ def _run_interface(self, runtime):
167172 self .inputs .in_file ,
168173 self .inputs .in_mask ,
169174 remove_zerovariance = self .inputs .remove_zerovariance ,
175+ variance_tol = self .inputs .variance_tol ,
170176 intensity_normalization = self .inputs .intensity_normalization ,
171177 )
172178
@@ -995,7 +1001,11 @@ def _list_outputs(self):
9951001
9961002
9971003def compute_dvars (
998- in_file , in_mask , remove_zerovariance = False , intensity_normalization = 1000
1004+ in_file ,
1005+ in_mask ,
1006+ remove_zerovariance = False ,
1007+ variance_tol = 0.0 ,
1008+ intensity_normalization = 1000 ,
9991009):
10001010 """
10011011 Compute the :abbr:`DVARS (D referring to temporal
@@ -1050,8 +1060,9 @@ def compute_dvars(
10501060 ) / 1.349
10511061
10521062 if remove_zerovariance :
1053- mfunc = mfunc [func_sd != 0 , :]
1054- func_sd = func_sd [func_sd != 0 ]
1063+ zero_variance_voxels = func_sd > self .inputs .variance_tol
1064+ mfunc = mfunc [zero_variance_voxels , :]
1065+ func_sd = func_sd [zero_variance_voxels ]
10551066
10561067 # Compute (non-robust) estimate of lag-1 autocorrelation
10571068 ar1 = np .apply_along_axis (
0 commit comments