MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / inv_shift_fourier

Method inv_shift_fourier

monai/transforms/utils.py:1904–1923  ·  view source on GitHub ↗

Applies inverse shift and fourier transform. Only the spatial dimensions are transformed. Args: k: K-space data. spatial_dims: Number of spatial dimensions. as_contiguous: Whether to convert the cached NumPy array or PyTorch tensor to be

(k: NdarrayOrTensor, spatial_dims: int, as_contiguous: bool = False)

Source from the content-addressed store, hash-verified

1902
1903 @staticmethod
1904 def inv_shift_fourier(k: NdarrayOrTensor, spatial_dims: int, as_contiguous: bool = False) -> NdarrayOrTensor:
1905 """
1906 Applies inverse shift and fourier transform. Only the spatial
1907 dimensions are transformed.
1908
1909 Args:
1910 k: K-space data.
1911 spatial_dims: Number of spatial dimensions.
1912 as_contiguous: Whether to convert the cached NumPy array or PyTorch tensor to be contiguous.
1913
1914 Returns:
1915 x: Tensor in image space.
1916 """
1917 dims = tuple(range(-spatial_dims, 0))
1918 out: NdarrayOrTensor
1919 if isinstance(k, torch.Tensor):
1920 out = torch.fft.ifftn(torch.fft.ifftshift(k, dim=dims), dim=dims, norm="backward").real
1921 else:
1922 out = np.fft.ifftn(np.fft.ifftshift(k, axes=dims), axes=dims).real
1923 return ascontiguousarray(out) if as_contiguous else out
1924
1925
1926def get_number_image_type_conversions(transform: Compose, test_data: Any, key: Hashable | None = None) -> int:

Callers 3

test_backwardMethod · 0.95
__call__Method · 0.80
__call__Method · 0.80

Calls 1

ascontiguousarrayFunction · 0.90

Tested by 1

test_backwardMethod · 0.76