Support 4D tensors as torchio.Image
See original GitHub issue🚀 Feature
Make torchio accept 4D tensors (i.e. volumes with multiple channels) as input data for torchio.Image
.
Motivation
I am working on a segmentation task using partial volume maps. Therefore, to take into account different tissues I need different channels as different tissues cannot be encoded to different integers.
Pitch
If a 3D tensor is given, torchio’s behaviour remains the same as before: the tensor is expanded to become a 4D tensor with a single channel. If a 4D tensor is given, it is directly loaded as it is. However, if there is a parameter saying that channels are at the end but should be at the beginning, dimensions are permuted so that we get channels first.
Alternatives
For now, the solution using torchio is to have several files and to create different attributes in the subject and concatenate these different maps on the channel dimension when I need to use them.
Additional context
I’m fine with the alternative solution but I fear that it could be inefficient if there are more than 10 channels and you have to apply a spatial transform independently on all these channels compared to applying the spatial transform on the 4D tensor. I’m not sure what would be the implications on the different transforms to handle 4D tensors with multiple channels (especially intensity transforms). Maybe only label
type image should be allowed to be 4D.
I guess @fepegar you know better the pros and cons and why the choice was made to handle only 3D tensors in the first place.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (5 by maintainers)
Top GitHub Comments
I’ll close this for now. We can reopen if we ever consider this to be necessary.
And for more completeness, here’s the affine from https://github.com/fepegar/torchio/issues/213#issuecomment-652304652 using the DGX: