def dvars(func, mask, output_all=False, out_file=None):
    '\n    Compute the mean :abbr:`DVARS (D referring to temporal\n    derivative of timecourses, VARS referring to RMS variance over voxels)`\n    [Power2012]_.\n\n    Particularly, the *standardized* :abbr:`DVARS (D referring to temporal\n    derivative of timecourses, VARS referring to RMS variance over voxels)`\n    [Nichols2013]_ are computed.\n\n    .. note:: Implementation details\n\n      Uses the implementation of the `Yule-Walker equations\n      from nitime\n      <http://nipy.org/nitime/api/generated/nitime.algorithms.autoregressive.html#nitime.algorithms.autoregressive.AR_est_YW>`_\n      for the :abbr:`AR (auto-regressive)` filtering of the fMRI signal.\n\n    :param numpy.ndarray func: functional data, after head-motion-correction.\n    :param numpy.ndarray mask: a 3D mask of the brain\n    :param bool output_all: write out all dvars\n    :param str out_file: a path to which the standardized dvars should be saved.\n    :return: the standardized DVARS\n\n    '
    if (len(func.shape) != 4):
        raise RuntimeError(('Input fMRI dataset should be 4-dimensional' % func))
    zv_mask = zero_variance(func, mask)
    idx = np.where((zv_mask > 0))
    mfunc = func[idx[0], idx[1], idx[2], :]
    func_sd = ((np.percentile(mfunc, 75) - np.percentile(mfunc, 25)) / 1.349)
    mfunc -= mfunc.mean(axis=1)[(..., np.newaxis)]
    ak_coeffs = np.apply_along_axis(nta.AR_est_YW, 1, mfunc, 1)
    func_sd_pd = np.squeeze((np.sqrt((2 * (1 - ak_coeffs[:, 0])).tolist()) * func_sd))
    diff_sd_mean = func_sd_pd[(func_sd_pd > 0)].mean()
    func_diff = np.diff(mfunc, axis=1)
    dvars_nstd = func_diff.std(axis=0)
    dvars_stdz = (dvars_nstd / diff_sd_mean)
    diff_vx_stdz = (func_diff / np.array(([func_sd_pd] * func_diff.shape[(- 1)])).T)
    dvars_vx_stdz = diff_vx_stdz.std(1, ddof=1)
    if output_all:
        gendvars = np.vstack((dvars_stdz, dvars_nstd, dvars_vx_stdz))
    else:
        gendvars = dvars_stdz.reshape(len(dvars_stdz), 1)
    if (out_file is not None):
        np.savetxt(out_file, gendvars, fmt='%.12f')
    return gendvars
Compute the mean :abbr:`DVARS (D referring to temporal
derivative of timecourses, VARS referring to RMS variance over voxels)`
[Power2012]_.

Particularly, the *standardized* :abbr:`DVARS (D referring to temporal
derivative of timecourses, VARS referring to RMS variance over voxels)`
[Nichols2013]_ are computed.

.. note:: Implementation details

  Uses the implementation of the `Yule-Walker equations
  from nitime
  <http://nipy.org/nitime/api/generated/nitime.algorithms.autoregressive.html#nitime.algorithms.autoregressive.AR_est_YW>`_
  for the :abbr:`AR (auto-regressive)` filtering of the fMRI signal.

:param numpy.ndarray func: functional data, after head-motion-correction.
:param numpy.ndarray mask: a 3D mask of the brain
:param bool output_all: write out all dvars
:param str out_file: a path to which the standardized dvars should be saved.
:return: the standardized DVARS
def dvars(func, mask, output_all=False, out_file=None):
    '\n    Compute the mean :abbr:`DVARS (D referring to temporal\n    derivative of timecourses, VARS referring to RMS variance over voxels)`\n    [Power2012]_.\n\n    Particularly, the *standardized* :abbr:`DVARS (D referring to temporal\n    derivative of timecourses, VARS referring to RMS variance over voxels)`\n    [Nichols2013]_ are computed.\n\n    .. note:: Implementation details\n\n      Uses the implementation of the `Yule-Walker equations\n      from nitime\n      <http://nipy.org/nitime/api/generated/nitime.algorithms.autoregressive.html#nitime.algorithms.autoregressive.AR_est_YW>`_\n      for the :abbr:`AR (auto-regressive)` filtering of the fMRI signal.\n\n    :param numpy.ndarray func: functional data, after head-motion-correction.\n    :param numpy.ndarray mask: a 3D mask of the brain\n    :param bool output_all: write out all dvars\n    :param str out_file: a path to which the standardized dvars should be saved.\n    :return: the standardized DVARS\n\n    '
    if (len(func.shape) != 4):
        raise RuntimeError(('Input fMRI dataset should be 4-dimensional' % func))
    zv_mask = zero_variance(func, mask)
    idx = np.where((zv_mask > 0))
    mfunc = func[idx[0], idx[1], idx[2], :]
    func_sd = ((np.percentile(mfunc, 75) - np.percentile(mfunc, 25)) / 1.349)
    mfunc -= mfunc.mean(axis=1)[(..., np.newaxis)]
    ak_coeffs = np.apply_along_axis(nta.AR_est_YW, 1, mfunc, 1)
    func_sd_pd = np.squeeze((np.sqrt((2 * (1 - ak_coeffs[:, 0])).tolist()) * func_sd))
    diff_sd_mean = func_sd_pd[(func_sd_pd > 0)].mean()
    func_diff = np.diff(mfunc, axis=1)
    dvars_nstd = func_diff.std(axis=0)
    dvars_stdz = (dvars_nstd / diff_sd_mean)
    diff_vx_stdz = (func_diff / np.array(([func_sd_pd] * func_diff.shape[(- 1)])).T)
    dvars_vx_stdz = diff_vx_stdz.std(1, ddof=1)
    if output_all:
        gendvars = np.vstack((dvars_stdz, dvars_nstd, dvars_vx_stdz))
    else:
        gendvars = dvars_stdz.reshape(len(dvars_stdz), 1)
    if (out_file is not None):
        np.savetxt(out_file, gendvars, fmt='%.12f')
    return gendvars