mrpro.operators.FastFourierOp
- class mrpro.operators.FastFourierOp[source]
Bases:
LinearOperatorFast Fourier operator class.
Applies a Fast Fourier Transformation along selected dimensions with cropping/zero-padding along these selected dimensions
The transformation is done with
'ortho'normalization, i.e. the normalization constant is split between forward and adjoint [FFT].Note
The input to both
forwardandadjointare assumed to have the zero-frequency in the center of the data.torch.fft.fftnandtorch.fft.ifftnexpect the zero-frequency to be the first entry in the tensor. Therefore inforwardandadjoint, firsttorch.fft.ifftshift, thentorch.fft.fftnortorch.fft.ifftn, finallytorch.fft.fftshiftare applied.Note
See also
FourierOpfor a Fourier operator that handles automatic sorting of the k-space data based on a trajectory.References
- __init__(dim: Sequence[int] = (-3, -2, -1), recon_matrix: SpatialDimension[int] | Sequence[int] | None = None, encoding_matrix: SpatialDimension[int] | Sequence[int] | None = None) None[source]
Initialize a Fast Fourier Operator.
If both
recon_matrixandencoding_matrixare set, the operator will perform padding/cropping before and after the transforms to match the shape in image space (recon_matrix) and k-shape (encoding_matrix). If both are set toNone, no padding or cropping will be performed. If these areSpatialDimension, the transform dimensions must be within the last three dimensions, typically corresponding to the(k2, k1, k0)and(z, y, x)axes ofKDataandIData, respectively.- Parameters:
dim (
Sequence[int], default:(-3, -2, -1)) – dim along which FFT and IFFT are applied, by default last three dimensions, as these correspond tok2,k1, andk0of k-space data.encoding_matrix (
Union[SpatialDimension[int],Sequence[int],None], default:None) – shape of encoded k-data along the axes indim. Must be set ifrecon_matrixis set. Ifencoding_matrixandrecon_matrixareNone, no padding or cropping will be performed. If all values in dim are -3, -2 or -1, this can also be aSpatialDimensiondescribing the k-space shape in all 3 dimensions(k2, k1, k0), but only values in the dimensions indimwill be used. Otherwise, it should be aSequenceof the same length asdim.recon_matrix (
Union[SpatialDimension[int],Sequence[int],None], default:None) – shape of reconstructed image data. Must be set ifencoding_matrixis set. Ifencoding_matrixandrecon_matrixareNone, no padding or cropping will be performed. If all values indimare -3, -2 or -1, this can also be aSpatialDimensiondescribing the image-space shape in all 3 dimensions(z, y, x), but only values in the dimensions indimwill be used. Otherwise, it should be aSequenceof the same length asdim.
- property H: LinearOperator[source]
Adjoint operator.
Obtains the adjoint of an instance of this operator as an
AdjointLinearOperator, which itself is a anLinearOperatorthat can be applied to tensors.Note:
linear_operator.H.H == linear_operator
- property gram: LinearOperator[source]
Gram operator.
For a LinearOperator \(A\), the self-adjoint Gram operator is defined as \(A^H A\).
Note
This is the inherited default implementation.
- __call__(x: Tensor) tuple[Tensor][source]
Apply Fast Fourier Transform (FFT) from image space to k-space.
- Parameters:
x (
Tensor) – (image-space) data on a Cartesian grid.- Returns:
FFT of
x
- adjoint(y: Tensor) tuple[Tensor][source]
Apply Inverse Fast Fourier Transform (IFFT) from k-space to image space.
- Parameters:
y (
Tensor) – (k-space) data on a Cartesian grid.- Returns:
IFFT of
y
- forward(x: Tensor) tuple[Tensor][source]
Apply forward of FastFourierOp.
Note
Prefer calling the instance of the FastFourierOp operator as
operator(x)over directly calling this method. See this PyTorch discussion.
- operator_norm(initial_value: Tensor, dim: Sequence[int] | None, max_iterations: int = 20, relative_tolerance: float = 1e-4, absolute_tolerance: float = 1e-5, callback: Callable[[Tensor], None] | None = None) Tensor[source]
Power iteration for computing the operator norm of the operator.
- Parameters:
initial_value (
Tensor) – initial value to start the iteration; must be element of the domain. if the initial value contains a zero-vector for one of the considered problems, the function throws anValueError.The dimensions of the tensors on which the operator operates. The choice of
dimdetermines how the operator norm is inperpreted. For example, for a matrix-vector multiplication with a batched matrix tensor of shape(batch1, batch2, row, column)and a batched input tensor of shape(batch1, batch2, row):If
dim=None, the operator is considered as a block diagonal matrix with batch1*batch2 blocks and the result is a tensor containing a single norm value (shape(1, 1, 1)).If
dim=(-1),batch1*batch2matrices are considered, and for each a separate operator norm is computed.If
dim=(-2,-1),batch1matrices withbatch2blocks are considered, and for each matrix a separate operator norm is computed.
Thus, the choice of
dimdetermines implicitly determines the domain of the operator.max_iterations (
int, default:20) – maximum number of iterationsrelative_tolerance (
float, default:1e-4) – absolute tolerance for the change of the operator-norm at each iteration; if set to zero, the maximal number of iterations is the only stopping criterion used to stop the power iteration.absolute_tolerance (
float, default:1e-5) – absolute tolerance for the change of the operator-norm at each iteration; if set to zero, the maximal number of iterations is the only stopping criterion used to stop the power iteration.callback (
Callable[[Tensor],None] |None, default:None) – user-provided function to be called at each iteration
- Returns:
An estimaton of the operator norm. Shape corresponds to the shape of the input tensor
initial_valuewith the dimensions specified indimreduced to a single value. The pointwise multiplication ofinitial_valuewith the result of the operator norm will always be well-defined.
- __add__(other: LinearOperator | Tensor | complex) LinearOperator[source]
- __add__(other: Operator[Tensor, tuple[Tensor]]) Operator[Tensor, tuple[Tensor]]
Operator addition.
Returns
lambda x: self(x) + other(x)if other is a operator,lambda x: self(x) + otherif other is a tensor
- __and__(other: LinearOperator) LinearOperatorMatrix[source]
Vertical stacking of two LinearOperators.
A&Bis aLinearOperatorMatrixwith two rows, with(A&B)(x) == (A(x), B(x)). Seemrpro.operators.LinearOperatorMatrixfor more information.
- __matmul__(other: LinearOperator) LinearOperator[source]
- __matmul__(other: Operator[Unpack[Tin2], tuple[Tensor]] | Operator[Unpack[Tin2], tuple[Tensor, ...]]) Operator[Unpack[Tin2], tuple[Tensor]]
Operator composition.
Returns
lambda x: self(other(x))
- __mul__(other: Tensor | complex) LinearOperator[source]
Operator elementwise left multiplication with tensor/scalar.
Returns
lambda x: self(x*other)
- __or__(other: LinearOperator) LinearOperatorMatrix[source]
Horizontal stacking of two LinearOperators.
A|Bis aLinearOperatorMatrixwith two columns, with(A|B)(x1,x2) == A(x1) + B(x2). Seemrpro.operators.LinearOperatorMatrixfor more information.
- __radd__(other: Tensor | complex) LinearOperator[source]
Operator addition.
Returns
lambda x: self(x) + other*x
- __rmul__(other: Tensor | complex) LinearOperator[source]
Operator elementwise right multiplication with tensor/scalar.
Returns
lambda x: other*self(x)