spyrit.core.recon.Pinv1Net

class spyrit.core.recon.Pinv1Net(noise, prep, denoi=Identity())[source]

Bases: Module

1D pseudo inverse reconstruction network.

Considering linear measurements \(Y = HX\), where \(H\in\mathbb{R}^{k\times h}\) is the measurement matrix and \(X \in\mathbb{R}^{h\times w}\) is an image, it estimates \(X\) from \(Y\) by computing

\[\hat{X} = \mathcal{G}_\theta(H^\dagger Y),\]

where \(H\) is the Moore-Penrose pseudo inverse of \(H\), and \(\mathcal{G}_\theta\) is a neural network.

The pseudo-inverse is computed along the last dimension, while (learnable) denoising applies to the last two dimensions.

Args:

noise: Acquisition operator that compute (noisy) measurements \(Y = HX\) (see noise)

prep: Preprocessing operator (see prep)

denoi (optional): Image denoising operator \(\mathcal{G}_\theta\) (see nnet). Defaults to Identity.

Input / Output:

input: Ground-truth images \(X\) with shape \((b,c,h,w)\).

output: Reconstructed images \(\hat{X}\) with shape \((b,c,h,w)\).

Attributes:

acqu: Acquisition operator initialized as noise.

prep: Preprocessing operator initialized as prep.

pinv: Analytical reconstruction operator initialized as PseudoInverse().

denoi: Image denoising operator initialized as denoi.

Example:
>>> b,c,h,w = 10,1,48,64
>>> H = torch.rand(15,w)
>>> meas = Linear(H, meas_shape=(1,w))
>>> noise = NoNoise(meas)
>>> prep = DirectPoisson(1.0, meas)
>>> recnet = Pinv1Net(noise, prep)
>>> x = torch.FloatTensor(b,c,h,n).uniform_(-1, 1)
>>> z = recnet(x)
>>> print(z.shape)
>>> print(torch.linalg.norm(x - z)/torch.linalg.norm(x))
torch.Size([10, 1, 64, 64])
tensor(5.8912e-06)

Note

The measurement operator applies to the last dimension of the input tensor, contrary PinvNet where it applies to the last two dimensions. In both cases, the denoising operator applies to the last two dimensions.

Methods

forward(x)

Full pipeline (image-to-image mapping)

reconstruct(x)

Reconstruction (measurement-to-image mapping)

reconstruct_expe(x)

Reconstruction (measurement-to-image mapping) for experimental data.