From fdb39b3d536d7f30db33e3fe76a46119cf40e87c Mon Sep 17 00:00:00 2001 From: ga84mun Date: Tue, 1 Sep 2026 12:08:55 +0000 Subject: [PATCH 1/2] dtye --- spineps/phase_post.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spineps/phase_post.py b/spineps/phase_post.py index 1a3b6b9..02ab57f 100644 --- a/spineps/phase_post.py +++ b/spineps/phase_post.py @@ -720,8 +720,8 @@ def detect_and_solve_merged_vertebra(seg_nii: NII, vert_nii: NII) -> tuple[NII, # first is significantly smaller than second and they are close in height # how many pixels are touching vert_firsttwo_arr = vert_nii.extract_label(first_key).get_seg_array() - vert_firsttwo_arr2 = vert_nii.extract_label(second_key).get_seg_array() - vert_firsttwo_arr += vert_firsttwo_arr2 + 1 + vert_firsttwo_arr2: np.ndarray = vert_nii.extract_label(second_key).get_seg_array() + vert_firsttwo_arr += vert_firsttwo_arr2.astype(vert_firsttwo_arr.dtype) + 1 contacts = np_contacts(vert_firsttwo_arr, connectivity=3) if contacts[(1, 2)] > isotropic_area_to_voxels(MERGED_VERTEBRA_MIN_CONTACT_MM2, vert_nii.zoom): logger.print("Found first two instance weird, will merge", Log_Type.STRANGE) From 4536b2859241a874c41921e43de50e890bd369cf Mon Sep 17 00:00:00 2001 From: Robert Graf Date: Mon, 7 Sep 2026 11:10:08 +0000 Subject: [PATCH 2/2] prevent rais errors --- spineps/phase_post.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/spineps/phase_post.py b/spineps/phase_post.py index 70506d7..4aa77b9 100644 --- a/spineps/phase_post.py +++ b/spineps/phase_post.py @@ -751,11 +751,10 @@ def detect_and_solve_merged_vertebra(seg_nii: NII, vert_nii: NII) -> tuple[NII, if first_stats[2] < MERGED_VERTEBRA_SIZE_RATIO * second_stats[2]: # first is significantly smaller than second and they are close in height # how many pixels are touching - vert_firsttwo_arr = vert_nii.extract_label(first_key).get_seg_array() - vert_firsttwo_arr2: np.ndarray = vert_nii.extract_label(second_key).get_seg_array() - vert_firsttwo_arr += vert_firsttwo_arr2.astype(vert_firsttwo_arr.dtype) + 1 + vert_firsttwo_arr = vert_nii.extract_label(first_key).get_seg_array().astype(np.uint8) + vert_firsttwo_arr[vert_nii.extract_label(second_key) > 0] = 2 # type: ignore contacts = np_contacts(vert_firsttwo_arr, connectivity=3) - if contacts[(1, 2)] > isotropic_area_to_voxels(MERGED_VERTEBRA_MIN_CONTACT_MM2, vert_nii.zoom): + if (1, 2) in contacts and contacts[(1, 2)] > isotropic_area_to_voxels(MERGED_VERTEBRA_MIN_CONTACT_MM2, vert_nii.zoom): logger.print("Found first two instance weird, will merge", Log_Type.STRANGE) vert_nii.map_labels_({first_key: second_key}, verbose=False)