Given an image of dimensions `image_size`, return a patch size tuple taking the dimension from `patch_size` if this is not 0/None. Otherwise, or if `patch_size` is shorter than `image_size`, the dimension from `image_size` is taken. This ensures the returned patch size is within the bou
(image_size: Sequence[int], patch_size: Sequence[int] | int | np.ndarray)
| 339 | |
| 340 | |
| 341 | def get_valid_patch_size(image_size: Sequence[int], patch_size: Sequence[int] | int | np.ndarray) -> tuple[int, ...]: |
| 342 | """ |
| 343 | Given an image of dimensions `image_size`, return a patch size tuple taking the dimension from `patch_size` if this is |
| 344 | not 0/None. Otherwise, or if `patch_size` is shorter than `image_size`, the dimension from `image_size` is taken. This ensures |
| 345 | the returned patch size is within the bounds of `image_size`. If `patch_size` is a single number this is interpreted as a |
| 346 | patch of the same dimensionality of `image_size` with that size in each dimension. |
| 347 | """ |
| 348 | ndim = len(image_size) |
| 349 | patch_size_ = ensure_tuple_size(patch_size, ndim) |
| 350 | |
| 351 | # ensure patch size dimensions are not larger than image dimension, if a dimension is None or 0 use whole dimension |
| 352 | return tuple(min(ms, ps or ms) for ms, ps in zip(image_size, patch_size_)) |
| 353 | |
| 354 | |
| 355 | def dev_collate(batch, level: int = 1, logger_name: str = "dev_collate"): |
no test coverage detected
searching dependent graphs…