def prepare_arrays(data_images, vardata_images, mask_images):
    from .mask import intersect_masks
    # Compute mask intersection
    mask = intersect_masks(mask_images, threshold=1.)
     # Compute xyz coordinates from mask
    xyz = np.array(np.where(mask > 0))
    # Prepare data & vardata arrays
    data = np.array([(d.get_data()[xyz[0], xyz[1], xyz[2]]).squeeze()
                    for d in data_images]).squeeze()
    if vardata_images is None:
        vardata = None
    else:
        vardata = np.array([(d.get_data()[xyz[0], xyz[1], xyz[2]]).squeeze()
                            for d in vardata_images]).squeeze()
    return data, vardata, xyz, mask