tumourkit.utils.postprocessing.get_greatest_connected_component
- tumourkit.utils.postprocessing.get_greatest_connected_component(idx: List[int], max_idx: int) Tuple[int, int]
Given a list of indices, returns the left and right value of the greatest connected component.
- Parameters:
idx (list[int]) – A list of indices.
max_idx (int) – The maximum index value.
- Returns:
A tuple containing the left and right values of the greatest connected component.
- Return type:
tuple(int, int)
This function takes a list of indices as input and returns the left and right values of the greatest connected component. Two indices are considered connected if they differ by one unit. The function loops over the indices, keeping track of the left and right indices of the current component. When a gap between indices is found, the function checks if the current component is greater than the previous greatest component and updates the left and right indices if it is. If the list of indices is circular (i.e., the first and last indices are connected), the function handles this case separately. The function returns a tuple containing the left and right values of the greatest connected component.