def reconstruction_ratio(aligned_error, identity_error):
    """
    Calculates the reconstruction error
    as defined by Bazeille and
    colleagues (2019).

    A value greater than 0 indicates that
    voxels are predicted better by aligned data
    than by raw data.

    Parameters
    ----------
    aligned_error : float or ndarray of floats
        The reconstruction error from a given
        functional alignment method
    identity error :  float or ndarray of floats
        The reconstruction error from predicting
        the target subject as the source subject

    References
    ----------
    `Bazeille T., Richard H., Janati H., and Thirion B. (2019) Local
    Optimal Transport for Functional Brain Template Estimation.
    In: Chung A., Gee J., Yushkevich P., and Bao S. (eds) Information
    Processing in Medical Imaging. Lecture Notes in Computer Science,
    vol 11492. Springer, Cham.
    DOI: 10.1007/978-3-030-20351-1_18.`
    """
    num = 1 - aligned_error
    den = 1 - identity_error
    try:
        return 1 - (num / den)
    except ZeroDivisionError:
        return 0.0