netneurotools.utils.get_centroids

netneurotools.utils.get_centroids(img, labels=None, image_space=False)[source]

Find centroids of labels in img.

Parameters:
  • img (niimg-like object) – 3D image containing integer label at each point

  • labels (array_like, optional) – List of labels for which to find centroids. If not specified all labels present in img will be used. Zero will be ignored as it is considered “background.” Default: None

  • image_space (bool, optional) – Whether to return xyz (image space) coordinates for centroids based on transformation in img.affine. Default: False

Returns:

centroids – Coordinates of centroids for ROIs in input data

Return type:

(N, 3) np.ndarray