SegResNetDS based on `3D MRI brain tumor segmentation using autoencoder regularization `_. It is similar to https://monai.readthedocs.io/en/stable/networks.html#segresnet, with several improvements including deep supervision and non-isotropic ke
| 232 | |
| 233 | |
| 234 | class SegResNetDS(nn.Module): |
| 235 | """ |
| 236 | SegResNetDS based on `3D MRI brain tumor segmentation using autoencoder regularization |
| 237 | <https://arxiv.org/pdf/1810.11654.pdf>`_. |
| 238 | It is similar to https://monai.readthedocs.io/en/stable/networks.html#segresnet, with several |
| 239 | improvements including deep supervision and non-isotropic kernel support. |
| 240 | |
| 241 | Args: |
| 242 | spatial_dims: spatial dimension of the input data. Defaults to 3. |
| 243 | init_filters: number of output channels for initial convolution layer. Defaults to 32. |
| 244 | in_channels: number of input channels for the network. Defaults to 1. |
| 245 | out_channels: number of output channels for the network. Defaults to 2. |
| 246 | act: activation type and arguments. Defaults to ``RELU``. |
| 247 | norm: feature normalization type and arguments. Defaults to ``BATCH``. |
| 248 | blocks_down: number of downsample blocks in each layer. Defaults to ``[1,2,2,4]``. |
| 249 | blocks_up: number of upsample blocks (optional). |
| 250 | dsdepth: number of levels for deep supervision. This will be the length of the list of outputs at each scale level. |
| 251 | At dsdepth==1,only a single output is returned. |
| 252 | preprocess: optional callable function to apply before the model's forward pass |
| 253 | resolution: optional input image resolution. When provided, the network will first use non-isotropic kernels to bring |
| 254 | image spacing into an approximately isotropic space. |
| 255 | Otherwise, by default, the kernel size and downsampling is always isotropic. |
| 256 | |
| 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 | |
| 271 | """ |
| 272 | |
| 273 | def __init__( |
| 274 | self, |
| 275 | spatial_dims: int = 3, |
| 276 | init_filters: int = 32, |
| 277 | in_channels: int = 1, |
| 278 | out_channels: int = 2, |
| 279 | act: tuple | str = "relu", |
| 280 | norm: tuple | str = "batch", |
| 281 | blocks_down: tuple = (1, 2, 2, 4), |
| 282 | blocks_up: tuple | None = None, |
| 283 | dsdepth: int = 1, |
| 284 | preprocess: nn.Module | Callable | None = None, |
| 285 | upsample_mode: UpsampleMode | str = "deconv", |
| 286 | resolution: tuple | None = None, |
| 287 | ): |
| 288 | super().__init__() |
| 289 | |
| 290 | if spatial_dims not in (1, 2, 3): |
| 291 | raise ValueError("`spatial_dims` can only be 1, 2 or 3.") |
no outgoing calls
searching dependent graphs…