Skip to content

Commit

Permalink
feat: #410 add groundtruth functionality for comparison
Browse files Browse the repository at this point in the history
- added support for `groundtruth` image comparison in
  `iterative_recon_alg`.

- implemented `groundtruth` handling in error measurement and
  initialization.

- updated documentation to reflect new parameter and its usage.
  • Loading branch information
miguelcsx committed Sep 14, 2024
1 parent 729f146 commit d694a09
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion Python/tigre/algorithms/iterative_recon_alg.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ class IterativeReconAlg(object):
OS_SART_TV
FISTA
:keyword groundtruth: (np.ndarray, optional)
Ground truth image for comparison with the reconstruction.
Default is None.
Usage
--------
>>> import numpy as np
Expand Down Expand Up @@ -134,6 +138,8 @@ def __init__(self, proj, geo, angles, niter, **kwargs):
self.geo = geo
self.niter = niter

self.groundtruth = kwargs.get("groundtruth", None)

self.geo.check_geo(angles)

options = dict(
Expand Down Expand Up @@ -167,6 +173,7 @@ def __init__(self, proj, geo, angles, niter, **kwargs):
"regularisation",
"tviter",
"tvlambda",
"groundtruth",
"hyper",
"fista_p",
"fista_q",
Expand Down Expand Up @@ -203,6 +210,9 @@ def __init__(self, proj, geo, angles, niter, **kwargs):
self.Quameasopts = (
[self.Quameasopts] if isinstance(self.Quameasopts, str) else self.Quameasopts
)
if self.groundtruth is not None:
if "error_norm" not in self.Quameasopts:
self.Quameasopts.append("error_norm")
setattr(self, "lq", np.zeros([len(self.Quameasopts), niter])) # quameasoptslist
else:
setattr(self, "lq", np.zeros([0, niter])) # quameasoptslist
Expand Down Expand Up @@ -356,8 +366,13 @@ def minimizeAwTV(self, res_prev, dtvg):
return AwminTV(res_prev, dtvg, self.numiter_tv, self.delta, self.gpuids)

def error_measurement(self, res_prev, iter):
if self.groundtruth is not None:
comparison_img = self.groundtruth
else:
comparison_img = res_prev

if self.Quameasopts is not None:
self.lq[:, iter] = MQ(self.res, res_prev, self.Quameasopts)
self.lq[:, iter] = MQ(self.res, comparison_img, self.Quameasopts)
if self.computel2:
# compute l2 borm for b-Ax
errornow = im3DNORM(
Expand Down

0 comments on commit d694a09

Please sign in to comment.