mrpro.operators.WaveletOp
- class mrpro.operators.WaveletOp(domain_shape: Sequence[int] | None = None, dim: tuple[int] | tuple[int, int] | tuple[int, int, int] = (-2, -1), wavelet_name: Literal['haar', 'db1', 'db2', 'db3', 'db4', 'db5', 'db6', 'db7', 'db8', 'db9', 'db10', 'db11', 'db12', 'db13', 'db14', 'db15', 'db16', 'db17', 'db18', 'db19', 'db20', 'db21', 'db22', 'db23', 'db24', 'db25', 'db26', 'db27', 'db28', 'db29', 'db30', 'db31', 'db32', 'db33', 'db34', 'db35', 'db36', 'db37', 'db38', 'sym2', 'sym3', 'sym4', 'sym5', 'sym6', 'sym7', 'sym8', 'sym9', 'sym10', 'sym11', 'sym12', 'sym13', 'sym14', 'sym15', 'sym16', 'sym17', 'sym18', 'sym19', 'sym20', 'coif1', 'coif2', 'coif3', 'coif4', 'coif5', 'coif6', 'coif7', 'coif8', 'coif9', 'coif10', 'coif11', 'coif12', 'coif13', 'coif14', 'coif15', 'coif16', 'coif17', 'bior1.1', 'bior1.3', 'bior1.5', 'bior2.2', 'bior2.4', 'bior2.6', 'bior2.8', 'bior3.1', 'bior3.3', 'bior3.5', 'bior3.7', 'bior3.9', 'bior4.4', 'bior5.5', 'bior6.8', 'rbio1.1', 'rbio1.3', 'rbio1.5', 'rbio2.2', 'rbio2.4', 'rbio2.6', 'rbio2.8', 'rbio3.1', 'rbio3.3', 'rbio3.5', 'rbio3.7', 'rbio3.9', 'rbio4.4', 'rbio5.5', 'rbio6.8', 'dmey', 'gaus1', 'gaus2', 'gaus3', 'gaus4', 'gaus5', 'gaus6', 'gaus7', 'gaus8', 'mexh', 'morl', 'cgau1', 'cgau2', 'cgau3', 'cgau4', 'cgau5', 'cgau6', 'cgau7', 'cgau8', 'shan', 'fbsp', 'cmor'] = 'db4', level: int | None = None)[source]
Bases:
LinearOperator
Wavelet operator class.
- __init__(domain_shape: Sequence[int] | None = None, dim: tuple[int] | tuple[int, int] | tuple[int, int, int] = (-2, -1), wavelet_name: Literal['haar', 'db1', 'db2', 'db3', 'db4', 'db5', 'db6', 'db7', 'db8', 'db9', 'db10', 'db11', 'db12', 'db13', 'db14', 'db15', 'db16', 'db17', 'db18', 'db19', 'db20', 'db21', 'db22', 'db23', 'db24', 'db25', 'db26', 'db27', 'db28', 'db29', 'db30', 'db31', 'db32', 'db33', 'db34', 'db35', 'db36', 'db37', 'db38', 'sym2', 'sym3', 'sym4', 'sym5', 'sym6', 'sym7', 'sym8', 'sym9', 'sym10', 'sym11', 'sym12', 'sym13', 'sym14', 'sym15', 'sym16', 'sym17', 'sym18', 'sym19', 'sym20', 'coif1', 'coif2', 'coif3', 'coif4', 'coif5', 'coif6', 'coif7', 'coif8', 'coif9', 'coif10', 'coif11', 'coif12', 'coif13', 'coif14', 'coif15', 'coif16', 'coif17', 'bior1.1', 'bior1.3', 'bior1.5', 'bior2.2', 'bior2.4', 'bior2.6', 'bior2.8', 'bior3.1', 'bior3.3', 'bior3.5', 'bior3.7', 'bior3.9', 'bior4.4', 'bior5.5', 'bior6.8', 'rbio1.1', 'rbio1.3', 'rbio1.5', 'rbio2.2', 'rbio2.4', 'rbio2.6', 'rbio2.8', 'rbio3.1', 'rbio3.3', 'rbio3.5', 'rbio3.7', 'rbio3.9', 'rbio4.4', 'rbio5.5', 'rbio6.8', 'dmey', 'gaus1', 'gaus2', 'gaus3', 'gaus4', 'gaus5', 'gaus6', 'gaus7', 'gaus8', 'mexh', 'morl', 'cgau1', 'cgau2', 'cgau3', 'cgau4', 'cgau5', 'cgau6', 'cgau7', 'cgau8', 'shan', 'fbsp', 'cmor'] = 'db4', level: int | None = None)[source]
Wavelet operator.
For complex images the wavelet coefficients are calculated for real and imaginary part separately.
For a 2D image, the coefficients are labeled [aa, (ad_n, da_n, dd_n), …, (ad_1, da_1, dd_1)] where a refers to the approximation coefficients and d to the detail coefficients. The index indicates the level.
- Parameters:
domain_shape – Shape of domain where wavelets are calculated. If set to None the shape is taken from the input of the forward operator. The adjoint operator will raise an error.
dim – Dimensions (axes) where wavelets are calculated
wavelet_name – Name of wavelets
level – Highest wavelet level. If set to None, the highest possible level is calculated based on the domain shape.
- Raises:
ValueError – If wavelets are calculated for more than three dimensions.
ValueError – If wavelet dimensions and domain shape do not match.
NotImplementedError – If any dimension of the domain shape is odd. Adjoint will lead to the wrong domain shape.
- adjoint(coefficients_stack: Tensor) tuple[Tensor] [source]
Transform wavelet coefficients to (image) data.
- Parameters:
coefficients_stack – Wavelet coefficients stacked along one dimension
- Return type:
(Image) data
- Raises:
ValueError – If the domain_shape is not defined.
ValueError – If the dimensions along which wavelets are to be calculated are not unique.
- forward(x: Tensor) tuple[Tensor] [source]
Calculate wavelet coefficients from (image) data.
- Parameters:
x – (Image) data
- Return type:
Wavelet coefficients stacked along one dimension
- Raises:
ValueError – If the dimensions along which wavelets are to be calculated are not unique.
- operator_norm(initial_value: Tensor, dim: Sequence[int] | None, max_iterations: int = 20, relative_tolerance: float = 0.0001, absolute_tolerance: float = 1e-05, callback: Callable[[Tensor], None] | None = None) Tensor
Power iteration for computing the operator norm of the linear operator.
- Parameters:
initial_value – initial value to start the iteration; if the initial value contains a zero-vector for one of the considered problems, the function throws an value error.
dim – the dimensions of the tensors on which the operator operates. For example, for a matrix-vector multiplication example, a batched matrix tensor with shape (4,30,80,160), input tensors of shape (4,30,160) to be multiplied, and dim = None, it is understood that the matrix representation of the operator corresponds to a block diagonal operator (with 4*30 matrices) and thus the algorithm returns a tensor of shape (1,1,1) containing one single value. In contrast, if for example, dim=(-1,), the algorithm computes a batched operator norm and returns a tensor of shape (4,30,1) corresponding to the operator norms of the respective matrices in the diagonal of the block-diagonal operator (if considered in matrix representation). In any case, the output of the algorithm has the same number of dimensions as the elements of the domain of the considered operator (whose dimensionality is implicitly defined by choosing dim), such that the pointwise multiplication of the operator norm and elements of the domain (to be for example used in a Landweber iteration) is well-defined.
max_iterations – maximum number of iterations
relative_tolerance – 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 – 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 – user-provided function to be called at each iteration
- Return type:
an estimaton of the operator norm
- property H: LinearOperator
Adjoint operator.
- property gram: LinearOperator
Gram operator.
For a LinearOperator \(A\), the self-adjoint Gram operator is defined as \(A^H A\).
Note: This is a default implementation that can be overwritten by subclasses for more efficient implementations.