Skip to content

Commit 64ab93b

Browse files
committed
requested changes
1 parent 431c635 commit 64ab93b

4 files changed

Lines changed: 11 additions & 8 deletions

File tree

TPTBox/core/bids_files.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,7 @@ def open_nii(self):
988988
except KeyError as e:
989989
raise ValueError(f"nii.gz not present. Found only {self.file.keys()}\t{self.file}\n\n{self}") from e
990990

991-
def get_grid_info(self, add_gird_info_to_json=True):
991+
def get_grid_info(self, add_grid_info_to_json=True):
992992
"""returns the Grid info. It looks up if this info is in json. If not it loads the File, computes the Grid and saves it in the json"""
993993
from TPTBox.core.dicom.dicom_extract import _add_grid_info_to_json
994994
from TPTBox.core.nii_poi_abstract import Grid
@@ -998,7 +998,7 @@ def get_grid_info(self, add_gird_info_to_json=True):
998998
return None
999999
if not self.has_json():
10001000
self.file["json"] = Path(str(nii_file).split(".")[0] + ".json")
1001-
return Grid(**_add_grid_info_to_json(nii_file, self.file["json"], add=add_gird_info_to_json)["grid"])
1001+
return Grid(**_add_grid_info_to_json(nii_file, self.file["json"], add=add_grid_info_to_json)["grid"])
10021002

10031003
def get_nii_file(self) -> Path: # type: ignore
10041004
for key in _supported_nii_files:

TPTBox/core/poi_fun/vertebra_direction.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ def _get_sub_array_by_direction(d: DIRECTIONS, cords: np.ndarray) -> np.ndarray:
197197
never_called(d)
198198

199199

200-
def get_direction(d: DIRECTIONS, poi: POI, vert_id: int) -> np.ndarray:
200+
def get_direction(d: DIRECTIONS, poi: POI, vert_id: int, verbose=True) -> np.ndarray:
201201
"""Get the sub-array of coordinates along a specified direction.
202202
cords must be in PIR direction
203203
Returns:
@@ -209,6 +209,7 @@ def get_direction(d: DIRECTIONS, poi: POI, vert_id: int) -> np.ndarray:
209209
Assumes the input `cords` array has shape (3, n), where n is the number of coordinates.
210210
"""
211211
if vert_id == 1:
212+
_log.on_warning("C1 has no direction computation use C2 as direction", verbose=verbose)
212213
vert_id = 2
213214
P, I, R = get_vert_direction_PIR(poi, vert_id, to_pir=False) # noqa: N806
214215
if d == "P":

TPTBox/segmentation/_deface.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import numpy as np
44

55
from TPTBox import BIDS_FILE, BIDS_Global_info, Image_Reference, to_nii
6-
from TPTBox.core.nii_wrapper import NII
6+
from TPTBox.core.nii_wrapper import DIRECTIONS, NII
77
from TPTBox.segmentation.VibeSeg.inference_nnunet import run_inference_on_file, run_VibeSeg
88

99

@@ -21,7 +21,7 @@ def _compute_deface_mask_cta(ct_img: Image_Reference, outpath: str | Path | None
2121
return run_VibeSeg(ct_img, out_path=outpath, dataset_id=1, keep_size=False, override=override, gpu=gpu, **args)
2222

2323

24-
def _extend_mask_anterior(mask: NII, n: int) -> NII:
24+
def _extend_mask(mask: NII, n: int, direction: DIRECTIONS = "A") -> NII:
2525
"""
2626
Extend a binary mask n voxels further in anterior (A) direction.
2727
@@ -42,7 +42,7 @@ def _extend_mask_anterior(mask: NII, n: int) -> NII:
4242
arr = m.extract_label(1).get_array()
4343

4444
# Axis corresponding to Anterior-Posterior
45-
axis = m.get_axis("A")
45+
axis = m.get_axis(direction)
4646

4747
# Orientation: +1 index is "A" or "P"
4848
# Typically values are ("A","P") or ("P","A")
@@ -55,7 +55,7 @@ def _extend_mask_anterior(mask: NII, n: int) -> NII:
5555

5656
coords = idx[axis]
5757

58-
if ori == "A":
58+
if ori == direction:
5959
anterior_idx = coords.max()
6060
slicer = [slice(None)] * arr.ndim
6161
slicer[axis] = slice(0, 1)
@@ -103,7 +103,7 @@ def compute_deface_mask_cta(
103103
f2[ct > -600] = 0
104104
f2 = f2.filter_connected_components(max_count_component=1, keep_label=True)
105105

106-
mask = _extend_mask_anterior(f2, 4)
106+
mask = _extend_mask(f2, 4)
107107
mask[face_org == 1] = 2
108108

109109
m2 = mask.extract_label(1)

TPTBox/spine/spinestats/body_quadrants.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
from pathlib import Path
24

35
import numpy as np

0 commit comments

Comments
 (0)