Skip to content

mean_center

Calculate the mean 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 mean center of the centroids as a numpy array with shape (2,).

Source code in src/histolytics/spatial_clust/centrography.py
def mean_center(xy: np.ndarray) -> np.ndarray:
    """Calculate the mean 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 mean center of the centroids as a numpy array with shape (2,).
    """
    return xy.mean(axis=0)