Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
ba8f9f1
Merge branch 'development_robert' of github.com:Hendrik-code/TPTBox i…
robert-graf Jul 24, 2025
56ddf76
improved defaults
robert-graf Jul 31, 2025
24a9cd7
add options to some functions (raise error, 2d infect, better defautls)
robert-graf Sep 1, 2025
cd20aa8
update constance Full Body
robert-graf Sep 1, 2025
f45386c
3.9 comp
robert-graf Sep 1, 2025
34483e9
snapshot3d can now update the resolution correctly
robert-graf Sep 1, 2025
e94f4e7
update max_histroy for early stoping
robert-graf Sep 1, 2025
0307165
add wrapper for file names
robert-graf Sep 1, 2025
a7e1864
update inference
robert-graf Sep 1, 2025
1d3b8e3
Merge branch 'development_robert' of github.com:Hendrik-code/TPTBox i…
robert-graf Sep 1, 2025
dd83121
add better logging
robert-graf Sep 11, 2025
87429c5
add option
robert-graf Sep 11, 2025
d45c49d
Merge branch 'main' into development_robert
robert-graf Sep 11, 2025
0ba8bdc
small changes
robert-graf Oct 1, 2025
d7b4a47
prevent error for unreadable data, like object data
robert-graf Oct 1, 2025
2c72af7
Merge branch 'development_robert' of github.com:Hendrik-code/TPTBox i…
robert-graf Oct 1, 2025
389b305
small bugfixes
robert-graf Oct 14, 2025
c9a198b
Merge branch 'development_robert' of github.com:Hendrik-code/TPTBox i…
robert-graf Oct 14, 2025
532f560
Merge branch 'development_robert' of github.com:Hendrik-code/TPTBox i…
robert-graf Oct 14, 2025
8711979
add 3D dicom supprot
robert-graf Oct 14, 2025
584efea
prevent error when cuda is not installed.
robert-graf Oct 17, 2025
11e4e8a
remove total from name
robert-graf Oct 17, 2025
01a36db
remove oar segmentation. Use CATS instead
robert-graf Oct 17, 2025
2976ba8
add __all__
robert-graf Oct 17, 2025
9cf81df
Merge branch 'main' into development_robert
robert-graf Oct 17, 2025
3332ea6
x
robert-graf Oct 17, 2025
c77ffb2
update tests
robert-graf Oct 17, 2025
889432f
small bug with new name
robert-graf Oct 30, 2025
82a58a4
added new features
robert-graf Nov 28, 2025
a9a3aa7
fix test with updated semantic meaning
robert-graf Nov 29, 2025
d5e1bc9
add 3.9 to fast test
robert-graf Nov 29, 2025
acea6bb
add 3.9 to merge test
robert-graf Nov 29, 2025
37c74e7
remove "total"
robert-graf Nov 29, 2025
67f4798
add init
robert-graf Nov 29, 2025
346e9db
ruff: remove Optional
robert-graf Nov 29, 2025
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
13 changes: 7 additions & 6 deletions TPTBox/registration/deepali/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from collections.abc import Sequence
from contextlib import ContextDecorator
from pathlib import Path
from typing import Literal, Optional, Union
from typing import Literal, Union

import torch
import torch.optim
Expand Down Expand Up @@ -49,7 +49,7 @@ def get_post_transform(
target_grid: Grid,
source_grid: Grid,
align=False,
) -> Optional[SpatialTransform]:
) -> SpatialTransform | None:
Comment thread
Hendrik-code marked this conversation as resolved.
r"""Get constant rigid transformation between image grid domains."""
if align is False or align is None:
return None
Expand Down Expand Up @@ -90,7 +90,7 @@ def load_transform(path: PathStr, grid: Grid) -> SpatialTransform:
"""
target_grid = grid

def convert_matrix(matrix: Tensor, grid: Optional[Grid] = None) -> Tensor:
def convert_matrix(matrix: Tensor, grid: Grid | None = None) -> Tensor:
if grid is None:
pre = target_grid.transform(Axes.CUBE_CORNERS, Axes.WORLD)
post = target_grid.transform(Axes.WORLD, Axes.CUBE_CORNERS)
Expand Down Expand Up @@ -166,7 +166,7 @@ def __exit__(self, exc_type, exc_value, traceback):
self.scheduler.step()


def overlap_mask(source_mask: Tensor | None, target_mask: Tensor | None) -> Optional[Tensor]:
def overlap_mask(source_mask: Tensor | None, target_mask: Tensor | None) -> Tensor | None:
r"""Overlap mask at which to evaluate pairwise data term."""
if source_mask is None:
return target_mask
Expand All @@ -184,11 +184,12 @@ def make_foreground_mask(image: Image, foreground_lower_threshold, foreground_up
return Image(mask, image.grid())


def normalize_img(image: Image, normalize_strategy: Optional[Literal["auto", "CT", "MRI"]]):
def normalize_img(image: Image, normalize_strategy: Literal["auto", "CT", "MRI"] | None):
if normalize_strategy is None:
return image
data = image.tensor()
if normalize_strategy == "MRI":
data = data.float()
max_v = torch.quantile(data[data > 0], q=0.95)
min_v = 0
elif normalize_strategy == "CT":
Expand All @@ -210,7 +211,7 @@ def normalize_img(image: Image, normalize_strategy: Optional[Literal["auto", "CT
return Image(data, image.grid())


def clamp_mask(image: Optional[Image]):
def clamp_mask(image: Image | None):
if image is None:
return image
data = image.tensor()
Expand Down