mr2.operators.MultiBandOp
- class mr2.operators.MultiBandOp[source]
Bases:
EinsumOpApply slice-dependent phases and sum slices into collapsed measurements.
Maps
(... slices coils k2 k1 k0)to(... coils k2 k1 k0)using \(y = \sum_s \exp(-2\pi i k\,\mathrm{shift}_s) x_s\). The slice axis is a leading axis, separate from the spatial/Fourier axes. The adjoint distributes measurements to all slices with conjugate phases.For joint SMS encoding, compose
collapse @ fourier @ sensitivities. Images and sensitivity maps must contain the same ordered group of slices. Other leading axes, such as contrasts or slice groups, remain batched. Construct the Fourier operator withtrajectory.unsqueeze(-5)to insert a singleton slice axis, while passing the original coordinates to this operator.- __init__(k: Tensor, shifts: Sequence[float] | Tensor) None[source]
Initialize slice encoding from coordinates and explicit shifts.
- Parameters:
k (
Tensor) – Real coordinates of shape(... 1 k2 k1 k0), with a singleton coil axis, as in aKTrajectorycomponent. Singleton sampling axes broadcast. Use the actual acquired coordinates, including after selecting or reordering measurements.shifts (
Sequence[float] |Tensor) – Nonempty one-dimensional sequence of shifts, one per slice. The product ofkand each shift must be dimensionless. For an in-plane coordinate in full-grid units, shifts are fractions of the full FOV. Alternatively, slice-encoding coordinates in cycles/meter can be paired with slice positions in meters.
- classmethod from_caipi(k: Tensor, multiband_factor: int, fov_shift_factor: float) Self[source]
Initialize regular CAIPI shifts relative to the full FOV.
- Parameters:
k (
Tensor) – Actual acquired coordinates in full-grid units, with shape(... 1 k2 k1 k0). For accelerated Cartesian data these coordinates retain their original spacing; do not replace them with consecutive indices or divide them by the acceleration factor.multiband_factor (
int) – Number of simultaneously acquired slices.fov_shift_factor (
float) – Denominator of the shift between successive slices relative to the full FOV. For example, 3 gives shifts(0, 1/3, 2/3, ...). Must be finite and at least 1. A value of 1 means no CAIPI shift.
Notes
Scanner settings may express the shift relative to the acceleration-reduced FOV. In that case, multiply the scanner’s FOV-shift factor by the nominal in-plane acceleration before passing it. For example, scanner factor 3 with acceleration 2 gives
fov_shift_factor=6. This convention occurs in Siemens SMS reconstruction; confirm the sequence’s convention, slice order and phase origin when applying it to raw data. A scanner setting meaning no CAIPI shift should remain 1.
- 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 | HasTensorData) tuple[Tensor][source]
Apply sum-product of input
xwith the operator’s matrixA.\(A\) and the rule used to perform the sum-product is set at initialization.
- Parameters:
x (
Tensor|HasTensorData) – Input tensor.- Returns:
Result of the sum-product operation.
- adjoint(y: Tensor) tuple[Tensor][source]
Multiplication of input with the adjoint of \(A\).
- Parameters:
y (
Tensor) – Tensor to be multiplied with hermitian/adjoint matrix \(A\)- Returns:
Result of the adjoint sum-product operation.
- forward(x: Tensor) tuple[Tensor][source]
Apply forward of EinsumOp.
Note
Prefer calling the instance of the EinsumOp 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 raises aValueError.The dimensions of the tensors on which the operator operates. The choice of
dimdetermines how the operator norm is interpreted. 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,
dimdetermines 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 estimate 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: LinearOperatorMatrix) LinearOperatorMatrix
- __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. For aLinearOperatorMatrix, the operator is added to the diagonal blocks, seemr2.operators.LinearOperatorMatrix.__radd__.
- __matmul__(other: LinearOperator) LinearOperator[source]
- __matmul__(other: LinearOperatorMatrix) LinearOperatorMatrix
- __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)). For aLinearOperatorMatrix, the operator is applied to each output of the matrix, seemr2.operators.LinearOperatorMatrix.__rmatmul__.
- __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). Seemr2.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)