spyrit.core.meas.DynamicLinear

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

Bases: Linear

Simulates the measurement of a moving object \(y = H \cdot x(t)\).

Computes linear measurements \(y\) from incoming images: \(y = Hx\), where \(H\) is a linear operator (matrix) and \(x\) is a batch of vectorized images representing a motion picture.

The class is constructed from a matrix \(H\) of shape \((M, N)\), where \(N\) represents the number of pixels in the image and \(M\) the number of measurements and the number of frames in the animated object.

Warning

For each call, there must be exactly as many images in \(x\) as there are measurements in the linear operator used to initialize the class.

Args:

H (torch.tensor): measurement matrix (linear operator) with shape \((M, N)\).

Ord (torch.tensor, optional): Order matrix used to reorder the rows of the measurement matrix \(H\). The first new row of \(H\) will correspond to the highest value in \(Ord\). Must contain \(M\) values. If some values repeat, the order is kept. Defaults to None.

meas_shape (tuple, optional): Shape of the measurement patterns. Must be a tuple of two integers representing the height and width of the patterns. If not specified, the shape is suppposed to be a square image. If not, an error is raised. Defaults to None.

img_shape (tuple, optional): Shape of the image. Must be a tuple of two integers representing the height and width of the image. If not specified, the shape is taken as equal to meas_shape. Setting this value is particularly useful when using an extended field of view.

white_acq (torch.tensor, optional): Eventual spatial gain resulting from detector inhomogeneities. Must have the same shape as the measurement patterns.

Attributes:

H_static (torch.nn.Parameter): The learnable measurement matrix of shape \((M,N)\) initialized as \(H\). Only real values are supported.

M (int): Number of measurements performed by the linear operator.

N (int): Number of pixels in the image.

h (int): Measurement pattern height.

w (int): Measurement pattern width.

meas_shape (tuple): Shape of the measurement patterns (height, width). Is equal to (self.h, self.w).

img_h (int): Image height.

img_w (int): Image width.

img_shape (tuple): Shape of the image (height, width). Is equal to (self.img_h, self.img_w).

H_dyn (torch.tensor): Dynamic measurement matrix \(H\). Must be set using the method build_H_dyn() before being accessed.

H (torch.tensor): Alias for H_dyn.

H_dyn_pinv (torch.tensor): Dynamic pseudo-inverse measurement matrix \(H_{dyn}^\dagger\). Must be set using the method build_H_dyn_pinv() before being accessed.

H_pinv (torch.tensor): Alias for H_dyn_pinv.

Warning

The attributes H and H_pinv are used as aliases for H_dyn and H_dyn_pinv. If you want to access the static versions of the attributes, be sure to include the suffix _static.

Example:

# >>> H_static = torch.rand([400, 1600]) # >>> meas_op = DynamicLinear(H_static) # >>> print(meas_op) # DynamicLinear( # (M): 400 # (N): 1600 # (H.shape): torch.Size([400, 1600]) # (meas_shape): (40, 40) # (H_dyn): False # (img_shape): (40, 40) # (H_pinv): False # )

Reference:

Methods

adjoint(m[, unvectorize])

Apply adjoint of matrix H.

approx_inv_deform(def_field)

build_H_dyn(motion[, mode, warping])

Build the dynamic measurement matrix H_dyn.

build_H_dyn_pinv([reg, eta])

Computes the pseudo-inverse of the dynamic measurement matrix H_dyn and stores it in the attribute H_dyn_pinv.

calc_det(def_field)

forward(x)

Simulates the measurement of a motion picture \(y = H \cdot x(t)\).

forward_H_dyn(x)

Simulates the acquisition of measurements using the dynamic measurement matrix H_dyn.

measure(x)

Simulate noiseless measurements

unvectorize(input)

Unflatten the measured dimensions.

vectorize(input)

Flatten the measured dimensions.