Skip to content

median_center

Calculate the manhattan median center of a GeoDataFrame containing nuclei.

Parameters:

Name Type Description Default
xy ndarray

A numpy array of shape (n, 2) containing the x and y coordinates. (centroids of the nuclei).

required

Returns:

Type Description
ndarray

np.ndarray: The median center of the centroids as a numpy array with shape (2,).

Source code in src/histolytics/spatial_clust/centrography.py
def median_center(xy: np.ndarray) -> np.ndarray:
    """Calculate the manhattan median center of a GeoDataFrame containing nuclei.

    Parameters:
        xy (np.ndarray):
            A numpy array of shape (n, 2) containing the x and y coordinates.
            (centroids of the nuclei).

    Returns:
        np.ndarray:
            The median center of the centroids as a numpy array with shape (2,).
    """
    return xy.median(axis=0)