From 20c009948bb6d6f41168a950db4c166c6f9c0b5d Mon Sep 17 00:00:00 2001 From: iback Date: Thu, 8 Feb 2024 09:44:22 +0000 Subject: [PATCH] another TPTBox update --- spineps/utils/proc_functions.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/spineps/utils/proc_functions.py b/spineps/utils/proc_functions.py index a158959..4db7add 100755 --- a/spineps/utils/proc_functions.py +++ b/spineps/utils/proc_functions.py @@ -3,7 +3,7 @@ from ants.utils.convert_nibabel import from_nibabel from scipy.ndimage import center_of_mass from TPTBox import NII, Logger_Interface -from TPTBox.core.np_utils import np_bbox_binary, np_count_nonzero, np_dilate_msk, np_unique +from TPTBox.core.np_utils import np_bbox_binary, np_count_nonzero, np_dilate_msk, np_unique, np_volume from tqdm import tqdm @@ -138,10 +138,10 @@ def clean_cc_artifacts( # majority voting dilated_m[dilated_m != 0] = 1 mult = mask_arr * dilated_m - labels, count = np.unique(mult, return_counts=True) - labels = labels[1:] - count = count[1:] - newlabel = labels[np.argmax(count)] + volumes = np_volume(mult) + nlabels = volumes.keys() + volumes_values = volumes.values() + newlabel = nlabels[np.argmax(volumes_values)] result_arr[mask_cc_l != 0] = newlabel logger.print(log_string + f"labeled as {newlabel}") if verbose else None # print(labels, count)