From 4e94a4b21b2cd58cc5bda5a7502a35903a05b09e Mon Sep 17 00:00:00 2001 From: gu53lif Date: Wed, 28 Jan 2026 10:34:40 +0100 Subject: [PATCH 1/2] update Full_Body_Instance (hip -> pelvis) --- TPTBox/core/vert_constants.py | 38 ++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/TPTBox/core/vert_constants.py b/TPTBox/core/vert_constants.py index 62ec764..3d6038b 100755 --- a/TPTBox/core/vert_constants.py +++ b/TPTBox/core/vert_constants.py @@ -30,7 +30,9 @@ ORIGIN = TRIPLE -LABEL_MAP = Union[dict[Union[int, str], Union[int, str]], dict[str, str], dict[int, int]] +LABEL_MAP = Union[ + dict[Union[int, str], Union[int, str]], dict[str, str], dict[int, int] +] LABEL_REFERENCE = Union[int, Sequence[int], None] @@ -190,8 +192,8 @@ class Full_Body_Instance_Vibe(Abstract_lvl): clavicula_right = 47 femur_left = 48 femur_right = 49 - hip_left = 50 - hip_right = 51 + pelvis_left = 50 + pelvis_right = 51 spinal_cord = 52 gluteus_maximus_left = 53 gluteus_maximus_right = 54 @@ -232,8 +234,8 @@ class Full_Body_Instance(Abstract_lvl): vert_body = 9 vert_post = 10 sacrum = 11 - hip_right = 12 - hip_left = 112 + pelvis_right = 12 + pelvis_left = 112 femur_right = 13 femur_left = 113 patella_right = 14 @@ -370,7 +372,9 @@ def __init__( self._endplate = None if has_rib: self._rib = ( - vertebra_label + VERTEBRA_INSTANCE_RIB_LABEL_OFFSET if vertebra_label != 28 else 21 + VERTEBRA_INSTANCE_RIB_LABEL_OFFSET + vertebra_label + VERTEBRA_INSTANCE_RIB_LABEL_OFFSET + if vertebra_label != 28 + else 21 + VERTEBRA_INSTANCE_RIB_LABEL_OFFSET ) if has_ivd: self._ivd = vertebra_label + VERTEBRA_INSTANCE_IVD_LABEL_OFFSET @@ -465,7 +469,13 @@ def order_dict(cls) -> dict[int, int]: return {a.value: e for e, a in enumerate(cls.order())} def get_next_poi(self, poi: POI | NII | list[int]): - r = poi if isinstance(poi, list) else poi.keys_region() if hasattr(poi, "keys_region") else poi.unique() # type: ignore + r = ( + poi + if isinstance(poi, list) + else poi.keys_region() + if hasattr(poi, "keys_region") + else poi.unique() + ) # type: ignore o = self.order() idx = o.index(self) for vert in o[idx + 1 :]: @@ -474,7 +484,13 @@ def get_next_poi(self, poi: POI | NII | list[int]): return None def get_previous_poi(self, poi: POI | NII | list[int]): - r = poi if isinstance(poi, list) else poi.keys_region() if hasattr(poi, "keys_region") else poi.unique() # type: ignore + r = ( + poi + if isinstance(poi, list) + else poi.keys_region() + if hasattr(poi, "keys_region") + else poi.unique() + ) # type: ignore o = self.order() idx = o.index(self) for vert in reversed(o[:idx]): @@ -528,7 +544,11 @@ def RIB(self) -> int: @classmethod def rib2vert(cls, riblabel: int) -> int: assert riblabel in Vertebra_Instance.rib_label(), riblabel - return riblabel - VERTEBRA_INSTANCE_RIB_LABEL_OFFSET if riblabel != 21 + VERTEBRA_INSTANCE_RIB_LABEL_OFFSET else 28 + return ( + riblabel - VERTEBRA_INSTANCE_RIB_LABEL_OFFSET + if riblabel != 21 + VERTEBRA_INSTANCE_RIB_LABEL_OFFSET + else 28 + ) @property def IVD(self) -> int: From 82713e4f705b2b1fad73eee69e41752a166f2173 Mon Sep 17 00:00:00 2001 From: Robert Graf Date: Wed, 4 Feb 2026 14:16:02 +0000 Subject: [PATCH 2/2] remove PLW0108 and FURB171 --- TPTBox/core/dicom/dicom_header_to_keys.py | 2 +- pyproject.toml | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/TPTBox/core/dicom/dicom_header_to_keys.py b/TPTBox/core/dicom/dicom_header_to_keys.py index b9156ec..b2ce879 100644 --- a/TPTBox/core/dicom/dicom_header_to_keys.py +++ b/TPTBox/core/dicom/dicom_header_to_keys.py @@ -222,7 +222,7 @@ def _get(key, default=None): keys["acq"] = to_nii(dcm_data_l).get_plane(1) else: keys["acq"] = get_plane_dicom(dcm_data_l, 1) - keys["part"] = dixon_mapping.get(_get("ProtocolName", "NO-PART").split("_")[-1], None) + keys["part"] = dixon_mapping.get(_get("ProtocolName", "NO-PART").split("_")[-1]) sequ = _get("SeriesNumber", None) if sequ is None: diff --git a/pyproject.toml b/pyproject.toml index 6dcf02a..935002b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -158,6 +158,8 @@ ignore = [ "F811", "N803", "N806", + "FURB171", + "PLW0108", "B905", # strict= in zip "UP007", # Union and "|" python 3.9 "PLC0415", # import-outside-top-level