mrpro.operators.FourierOp
- class mrpro.operators.FourierOp[source]
Bases:
LinearOperatorFourier Operator class.
This is the recommended operator for all Fourier transformations. It auto-detects if a non-uniform or regular fast Fourier transformation is required. For Cartesian data on a regular grid, the data is sorted and a FFT is used. For non-Cartesian data, a NUFFT with regridding is used. It also includes padding/cropping to the reconstruction matrix size.
The operator can directly be constructed from a
KDataobject to match its trajectory and header information, seeFourierOp.from_kdata.- __init__(recon_matrix: SpatialDimension[int], encoding_matrix: SpatialDimension[int], traj: KTrajectory) None[source]
Initialize Fourier Operator.
- Parameters:
recon_matrix (
SpatialDimension[int]) – dimension of the reconstructed imageencoding_matrix (
SpatialDimension[int]) – dimension of the encoded k-spacetraj (
KTrajectory) – the k-space trajectories where the frequencies are sampled
- classmethod from_kdata(kdata: KData, recon_shape: SpatialDimension[int] | None = None) Self[source]
Create an instance of FourierOp from kdata with default settings.
- Parameters:
kdata (
KData) – k-space datarecon_shape (
Optional[SpatialDimension[int]], default:None) – Dimension of the reconstructed image. Defaults toKData.header.recon_matrix.
- property gram: LinearOperator[source]
Return the gram operator.
- 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
- __call__(x: Tensor) tuple[Tensor][source]
Apply forward Fourier operation (image to k-space).
This operator maps coil image data to coil k-space data. Depending on the trajectory and dimensions, it may involve NUFFT, FFT, and Cartesian sampling operations.
- Parameters:
x (
Tensor) – Coil image data, typically with shape(... coils z y x).- Returns:
Coil k-space data, typically with shape
(... coils k2 k1 k0).
- adjoint(x: Tensor) tuple[Tensor][source]
Apply adjoint Fourier operation (k-space to image).
This operator maps coil k-space data to coil image data. It is the adjoint of the forward operation and involves corresponding adjoint NUFFT, FFT, and Cartesian sampling operations.
- Parameters:
x (
Tensor) – Coil k-space data, typically with shape(... coils k2 k1 k0).- Returns:
Coil image data, typically with shape
(... coils z y x).
- forward(x: Tensor) tuple[Tensor][source]
Apply forward of FourierOp.
Note
Prefer calling the instance of the FourierOp 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)