fusionlab.segmentation.unetr.unetr module#
- class fusionlab.segmentation.unetr.unetr.UNETR(in_channels, out_channels, img_size, feature_size=16, hidden_size=768, mlp_dim=3072, num_heads=12, pos_embed='fc', dropout_rate=0.0, spatial_dims=2)[source]#
Bases:
ModuleUNETR based on: “Hatamizadeh et al., UNETR: Transformers for 3D Medical Image Segmentation <https://arxiv.org/abs/2103.10504>”
source code: Project-MONAI/MONAI
- __init__(in_channels, out_channels, img_size, feature_size=16, hidden_size=768, mlp_dim=3072, num_heads=12, pos_embed='fc', dropout_rate=0.0, spatial_dims=2)[source]#
- Parameters:
in_channels (
int) – dimension of input channels.out_channels (
int) – dimension of output channels.img_size (
int) – dimension of input image.feature_size (
int) – dimension of network feature size.hidden_size (
int) – dimension of hidden layer.mlp_dim (
int) – dimension of feedforward layer.num_heads (
int) – number of attention heads.pos_embed (
str) – position embedding layer type.norm_name – feature normalization type and arguments.
conv_block – bool argument to determine if convolutional block is used.
res_block – bool argument to determine if residual block is used.
dropout_rate (
float) – faction of the input units to drop in ViT.spatial_dims (
int) – number of spatial dimensions.
- forward(x_in)[source]#
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- training: bool#
- class fusionlab.segmentation.unetr.unetr.UnetrBasicBlock(spatial_dims, in_channels, out_channels, kernel_size, stride)[source]#
Bases:
ModuleA CNN module that can be used for UNETR, based on: “Hatamizadeh et al., UNETR: Transformers for 3D Medical Image Segmentation <https://arxiv.org/abs/2103.10504>”
- Parameters:
spatial_dims (
int) – number of spatial dimensions.in_channels (
int) – number of input channels.out_channels (
int) – number of output channels.kernel_size (
Union[Sequence[int],int]) – convolution kernel size.stride (
Union[Sequence[int],int]) – convolution stride.
- forward(x)[source]#
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- training: bool#
- class fusionlab.segmentation.unetr.unetr.UnetrPrUpBlock(spatial_dims, in_channels, out_channels, num_layer, kernel_size, stride, upsample_kernel_size)[source]#
Bases:
ModuleA projection upsampling module that can be used for UNETR: “Hatamizadeh et al., UNETR: Transformers for 3D Medical Image Segmentation <https://arxiv.org/abs/2103.10504>”
- __init__(spatial_dims, in_channels, out_channels, num_layer, kernel_size, stride, upsample_kernel_size)[source]#
- Parameters:
spatial_dims (
int) – number of spatial dimensions.in_channels (
int) – number of input channels.out_channels (
int) – number of output channels.num_layer (
int) – number of upsampling blocks.kernel_size (
Union[Sequence[int],int]) – convolution kernel size.stride (
Union[Sequence[int],int]) – convolution stride.upsample_kernel_size (
Union[Sequence[int],int]) – convolution kernel size for transposed convolution layers.
- forward(x)[source]#
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- training: bool#
- class fusionlab.segmentation.unetr.unetr.UnetrUpBlock(spatial_dims, in_channels, out_channels, kernel_size, upsample_kernel_size)[source]#
Bases:
ModuleAn upsampling module that can be used for UNETR: “Hatamizadeh et al., UNETR: Transformers for 3D Medical Image Segmentation <https://arxiv.org/abs/2103.10504>”
- __init__(spatial_dims, in_channels, out_channels, kernel_size, upsample_kernel_size)[source]#
- Parameters:
spatial_dims (
int) – number of spatial dimensions.in_channels (
int) – number of input channels.out_channels (
int) – number of output channels.kernel_size (
Union[Sequence[int],int]) – convolution kernel size.upsample_kernel_size (
Union[Sequence[int],int]) – convolution kernel size for transposed convolution layers.
- forward(x, skip)[source]#
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- training: bool#