Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ground truth comparison feature to Python (resolves #410) #581

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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