<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def haarpsi(data, ground_truth, a=4.2, c=None):
 r"""Haar-Wavelet based perceptual similarity index FOM. This function evaluates the structural similarity between two images based on edge features along the coordinate axes, analyzed with two wavelet filter levels. See `[Rei+2016] <https://arxiv.org/abs/1607.06140>`_ and the Notes section for further details. Parameters data : 2D array-like The image to compare to the ground truth. ground_truth : 2D array-like The true image with which to compare ``data``. It must have the same shape as ``data``. a : positive float, optional Parameter in the logistic function. Larger value leads to a steeper curve, thus lowering the threshold for an input to be mapped to an output close to 1. See Notes for details. The default value 4.2 is taken from the referenced paper. c : positive float, optional Constant determining the score of maximally dissimilar values. Smaller constant means higher penalty for dissimilarity. See `haarpsi_similarity_map` for details. For ``None``, the value is chosen as ``3 * sqrt(max(abs(ground_truth)))``. Returns ------- haarpsi : float between 0 and 1 The similarity score, where a higher score means a better match. See Notes for details. See Also -------- haarpsi_similarity_map haarpsi_weight_map Notes ----- For input images :math:`f_1, f_2`, the HaarPSI score is defined as .. math:: \mathrm{HaarPSI}_{f_1, f_2} = l_a^{-1} \left( \frac{ \sum_x \sum_{k=1}^2 \mathrm{HS}_{f_1, f_2}^{(k)}(x) \cdot \mathrm{W}_{f_1, f_2}^{(k)}(x)}{ \sum_x \sum_{k=1}^2 \mathrm{W}_{f_1, f_2}^{(k)}(x)} \right)^2 see `[Rei+2016] <https://arxiv.org/abs/1607.06140>`_ equation (12). For the definitions of the constituting functions, see - `haarpsi_similarity_map` for :math:`\mathrm{HS}_{f_1, f_2}^{(k)}`, - `haarpsi_weight_map` for :math:`\mathrm{W}_{f_1, f_2}^{(k)}`. References [Rei+2016] Reisenhofer, R, Bosse, S, Kutyniok, G, and Wiegand, T. *A Haar Wavelet-Based Perceptual Similarity Index for Image Quality Assessment*. arXiv:1607.06140 [cs], Jul. 2016. """

    import scipy.special
    from odl.contrib.fom.util import haarpsi_similarity_map, haarpsi_weight_map

    if c is None:
        c = 3 * np.sqrt(np.max(np.abs(ground_truth)))

    lsim_horiz = haarpsi_similarity_map(data, ground_truth, axis=0, c=c, a=a)
    lsim_vert = haarpsi_similarity_map(data, ground_truth, axis=1, c=c, a=a)

    wmap_horiz = haarpsi_weight_map(data, ground_truth, axis=0)
    wmap_vert = haarpsi_weight_map(data, ground_truth, axis=1)

    numer = np.sum(lsim_horiz * wmap_horiz + lsim_vert * wmap_vert)
    denom = np.sum(wmap_horiz + wmap_vert)

    return (scipy.special.logit(numer / denom) / a) ** 2