def _get_data_dtype(img):
    """Returns the dtype of an image.
    If the image is non standard (no get_data_dtype member), this function
    relies on the data itself.
    """
    try:
        return img.get_data_dtype()
    except AttributeError:
        return img.get_data().dtype