Skip to content

Commit 0ce153d

Browse files
committed
added intensity normalization
1 parent 8b6b263 commit 0ce153d

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

nipype/algorithms/confounds.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,16 @@ class ComputeDVARSInputSpec(BaseInterfaceInputSpec):
5252
desc='output figure size')
5353
figformat = traits.Enum('png', 'pdf', 'svg', usedefault=True,
5454
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.')
5565

5666

5767

@@ -128,7 +138,8 @@ def _gen_fname(self, suffix, ext=None):
128138

129139
def _run_interface(self, runtime):
130140
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)
132143

133144
(self._results['avg_std'],
134145
self._results['avg_nstd'],
@@ -595,7 +606,8 @@ def regress_poly(degree, data, remove_mean=True, axis=-1):
595606
# Back to original shape
596607
return regressed_data.reshape(datashape)
597608

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):
599611
"""
600612
Compute the :abbr:`DVARS (D referring to temporal
601613
derivative of timecourses, VARS referring to RMS variance over voxels)`
@@ -651,6 +663,9 @@ def compute_dvars(in_file, in_mask, remove_zerovariance=False):
651663
# Demean
652664
mfunc = regress_poly(0, mfunc, remove_mean=True).astype(np.float32)
653665

666+
if intensity_normalization != False:
667+
mfunc = (mfunc / np.median(mfunc)) * intensity_normalization
668+
654669
# Compute (non-robust) estimate of lag-1 autocorrelation
655670
ar1 = np.apply_along_axis(AR_est_YW, 1, mfunc, 1)[:, 0]
656671

0 commit comments

Comments
 (0)