spyrit.core.meas.FreeformLinearSplit

class spyrit.core.meas.FreeformLinearSplit(H: tensor, meas_shape: int | Size | Iterable[int] = None, meas_dims: int | Size | Iterable[int] = None, index_mask: tensor = None, bool_mask: tensor = None, *, noise_model: Module = Identity(), dtype: dtype = torch.float32, device: device = device(type='cpu'))[source]

Bases: LinearSplit

Simulate split measurements in a region of interest

\[m =\mathcal{N}\left(Ax\right), \quad \text{where }x = \text{mask}(\tilde{x})\]

where \(\mathcal{N} \colon\, \mathbb{R}^M \to \mathbb{R}^M\) represents a noise operator (e.g., Gaussian), \(A\in\mathbb{R}_+^{2M\times N}\) is the acquisition matrix, \(x \in \mathbb{R}^N\) is the signal in the region of interest, \(2M\) is the number of measurements, \(N\) is the number of pixels in the region of interest, \(\text{mask} \colon\, \mathbb{R}^\tilde{N} \to \mathbb{R}^N\) represents the masking operation, \(\tilde{x} \in \mathbb{R}^\tilde{N}\) is the full signal, and \(\tilde{N}\ge N\) is the dimension of the full signal \(\tilde{x}\).

Example: Select one every second point on the diagonal of a batch of images
>>> from spyrit.core.meas import FreeformLinearSplit
>>> import torch
>>> images = torch.rand(17, 3, 40, 40)
>>> mask = torch.tensor([[i, i] for i in range(0,40,2)]).T
>>> H = torch.randn(13, 20)
>>> meas_op = FreeformLinearSplit(H, meas_shape=(40,40), index_mask=mask)
>>> x_masked = meas_op(images)
>>> print(x_masked.shape)
torch.Size([17, 3, 26])

Methods

adjoint(y[, unvectorize])

Apply adjoint of matrix A.

adjoint_H(m[, unvectorize])

Apply adjoint of matrix H.

forward(x)

Simulate measurements.

forward_H(x)

Simulate measurements.

measure(x)

Simulate measurements from signal/image.

measure_H(x)

Simulate measurements from signal/image.

set_matrix_to_inverse(matrix_name)

unvectorize(x[, fill_value])

Unflatten the last dimension of a tensor to the measurement shape at the measured dimensions based on the mask.

vectorize(x)

Appplies the saved mask to the input tensor, where the masked dimensions are collapsed into one.