def _partition_data(datavol, roivol, roivalue, maskvol=None, zeroe=True):
if maskvol is not None:<EOL><INDENT>indices = (roivol == roivalue) * (maskvol > <NUM_LIT:0>)<EOL><DEDENT>else:<EOL><INDENT>indices = roivol == roivalue<EOL><DEDENT>if datavol.ndim == <NUM_LIT:4>:<EOL><INDENT>ts = datavol[indices, :]<EOL><DEDENT>else:<EOL><INDENT>ts = datavol[indices]<EOL><DEDENT>if zeroe:<EOL><INDENT>if datavol.ndim == <NUM_LIT:4>:<EOL><INDENT>ts = ts[ts.sum(axis=<NUM_LIT:1>) != <NUM_LIT:0>, :]<EOL><DEDENT><DEDENT>return ts<EOL>
Extracts the values in `datavol` that are in the ROI with value `roivalue` in `roivol`.
    The ROI can be masked by `maskvol`.

    Parameters
    ----------
    datavol: numpy.ndarray
        4D timeseries volume or a 3D volume to be partitioned

    roivol: numpy.ndarray
        3D ROIs volume

    roivalue: int or float
        A value from roivol that represents the ROI to be used for extraction.

    maskvol: numpy.ndarray
        3D mask volume

    zeroe: bool
        If true will remove the null timeseries voxels.  Only applied to timeseries (4D) data.

    Returns
    -------
    values: np.array
        An array of the values in the indicated ROI.
        A 2D matrix if `datavol` is 4D or a 1D vector if `datavol` is 3D.