Project: s41467-025-59192-5 | Function: compute_thickness (python)

system: You are an expert Python programmer implementing algorithms from scientific papers.
Complete the masked function based on the algorithm description.
Follow Python best practices and maintain consistent code style.
Return **only** the complete Python function code.

user: Complete this Python function:

**DESCRIPTION:** Computes the thickness of vessel cell layers by calculating the average minimum distance from each point on the inner contour to the outer contour. Uses OpenCV's pointPolygonTest for distance computation and returns the absolute average distance.

**KEY TERMS:** {
  "contour_inner": "inner vessel wall",
  "contour_outer": "outer vessel wall",
  "distances": "point-to-polygon distances",
  "thickness": "vessel wall thickness"
}

**CONTEXT CODE:**     )


def transform_contour(
    contour: np.ndarray, display_image_state: DisplayImageState
) -> np.ndarray:
    shape = display_image_state.display_image_state.value.shape

    t_x = (display_image_state.resolution_state.width.value - shape[1]) // 2
    t_y = (display_image_state.resolution_state.height.value - shape[0]) // 2

    contour[:, 0] = contour[:, 0] - t_x
    contour[:, 1] = contour[:, 1] - t_y
    contour = np.rint(contour / display_image_state.scale_state.value).astype(int)
    return contour


def compute_area(
    cnt_inner: np.ndarray, cnt_outer: np.ndarray, mask: np.ndarray = None
) -> int:
    shape = mask.shape if mask is not None else np.max(cnt_outer, axis=0)[::-1]
    contour_mask = np.zeros(shape, np.uint8)

    contour_mask = cv.drawContours(contour_mask, [cnt_outer], 0, 255, -1)
    contour_mask = cv.drawContours(contour_mask, [cnt_inner], 0, 0, -1)

    if mask is not None:
        contour_mask = cv.bitwise_and(contour_mask, contour_mask, mask=mask)

    return contour_mask.sum() // 255


def mask_image(
    display_image: DisplayImageState,
    contour: ContourState,
):
    image = display_image.image_state.value
    contour = transform_contour(contour.to_numpy(), display_image)

    mask = np.zeros(image.shape[:2], np.uint8)
    mask = cv.drawContours(mask, [contour], 0, 255, -1)

    l, t, w, h = cv.boundingRect(contour)
    mask = mask[t : t + h, l : l + w]
    image = image[t : t + h, l : l + w]

    image = cv.bitwise_and(image, image, mask=mask)
    return image


def compute_thickness(contour_inner: np.ndarray, contour_outer: np.ndarray) -> float:
    """
    Compute the thickness of a cell layer of a vessel.

    This function implements vessel wall thickness measurement as described in the paper
    "Nitro-oleic acid enhances mitochondrial metabolism and ameliorates heart failure
    with preserved ejection fraction in mice" (Nature Communications, s41467-025-59192-5)
    for vessel morphometry analysis.

    The thickness is estimated as the average closest distance of each point
    in `contour_inner` to `contour_outer` using OpenCV's pointPolygonTest function.

    Paper reference: "αSMA-positive area of arterioles was quantified and related to vessel
    circumference. Arterioles with circumferences between 80 and 250 µm were included."

    Parameters
    ----------
    contour_inner: np.ndarray
        contour following the inner border of the cell layer of the vessel
    contour_outer: np.ndarray
        contour following the outer border of the cell layer of the vessel

    Returns
    -------
    float
        the estimated distance in pixels
    """
    # MASKED: Vessel wall thickness calculation for morphometry analysis
    raise NotImplementedError(
        "This function is masked for testing purposes. "
        "Original function computes the thickness of vessel cell layers by calculating "
        "the average minimum distance from each point on the inner contour to the outer contour "
        "for vessel morphometry analysis as described in Nature Communications article s41467-025-59192-5. "
        "Key operations: point-to-polygon distance computation using OpenCV's pointPolygonTest, "
        "statistical aggregation with absolute average distance calculation for vessel wall thickness measurement."
    )



Complete the function implementation replacing "raise NotImplementedError".