Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion TPTBox/core/dicom/dicom_header_to_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
34 changes: 27 additions & 7 deletions TPTBox/core/vert_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 :]:
Expand All @@ -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]):
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down