Skip to content

Commit

Permalink
Add option to only pad and never crop
Browse files Browse the repository at this point in the history
  • Loading branch information
joeranbosma committed Jul 10, 2024
1 parent 704b7c1 commit 1f26fa6
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/picai_prep/preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ def crop_or_pad(
size: Optional[Iterable[int]] = (20, 256, 256),
physical_size: Optional[Iterable[float]] = None,
crop_only: bool = False,
pad_only: bool = False,
) -> "Union[sitk.Image, npt.NDArray[Any]]":
"""
Resize image by cropping and/or padding
Expand Down Expand Up @@ -208,6 +209,9 @@ def crop_or_pad(
padding[i][0] = (size[i] - shape[i]) // 2
padding[i][1] = size[i] - shape[i] - padding[i][0]
else:
if pad_only:
continue

# create slicer object to crop image
idx_start = int(np.floor((shape[i] - size[i]) / 2.))
idx_end = idx_start + size[i]
Expand Down

0 comments on commit 1f26fa6

Please sign in to comment.