pytomography.priors.gibbs - PyTomography 0.1 documentation

Hide navigation sidebar
Hide table of contents sidebar
Back to top
Toggle table of contents sidebar

# `pytomography.priors.gibbs`

## Module Contents

### Classes

`DiffAndSumSmoothnessPrior` | Implementation of priors where gradients depend on difference and the sum of neighbouring voxels:
`QClearPrior` | Implentation of SmoothnessPrior where \(\phi\) is the the QClear Function (DEFINE HERE)

### Functions

`QClear`(sum, diff, gamma[, eps]) |

class pytomography.priors.gibbs.DiffAndSumSmoothnessPrior(beta, phi, device='cpu', **kwargs)

  Bases: `pytomography.priors.prior.Prior`

  Implementation of priors where gradients depend on difference and the sum of neighbouring voxels: \(\frac{\partial V}{\partial f_r}=\frac{\beta}{\delta}\sum_{r,s}w_{s}\phi\left(\frac{f_r-f_s}{\delta}\right)\) where \(V\) is from the log-posterior probability \(\log P(g | f) - \beta V(f)\).

  Parameters:

    - beta (float) –

    - phi (collections.abc.Callable) –

    - device (str) –

  get_kernel(sign=1)

    Obtains the kernel used to get \(\frac{\partial V}{\partial f_r}\) (this is an array with the same dimensions as the object space image)

    Parameters:

      sign (float) – Kernel computes image \(f_r + \text{sign} \cdot f_k\) for all 26 nearest neighbours \(k\) (i.e. a 3D image is returned with 26 channels). Defaults to 1.

    Returns:

      Kernel used for convolution (number of output channels equal to number of \(s\)), and array of weights \(w_s\) used in expression for gradient.

    Return type:

      (torch.nn.Conv3d, torch.tensor)

  set_kernel(object_meta)

    Sets the kernel using get_kernel and the corresponding object metadata.

    Parameters:

      object_meta (ObjectMeta) – Metadata for object space.

    Return type:

      None

  forward()

    Computes the prior on `self.object`

    Returns:

      Tensor of shape [batch_size, Lx, Ly, Lz] representing \(\frac{\partial V}{\partial f_r}\)

    Return type:

      torch.tensor

class pytomography.priors.gibbs.QClearPrior(beta=1, gamma=1, device='cpu')

  Bases: `DiffAndSumSmoothnessPrior`

  Implentation of SmoothnessPrior where \(\phi\) is the the QClear Function (DEFINE HERE)

  Parameters:

    - beta (float) –

    - gamma (float) –

    - device (str) –

pytomography.priors.gibbs.QClear(sum, diff, gamma, eps=1e-11)