Skip to content

Commit 1dc47a5

Browse files
authored
Docs: add spatial shape constraints to SegResNetDS docstring (Project-MONAI#8797)
Fixes Project-MONAI#6771 ### Description Adds spatial shape constraint documentation to the SegResNetDS class docstring. Documents that input spatial dimensions must be divisible by 2 ** (len(blocks_down) - 1), with a worked example and pointers to the existing shape_factor() and is_valid_shape() methods. ### Types of changes - [x] Non-breaking change (fix or new feature that would not break existing functionality). - [ ] Breaking change (fix or new feature that would cause existing functionality to change). - [ ] New tests added to cover the changes. - [ ] Integration tests passed locally by running `./runtests.sh -f -u --net --coverage`. - [ ] Quick tests passed locally by running `./runtests.sh --quick --unittests --disttests`. - [x] In-line docstrings updated. - [ ] Documentation updated, tested `make html` command in the `docs/` folder. --------- Signed-off-by: Talhax55z <muhammadtalha223@gmail.com>
1 parent a537499 commit 1dc47a5

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

monai/networks/nets/segresnet_ds.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,20 @@ class SegResNetDS(nn.Module):
254254
image spacing into an approximately isotropic space.
255255
Otherwise, by default, the kernel size and downsampling is always isotropic.
256256
257+
**Spatial shape constraints**: If ``resolution`` is ``None`` (isotropic mode),
258+
each spatial dimension must be divisible by ``2 ** (len(blocks_down) - 1)``.
259+
With the default ``blocks_down=(1, 2, 2, 4)``, each dimension must be
260+
divisible by 8. If ``resolution`` is provided (anisotropic mode),
261+
divisibility can differ per dimension; use :py:meth:`shape_factor` for
262+
the exact required factors and :py:meth:`is_valid_shape` to verify a shape.
263+
264+
Example::
265+
266+
model = SegResNetDS(spatial_dims=3, blocks_down=(1, 2, 2, 4))
267+
print(model.shape_factor()) # [8, 8, 8]
268+
print(model.is_valid_shape((1, 1, 128, 128, 128))) # True
269+
print(model.is_valid_shape((1, 1, 100, 100, 100))) # False
270+
257271
"""
258272

259273
def __init__(

0 commit comments

Comments
 (0)