pytomography.likelihoods.poisson_log_likelihood#
Module Contents#
Classes#
The log-likelihood function for Poisson random variables. The likelihood is given by \(L(g|f) = \sum_i g_i [\ln(Hf)]_i - [Hf]_i - ...\). The \(...\) contains terms that are not dependent on \(f\). |
|
Adapated Poisson log likelihood for Monte Carlo hybrid SPECT system matrix. |
- class pytomography.likelihoods.poisson_log_likelihood.PoissonLogLikelihood(system_matrix, projections=None, additive_term=None, additive_term_variance_estimate=None)[source]#
Bases:
pytomography.likelihoods.likelihood.LikelihoodThe log-likelihood function for Poisson random variables. The likelihood is given by \(L(g|f) = \sum_i g_i [\ln(Hf)]_i - [Hf]_i - ...\). The \(...\) contains terms that are not dependent on \(f\).
- Parameters:
system_matrix (SystemMatrix) – The system matrix \(H\) modeling the particular system whereby the projections were obtained
projections (torch.Tensor) – Acquired data (assumed to have Poisson statistics).
additive_term (torch.Tensor, optional) – Additional term added after forward projection by the system matrix. This term might include things like scatter and randoms. Defaults to None.
additive_term_variance_estimate (collections.abc.Callable | None) –
- compute_gradient(object, subset_idx=None, norm_BP_subset_method='subset_specific')[source]#
Computes the gradient for the Poisson log likelihood given by \(\nabla_f L(g|f) = H^T (g / Hf) - H^T 1\).
- Parameters:
object (torch.Tensor) – Object \(f\) on which the likelihood is computed
subset_idx (int | None, optional) – Specifies the subset for forward/back projection. If none, then forward/back projection is done over all subsets, and the entire projections \(g\) are used. Defaults to None.
norm_BP_subset_method (str, optional) – Specifies how \(H^T 1\) is calculated when subsets are used. If ‘subset_specific’, then uses \(H_m^T 1\). If average_of_subsets, then uses the average of all :math:`H_m^T 1`s for any given subset (scaled to the relative size of the subset if subsets are not equal size). Defaults to ‘subset_specific’.
- Returns:
The gradient of the Poisson likelihood.
- Return type:
torch.Tensor
- compute_gradient_ff(object, precomputed_forward_projection=None, subset_idx=None)[source]#
Computes the second order derivative \(\nabla_{ff} L(g|f) = -H^T (g/(Hf+s)^2) H\).
- Parameters:
object (torch.Tensor) – Object \(f\) used in computation.
precomputed_forward_projection (torch.Tensor | None, optional) – The quantity \(Hf\). If this value is None, then the forward projection is recomputed. Defaults to None.
subset_idx (int, optional) – Specifies the subset for all computations. Defaults to None.
- Returns:
The operator given by the second order derivative.
- Return type:
Callable
- compute_gradient_gf(object, precomputed_forward_projection=None, subset_idx=None)[source]#
Computes the second order derivative \(\nabla_{gf} L(g|f) = 1/(Hf+s) H\).
- Parameters:
object (torch.Tensor) – Object \(f\) used in computation.
precomputed_forward_projection (torch.Tensor | None, optional) – The quantity \(Hf\). If this value is None, then the forward projection is recomputed. Defaults to None.
subset_idx (int, optional) – Specifies the subset for all computations. Defaults to None.
- Returns:
The operator given by the second order derivative.
- Return type:
Callable
- compute_gradient_sf(object, precomputed_forward_projection=None, subset_idx=None)[source]#
Computes the second order derivative \(\nabla_{sf} L(g|f,s) = -g/(Hf+s)^2 H\) where \(s\) is an additive term representative of scatter.
- Parameters:
object (torch.Tensor) – Object \(f\) used in computation.
precomputed_forward_projection (torch.Tensor | None, optional) – The quantity \(Hf\). If this value is None, then the forward projection is recomputed. Defaults to None.
subset_idx (int, optional) – Specifies the subset for all computations. Defaults to None.
- Returns:
The operator given by the second order derivative.
- Return type:
Callable
- class pytomography.likelihoods.poisson_log_likelihood.MonteCarloHybridSPECTPoissonLogLikelihood(system_matrix, projections=None, additive_term=None, additive_term_variance_estimate=None)[source]#
Bases:
PoissonLogLikelihoodAdapated Poisson log likelihood for Monte Carlo hybrid SPECT system matrix.
- Parameters:
system_matrix (pytomography.projectors.SystemMatrix) –
projections (torch.Tensor | None) –
additive_term (torch.Tensor) –
additive_term_variance_estimate (collections.abc.Callable | None) –
- compute_gradient(object, subset_idx=None, norm_BP_subset_method='subset_specific')[source]#
Returns the gradient of the log likelihood with respect to the object. :param object: Object to simulate :type object: torch.Tensor :param subset_idx: Index of the subset to use. If None, then all projections are used. Defaults to None. :type subset_idx: int | None, optional :param norm_BP_subset_method: Method to use for normalizing the back projection. Defaults to ‘subset_specific’. :type norm_BP_subset_method: str, optional
- Returns:
Gradient of the log likelihood with respect to the object
- Return type:
torch.Tensor
- Parameters:
object (torch.Tensor) –
subset_idx (int | None) –
norm_BP_subset_method (str) –