From 32317f9b8216c956a300b73a43add0e75afb3a7e Mon Sep 17 00:00:00 2001 From: ckolbPTB Date: Wed, 22 Jan 2025 11:37:34 +0100 Subject: [PATCH] docs formatting --- src/mrpro/operators/FastFourierOp.py | 4 +- src/mrpro/operators/FourierOp.py | 2 +- .../operators/NonUniformFastFourierOp.py | 43 ++++++++++--------- 3 files changed, 25 insertions(+), 24 deletions(-) diff --git a/src/mrpro/operators/FastFourierOp.py b/src/mrpro/operators/FastFourierOp.py index c9f1f3517..0d504f3ec 100644 --- a/src/mrpro/operators/FastFourierOp.py +++ b/src/mrpro/operators/FastFourierOp.py @@ -122,7 +122,7 @@ def forward(self, x: torch.Tensor) -> tuple[torch.Tensor,]: Returns ------- - FFT of x + FFT of `x` """ y = torch.fft.fftshift( torch.fft.fftn(torch.fft.ifftshift(*self._pad_op(x), dim=self._dim), dim=self._dim, norm='ortho'), @@ -140,7 +140,7 @@ def adjoint(self, y: torch.Tensor) -> tuple[torch.Tensor,]: Returns ------- - IFFT of y + IFFT of `y` """ # FFT return self._pad_op.adjoint( diff --git a/src/mrpro/operators/FourierOp.py b/src/mrpro/operators/FourierOp.py index 8d3b93f81..fc7801195 100644 --- a/src/mrpro/operators/FourierOp.py +++ b/src/mrpro/operators/FourierOp.py @@ -176,7 +176,7 @@ class FourierGramOp(LinearOperator): """Gram operator for the Fourier operator. Implements the adjoint of the forward operator of the Fourier operator, i.e. the gram operator - `F.H@F. + `F.H@F`. Uses a convolution, implemented as multiplication in Fourier space, to calculate the gram operator for the toeplitz NUFFT operator. diff --git a/src/mrpro/operators/NonUniformFastFourierOp.py b/src/mrpro/operators/NonUniformFastFourierOp.py index 15b047593..b7e788a70 100644 --- a/src/mrpro/operators/NonUniformFastFourierOp.py +++ b/src/mrpro/operators/NonUniformFastFourierOp.py @@ -36,19 +36,19 @@ def __init__( direction direction along which non-uniform FFT is applied recon_matrix - Dimension of the reconstructed image. If this is SpatialDimension only values of directions will be used. - Otherwise, it should be a Sequence of the same length as direction. + Dimension of the reconstructed image. If this is `~mrpro.data.SpatialDimension` only values of directions + will be used. Otherwise, it should be a `Sequence` of the same length as direction. encoding_matrix - Dimension of the encoded k-space. If this is SpatialDimension only values of directions will be used. - Otherwise, it should be a Sequence of the same length as direction. + Dimension of the encoded k-space. If this is `~mrpro.data.SpatialDimension` only values of directions will + be used. Otherwise, it should be a `Sequence` of the same length as direction. traj - the k-space trajectories where the frequencies are sampled + The k-space trajectories where the frequencies are sampled. nufft_oversampling - oversampling used for interpolation in non-uniform FFTs + Oversampling used for interpolation in non-uniform FFTs. nufft_numpoints - number of neighbors for interpolation in non-uniform FFTs + Number of neighbors for interpolation in non-uniform FFTs. nufft_kbwidth - size of the Kaiser-Bessel kernel interpolation in non-uniform FFTs + Size of the Kaiser-Bessel kernel interpolation in non-uniform FFTs. """ super().__init__() @@ -178,7 +178,7 @@ def _separate_joint_dimensions( Returns ------- - ((sep dims along zyx), (permute for zyx), (sep dims along 210), (permute for 210)) + `((sep dims along zyx), (permute for zyx), (sep dims along 210), (permute for 210))` """ # We did most in _init_ and here we only have to check the other dimensions. @@ -205,11 +205,11 @@ def forward(self, x: torch.Tensor) -> tuple[torch.Tensor,]: Parameters ---------- x - coil image data with shape: (... coils z y x) + coil image data with shape `(... coils z y x)` Returns ------- - coil k-space data with shape: (... coils k2 k1 k0) + coil k-space data with shape `(... coils k2 k1 k0)` """ if len(self._nufft_directions): # We rearrange x into (sep_dims, joint_dims, nufft_directions) @@ -236,11 +236,11 @@ def adjoint(self, x: torch.Tensor) -> tuple[torch.Tensor,]: Parameters ---------- x - coil k-space data with shape: (... coils k2 k1 k0) + coil k-space data with shape `(... coils k2 k1 k0)` Returns ------- - coil image data with shape: (... coils z y x) + coil image data with shape `(... coils z y x)` """ if len(self._nufft_directions): # We rearrange x into (sep_dims, joint_dims, nufft_directions) @@ -291,7 +291,8 @@ def gram_nufft_kernel(weight: torch.Tensor, trajectory: torch.Tensor, recon_shap Returns ------- kernel - real valued convolution kernel for the NUFFT gram operator, already in Fourier space + Real valued convolution kernel for :class:`mrpro.operator.NonUniformFastFourierOpGramOp`, already in Fourier + space. """ rank = trajectory.shape[-2] # Instead of doing one adjoint nufft with double the recon size in all dimensions, @@ -328,16 +329,16 @@ def gram_nufft_kernel(weight: torch.Tensor, trajectory: torch.Tensor, recon_shap class NonUniformFastFourierOpGramOp(LinearOperator): - """Gram operator for the non-uniform Fast Fourier operator. + """Gram operator for py:class:`NonUniformFastFourierOp`. Implements the adjoint of the forward operator of the non-uniform Fast Fourier operator, i.e. the gram operator - `NUFFT.H@NUFFT. + `NUFFT.H@NUFFT`. Uses a convolution, implemented as multiplication in Fourier space, to calculate the gram operator - for the toeplitz NUFFT operator. + for the Toeplitz NUFFT operator. This should not be used directly, but rather through the `gram` method of a - :class:`mrpro.operator.NonUniformFastFourierOp` object. + py:class:`NonUniformFastFourierOp` object. """ _kernel: torch.Tensor | None @@ -348,7 +349,7 @@ def __init__(self, nufft_op: NonUniformFastFourierOp) -> None: Parameters ---------- nufft_op - the non-uniform Fast Fourier operator to calculate the gram operator for + The py:class:`NonUniformFastFourierOp` to calculate the gram operator for. """ super().__init__() @@ -389,7 +390,7 @@ def forward(self, x: torch.Tensor) -> tuple[torch.Tensor,]: Parameters ---------- x - input tensor, shape (..., coils, z, y, x) + input tensor, shape `(..., coils, z, y, x)` """ if self.nufft_gram is not None: (x,) = self.nufft_gram(x) @@ -402,7 +403,7 @@ def adjoint(self, x: torch.Tensor) -> tuple[torch.Tensor,]: Parameters ---------- x - input tensor, shape (..., coils, k2, k1, k0) + input tensor, shape `(..., coils, k2, k1, k0)` """ return self.forward(x)