def calculate_DVARS(rest, mask):
    """
    Method to calculate DVARS as per power's method

    Parameters
    ----------
    rest : string (nifti file)
        path to motion correct functional data

    mask : string (nifti file)
        path to brain only mask for functional data

    Returns
    -------
    out_file : string (numpy mat file)
        path to file containing  array of DVARS
        calculation for each voxel
    """
    import os
    import numpy as np
    import nibabel as nib
    out_file = 'DVARS.npy'
    rest_data = nib.load(rest).get_data().astype(np.float32)
    mask_data = nib.load(mask).get_data().astype('bool')
    data = np.square(np.diff(rest_data, axis=3))
    data = data[mask_data]
    DVARS = np.sqrt(np.mean(data, axis=0))
    np.save(out_file, DVARS)
    return os.path.abspath(out_file)
