clustering#


class DataCluster(*, datapoints: list[tuple[float, float]] | ndarray, center: tuple[floating[Any], floating[Any]])[source]#

Data class for a cluster of a tissue in a slice.

center: tuple[floating[Any], floating[Any]]#
datapoints: list[tuple[float, float]] | ndarray#
class TissueClusters(*, bones: list[DataCluster], tendons: list[DataCluster], ulnar: list[DataCluster])[source]#

Data class for all tissue clusters in a slice of a labelmap volume built using DBSCAN.

bones: list[DataCluster]#
classmethod from_labelmap_slice(labelmap_slice: ndarray) Self[source]#

Find clusters of all tissues in a slice using DBSCAN.

Parameters:

labelmap_slice -- image slice to cluster

get_cluster_for_label(label: TissueLabel) list[DataCluster][source]#

Get the clusters for a given tissue label.

tendons: list[DataCluster]#
ulnar: list[DataCluster]#
class TissueLabel(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#

Enum class for tissue labels in the labelmap volume.

BONES = 1#
TENDONS = 2#
ULNAR = 3#
find_DBSCAN_clusters(labelmap_slice: ndarray) list[DataCluster][source]#

Find clusters of a given tissue in a slice using DBSCAN.

cluster_iter(tissues: dict, slice: ndarray) TissueClusters[source]#

Find clusters of all tissues in a slice using a center-symmetric mask.

Parameters:
  • tissues -- dictionary of tissues and their values

  • slice -- image slice to cluster

Returns:

dictionary of tissues and their clusters.

find_DBSCAN_clusters(tissue_label: TissueLabel, labelmap_slice: ndarray, eps: float, min_samples: int) list[DataCluster][source]#

Find clusters of a given tissue in a slice using DBSCAN.

Parameters:
  • label -- value of the tissue to cluster

  • labelmap_slice -- slice of a labelmap volume, i.e., a 2D array with integers

  • eps -- The maximum distance between two samples for one to be considered as in the neighborhood of the other.

  • min_samples -- The number of samples (or total weight) in a neighborhood for a point to be considered as a core point.

Returns:

list of clusters and their centers.

find_clusters(tissue_value: int, slice: ndarray) list[DataCluster][source]#

Find clusters of a given tissue in a slice using a center-symmetric mask.

Parameters:
  • tissue_value -- value of the tissue to cluster

  • slice -- image slice to cluster

Returns:

list of clusters and their centers.