@@ -52,6 +52,16 @@ class ComputeDVARSInputSpec(BaseInterfaceInputSpec):
52
52
desc = 'output figure size' )
53
53
figformat = traits .Enum ('png' , 'pdf' , 'svg' , usedefault = True ,
54
54
desc = 'output format for figures' )
55
+ intensity_normalization = traits .Float (1000.0 , usedefault = True ,
56
+ desc = 'Divide value in each voxel at each timepoint '
57
+ 'by the median calculated across all voxels'
58
+ 'and timepoints within the mask (if specified)'
59
+ 'and then multiply by the value specified by'
60
+ 'this parameter. By using the default (1000)' \
61
+ 'output DVARS will be expressed in ' \
62
+ 'x10 % BOLD units compatible with Power et al.' \
63
+ '2012. Set this to 0 to disable intensity' \
64
+ 'normalization altogether.' )
55
65
56
66
57
67
@@ -128,7 +138,8 @@ def _gen_fname(self, suffix, ext=None):
128
138
129
139
def _run_interface (self , runtime ):
130
140
dvars = compute_dvars (self .inputs .in_file , self .inputs .in_mask ,
131
- remove_zerovariance = self .inputs .remove_zerovariance )
141
+ remove_zerovariance = self .inputs .remove_zerovariance ,
142
+ intensity_normalization = self .inputs .intensity_normalization )
132
143
133
144
(self ._results ['avg_std' ],
134
145
self ._results ['avg_nstd' ],
@@ -595,7 +606,8 @@ def regress_poly(degree, data, remove_mean=True, axis=-1):
595
606
# Back to original shape
596
607
return regressed_data .reshape (datashape )
597
608
598
- def compute_dvars (in_file , in_mask , remove_zerovariance = False ):
609
+ def compute_dvars (in_file , in_mask , remove_zerovariance = False ,
610
+ intensity_normalization = 1000 ):
599
611
"""
600
612
Compute the :abbr:`DVARS (D referring to temporal
601
613
derivative of timecourses, VARS referring to RMS variance over voxels)`
@@ -651,6 +663,9 @@ def compute_dvars(in_file, in_mask, remove_zerovariance=False):
651
663
# Demean
652
664
mfunc = regress_poly (0 , mfunc , remove_mean = True ).astype (np .float32 )
653
665
666
+ if intensity_normalization != False :
667
+ mfunc = (mfunc / np .median (mfunc )) * intensity_normalization
668
+
654
669
# Compute (non-robust) estimate of lag-1 autocorrelation
655
670
ar1 = np .apply_along_axis (AR_est_YW , 1 , mfunc , 1 )[:, 0 ]
656
671
0 commit comments