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/TPTBox/core/vert_constants.py b/TPTBox/core/vert_constants.py index 1e3b1c2..bae5ed1 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 @@ -578,7 +580,9 @@ def __init__( self.has_rib = has_rib 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 ) # 40 - 8 + 21 = 53 = rib for T13 # 52 rib for L1 @@ -675,7 +679,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 :]: @@ -684,7 +694,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]): @@ -738,7 +754,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: 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