lama/utilities/atlas_tools.py
def remove_unconected(image, label_num) -> np.ndarray:
    """
    Keep only the largest coonected componenet label with given label num. Zero out all other labels

    """
    from skimage.measure import label, regionprops
    image = np.copy(image)
    image[image != label_num] = 0
    relab = label(image)
    biggest_label = sorted(regionprops(relab), key=lambda x: x.area, reverse=True)[0].label
    image[:] = 0
    image[relab == biggest_label] = label_num
    return image

    Keep only the largest coonected componenet label with given label num. Zero out all other labels

    
Keep only the largest coonected componenet label with given label num. Zero out all other labels
Keep only the largest coonected componenet label with given label num . Zero out all other labels
def remove_unconected(image, label_num) -> np.ndarray:
    from skimage.measure import label, regionprops
    image = np.copy(image)
    image[image != label_num] = 0
    relab = label(image)
    biggest_label = sorted(regionprops(relab), key=lambda x: x.area, reverse=True)[0].label
    image[:] = 0
    image[relab == biggest_label] = label_num
    return image
def remove_unconected ( image , label_num ) -> np . ndarray : from skimage . measure import label , regionprops image = np . copy ( image ) image [ image != label_num ] = 0 relab = label ( image ) biggest_label = sorted ( regionprops ( relab ) , key = lambda x : x . area , reverse = True ) [ 0 ] . label image [ : ] = 0 image [ relab == biggest_label ] = label_num return image
Keep only the largest coonected componenet label with given label num.
Keep only the largest coonected componenet label with given label num .
"""
    Keep only the largest coonected componenet label with given label num. Zero out all other labels

    """
image
label_num