From 34771daa0441760ef7f5a74878291e2698c62462 Mon Sep 17 00:00:00 2001 From: Ameya Khot <90050951+ameyakhot@users.noreply.github.com> Date: Sat, 8 Jun 2024 17:57:17 -0500 Subject: [PATCH 1/3] Issue410: Added groundtruth comparion flags to ./Python/tigre/algorithms/iterative_recon_alg.py and ./Python/tigre/algorithms/single_pass_algorithms.py --- Python/tigre/algorithms/iterative_recon_alg.py | 9 +++++++++ Python/tigre/algorithms/single_pass_algorithms.py | 5 ++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Python/tigre/algorithms/iterative_recon_alg.py b/Python/tigre/algorithms/iterative_recon_alg.py index b882b97b..47b7487b 100644 --- a/Python/tigre/algorithms/iterative_recon_alg.py +++ b/Python/tigre/algorithms/iterative_recon_alg.py @@ -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 @@ -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) diff --git a/Python/tigre/algorithms/single_pass_algorithms.py b/Python/tigre/algorithms/single_pass_algorithms.py index 7ab33f71..f2442268 100644 --- a/Python/tigre/algorithms/single_pass_algorithms.py +++ b/Python/tigre/algorithms/single_pass_algorithms.py @@ -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) @@ -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 From 69afbcf94ec3ffa20d1fcd15e800805540ff577a Mon Sep 17 00:00:00 2001 From: Ameya Khot <90050951+ameyakhot@users.noreply.github.com> Date: Mon, 17 Jun 2024 17:18:19 -0500 Subject: [PATCH 2/3] Added a small functionality to Iterative_recon_alg - ref SART.m --- Python/tigre/algorithms/iterative_recon_alg.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Python/tigre/algorithms/iterative_recon_alg.py b/Python/tigre/algorithms/iterative_recon_alg.py index 47b7487b..9994ecca 100644 --- a/Python/tigre/algorithms/iterative_recon_alg.py +++ b/Python/tigre/algorithms/iterative_recon_alg.py @@ -212,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 @@ -320,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) @@ -366,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( From 091f0fe83e487c1a8509b294395ebe864935cd5a Mon Sep 17 00:00:00 2001 From: Ameya Khot <90050951+ameyakhot@users.noreply.github.com> Date: Wed, 19 Jun 2024 23:11:05 -0500 Subject: [PATCH 3/3] added a comment for now for tasklist --- Python/tigre/algorithms/iterative_recon_alg.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Python/tigre/algorithms/iterative_recon_alg.py b/Python/tigre/algorithms/iterative_recon_alg.py index 9994ecca..898e5c3e 100644 --- a/Python/tigre/algorithms/iterative_recon_alg.py +++ b/Python/tigre/algorithms/iterative_recon_alg.py @@ -497,3 +497,5 @@ def iterativereconalg(proj, geo, angles, niter, **kwargs): iterativereconalg = decorator(IterativeReconAlg) + +# have to find a usecase to groundtruth comparing with matlab \ No newline at end of file