From fc1594f504b7bd228c073fb1129b9f63112be52e Mon Sep 17 00:00:00 2001 From: iback Date: Mon, 27 Jul 2026 11:02:07 +0000 Subject: [PATCH 1/4] fixed lincensing mismatch #118 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index cf85aa2..f79953d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ authors = [ "Hendrik Möller ", ] 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" }] From 3dc9fb2431486e4199f6d0cf4781dc9c9535e113 Mon Sep 17 00:00:00 2001 From: iback Date: Mon, 27 Jul 2026 14:02:38 +0000 Subject: [PATCH 2/4] make ruff happy or ignored --- pyproject.toml | 1 + unit_tests/test_testsamples.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index f79953d..12de42a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -190,6 +190,7 @@ ignore = [ "ANN202", # En-dashes (–) in docstrings are legitimate range notation (e.g. "C1–C7") "RUF002", + "PLR0917", # Too many positional arguments ] # Allow fix for all enabled rules (when `--fix`) is provided. diff --git a/unit_tests/test_testsamples.py b/unit_tests/test_testsamples.py index 28a38c2..1c76fdf 100644 --- a/unit_tests/test_testsamples.py +++ b/unit_tests/test_testsamples.py @@ -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( From 4110169a2799ac7efe4eabcfe2aec377c8497259 Mon Sep 17 00:00:00 2001 From: iback Date: Mon, 27 Jul 2026 14:04:04 +0000 Subject: [PATCH 3/4] make ruff happy or ignored --- TPTBox/core/poi_fun/vertebra_direction.py | 2 +- TPTBox/segmentation/VibeSeg/inference_nnunet.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/TPTBox/core/poi_fun/vertebra_direction.py b/TPTBox/core/poi_fun/vertebra_direction.py index b7ec316..9fc0ec2 100644 --- a/TPTBox/core/poi_fun/vertebra_direction.py +++ b/TPTBox/core/poi_fun/vertebra_direction.py @@ -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]: diff --git a/TPTBox/segmentation/VibeSeg/inference_nnunet.py b/TPTBox/segmentation/VibeSeg/inference_nnunet.py index d550dd5..3d9cc85 100644 --- a/TPTBox/segmentation/VibeSeg/inference_nnunet.py +++ b/TPTBox/segmentation/VibeSeg/inference_nnunet.py @@ -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: From 00e9c29e1809ae393f0184c1f2164a0f554000e5 Mon Sep 17 00:00:00 2001 From: iback Date: Mon, 27 Jul 2026 14:06:59 +0000 Subject: [PATCH 4/4] make ruff happy or ignored --- TPTBox/core/dicom/nii2dicom.py | 2 +- TPTBox/core/nii_wrapper.py | 4 ++-- TPTBox/core/np_utils.py | 4 ++-- pyproject.toml | 1 + 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/TPTBox/core/dicom/nii2dicom.py b/TPTBox/core/dicom/nii2dicom.py index 9cca9c0..600668d 100644 --- a/TPTBox/core/dicom/nii2dicom.py +++ b/TPTBox/core/dicom/nii2dicom.py @@ -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. diff --git a/TPTBox/core/nii_wrapper.py b/TPTBox/core/nii_wrapper.py index e93e7d0..3dbe1a1 100755 --- a/TPTBox/core/nii_wrapper.py +++ b/TPTBox/core/nii_wrapper.py @@ -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 @@ -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) diff --git a/TPTBox/core/np_utils.py b/TPTBox/core/np_utils.py index 1ac5f10..03270ce 100755 --- a/TPTBox/core/np_utils.py +++ b/TPTBox/core/np_utils.py @@ -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). @@ -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. diff --git a/pyproject.toml b/pyproject.toml index 12de42a..6df1b2b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -191,6 +191,7 @@ ignore = [ # 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.