learning.as_real#
- bartorch.learning.as_real()#
Real and imaginary parts of
inputstacked along a new leading axis.The pair is placed in front rather than in the trailing axis used by
torch.view_as_real(), matching the channel-first convention of convolutional networks and oftorchio.ScalarImage.- Parameters:
input (torch.Tensor) – Complex tensor of any shape. A real tensor is given a zero imaginary part, so that magnitude images and complex k-space can be carried in the same layout.
- Returns:
Real tensor of shape
(2, *input.shape).- Return type:
torch.Tensor
Notes
torchio.ScalarImagerequires four axes,(channels, width, height, depth), so a two-dimensional image is unsqueezed to(2, height, width, 1)before it is passed on.Examples
>>> volume = learning.as_real(image) # (2, x, y, z) >>> subject = torchio.Subject(image=torchio.ScalarImage(tensor=volume))