def vector_to_volume(arr, mask, order='<STR_LIT:C>'):
if mask.dtype != np.bool:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if arr.ndim != <NUM_LIT:1>:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if arr.ndim == <NUM_LIT:2> and any(v == <NUM_LIT:1> for v in arr.shape):<EOL><INDENT>log.debug('<STR_LIT>'.format(arr.shape))<EOL>arr = arr.flatten()<EOL><DEDENT>volume = np.zeros(mask.shape[:<NUM_LIT:3>], dtype=arr.dtype, order=order)<EOL>volume[mask] = arr<EOL>return volume<EOL>
Transform a given vector to a volume. This is a reshape function for
    3D flattened and maybe masked vectors.

    Parameters
    ----------
    arr: np.array
        1-Dimensional array

    mask: numpy.ndarray
        Mask image. Must have 3 dimensions, bool dtype.

    Returns
    -------
    np.ndarray