Convert 3D volume data and masks to PyTorch tensors (D,H,W,C or D,H,W -> C,D,H,W). For 3D medical imaging pipelines; p=1.0 by default.
This transform is designed for 3D medical imaging data. It converts numpy arrays to PyTorch tensors and ensures consistent channel positioning.
For all inputs (volume data and masks): - Input: (D, H, W, C) or (D, H, W) - depth, height, width, [channels] - Output: (C, D, H, W) - channels first format for PyTorch For single-channel input, adds C=1 dimension
Note: This transform always moves channels to first position as this is the standard PyTorch format. For masks that need to stay in DHWC format, use a different transform or handle the transposition after this transform.
pProbability of applying the transform. Default: 1.0
>>> transform = ToTensor3D(p=1.0)This transform always moves channels to first position as this is the standard PyTorch format. For masks that need to stay in DHWC format, use a different transform or handle the transposition after this transform.