Skip to content
Merged
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/nii2dicom.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def nifti2dicom_1file(
out_dir: str | Path,
no_json_ok: bool = False,
secondary: bool = False,
json_path: None | str | Path = None,
json_path: str | Path | None = None,
out_name: str = "slice",
) -> None:
r"""Convert a single NIfTI file to a DICOM series.
Expand Down
4 changes: 2 additions & 2 deletions TPTBox/core/nii_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -1157,7 +1157,7 @@ def rescale_(self, voxel_spacing=(1, 1, 1), c_val: float | None = None, verbose:
return self.rescale( voxel_spacing=voxel_spacing, c_val=c_val, verbose=verbose,mode=mode, inplace=True)

def resample_from_to(self, to_vox_map:Image_Reference|Has_Grid|tuple[SHAPE,AFFINE,ZOOMS], mode:MODES='nearest', order: int |None=None, c_val=None, inplace = False,verbose:logging=True,align_corners:bool=False) -> Self:
r"""Self will be resampled in coordinate of given other image. Adheres to global space not to local pixel space.
"""Self will be resampled in coordinate of given other image. Adheres to global space not to local pixel space.

Args:
to_vox_map (Image_Reference|Proxy): If object, has attributes shape giving input voxel shape, and affine giving mapping of input voxels to output space. If length 2 sequence, elements are (shape, affine) with same meaning as above. The affine is a (4, 4) array-like.\n
Expand Down Expand Up @@ -1802,7 +1802,7 @@ def calc_convex_hull(
return self.set_array_(convex_hull_arr)
return self.set_array(convex_hull_arr)

def calc_convex_hull_(self, axis: None | DIRECTIONS = "S", verbose: bool = False) -> Self:
def calc_convex_hull_(self, axis: DIRECTIONS | None = "S", verbose: bool = False) -> Self:
"""In-place variant of `calc_convex_hull`."""
return self.calc_convex_hull(axis=axis, inplace=True, verbose=verbose)

Expand Down
4 changes: 2 additions & 2 deletions TPTBox/core/np_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ def np_dilate_msk(
connectivity: int = 3,
use_crop: bool = True,
mask: np.ndarray | None = None,
ignore_axis: None | int = None,
ignore_axis: int | None = None,
) -> np.ndarray:
"""Dilates the given array by the specified number of voxels (not including the zero label).

Expand Down Expand Up @@ -586,7 +586,7 @@ def np_erode_msk(
use_crop: bool = True,
connectivity: int = 3,
border_value=0,
ignore_axis: None | int = None,
ignore_axis: int | None = None,
) -> np.ndarray:
"""Erodes the given array by the specified number of voxels.

Expand Down
2 changes: 1 addition & 1 deletion TPTBox/core/poi_fun/vertebra_direction.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def calc_orientation_of_vertebra_PIR(
source_subreg_point_id=Location.Vertebra_Corpus,
subreg_id=Location.Spinal_Canal,
do_fill_back: bool = False,
spine_plot_path: None | str = None,
spine_plot_path: str | None = None,
save_normals_in_info=False,
_orientation_version=0,
) -> tuple[POI, NII | None]:
Expand Down
2 changes: 1 addition & 1 deletion TPTBox/segmentation/VibeSeg/inference_nnunet.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ def run_inference_on_file(
unknown_strings: dict[str, int] = {"max": seg_nii.max() + 1, "Intervertebral_Disc": 100}
mapping = {}

def to_int(a: str, k: None | int = None):
def to_int(a: str, k: int | None = None):
if a in unknown_strings:
return unknown_strings[a]
try:
Expand Down
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ authors = [
"Hendrik Möller <hendrik.moeller@tum.de>",
]
repository = "https://github.com/Hendrik-code/TPTBox"
license = "GNU AFFERO GENERAL PUBLIC LICENSE v3.0, 19 November 2007"
license = "Apache License Version 2.0, January 2004"
readme = "README.md"
packages = [{ include = "TPTBox" }]

Expand Down Expand Up @@ -190,6 +190,8 @@ ignore = [
"ANN202",
# En-dashes (–) in docstrings are legitimate range notation (e.g. "C1–C7")
"RUF002",
"PLR0917", # Too many positional arguments
"UP038", # Use `X | Y` in `isinstance` call instead of `(X, Y)`
]

# Allow fix for all enabled rules (when `--fix`) is provided.
Expand Down
2 changes: 1 addition & 1 deletion unit_tests/test_testsamples.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def test_make_snapshot_both(self, keep_images=False):

self.assertFalse(Path(td).exists() and not keep_images)

def make_POIs(self, vert_nii: NII, subreg_nii: NII, vert_id: int, ignore_list: list[Location], locs: None | list[Location] = None, n=5):
def make_POIs(self, vert_nii: NII, subreg_nii: NII, vert_id: int, ignore_list: list[Location], locs: list[Location] | None = None, n=5):
for i in range(n):
locs2 = [l for l in Location if l not in ignore_list and random.random() < (i + 1) / n * 3] if locs is None else locs
poi = calc_poi_from_subreg_vert(vert_nii, subreg_nii, subreg_id=locs2, verbose=False, _print_phases=True).extract_region(
Expand Down
Loading