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

Issue410: Added groundtruth comparion flags to ./python/TIGRE/algorithms #556

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
22 changes: 20 additions & 2 deletions Python/tigre/algorithms/iterative_recon_alg.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ class IterativeReconAlg(object):
OS_SART_TV
FISTA


:keyword groundtruth: ()
groundtruth image for comparison with the reconstruction.
Default is None


Usage
--------
>>> import numpy as np
Expand Down Expand Up @@ -133,6 +139,9 @@ def __init__(self, proj, geo, angles, niter, **kwargs):
self.angles = angles
self.geo = geo
self.niter = niter

# adding groundtruth comparison
self.groundtruth = None if "groundtruth" not in kwargs else kwargs["groundtruth"]

self.geo.check_geo(angles)

Expand Down Expand Up @@ -203,6 +212,9 @@ def __init__(self, proj, geo, angles, niter, **kwargs):
self.Quameasopts = (
[self.Quameasopts] if isinstance(self.Quameasopts, str) else self.Quameasopts
)
# appending error_norm is groundtruth is Null
if self.groundtruth is not None:
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 @@ -311,7 +323,8 @@ def run_main_iter(self):
Quameasopts = self.Quameasopts

for i in range(self.niter):

# init Quameasopts
Quameasopts = self.Quameasopts
res_prev = None
if Quameasopts is not None:
res_prev = copy.deepcopy(self.res)
Expand Down Expand Up @@ -357,7 +370,10 @@ def minimizeAwTV(self, res_prev, dtvg):

def error_measurement(self, res_prev, iter):
if self.Quameasopts is not None:
self.lq[:, iter] = MQ(self.res, res_prev, self.Quameasopts)
if self.groundtruth is not None:
self.lq[:, iter] = MQ(self.res, self.groundtruth, self.Quameasopts)
else:
self.lq[:, iter] = MQ(self.res, res_prev, self.Quameasopts)
if self.computel2:
# compute l2 borm for b-Ax
errornow = im3DNORM(
Expand Down Expand Up @@ -481,3 +497,5 @@ def iterativereconalg(proj, geo, angles, niter, **kwargs):


iterativereconalg = decorator(IterativeReconAlg)

# have to find a usecase to groundtruth comparing with matlab
5 changes: 4 additions & 1 deletion Python/tigre/algorithms/single_pass_algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,10 @@ def FDK(proj, geo, angles, **kwargs):
PYTHON : Reuben Lindroos
"""
verbose = kwargs["verbose"] if "verbose" in kwargs else False

gpuids = kwargs["gpuids"] if "gpuids" in kwargs else None
dowang = kwargs["dowang"] if "dowang" in kwargs else False
# adding groundtruth comparison
groundtruth = None if "groundtruth" not in kwargs else kwargs["groundtruth"]

def zeropadding(proj, geo):
zgeo = copy.deepcopy(geo)
Expand Down Expand Up @@ -192,4 +193,6 @@ def fbp(proj, geo, angles, **kwargs): # noqa: D103
gpuids = kwargs["gpuids"] if "gpuids" in kwargs else None
proj_filt = filtering(copy.deepcopy(proj), geox,
angles, parker=False, verbose=verbose)
# adding groundtruth comparison
groundtruth = None if "groundtruth" not in kwargs else kwargs["groundtruth"]
return Atb(proj_filt, geo, angles, gpuids=gpuids) * geo.DSO / geo.DSD