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

Various improvements related to the new X-ray transform implemementation. #36

Merged
merged 9 commits into from
Nov 2, 2023
Merged
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
Binary file modified docs/figures/scico-tomo-overview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions notebooks/ct_abel_tv_admm.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"import scico.numpy as snp\n",
"from scico import functional, linop, loss, metric, plot\n",
"from scico.examples import create_circular_phantom\n",
"from scico.linop.abel import AbelProjector\n",
"from scico.linop.abel import AbelTransform\n",
"from scico.optimize.admm import ADMM, LinearSubproblemSolver\n",
"from scico.util import device_info\n",
"plot.config_notebook_plotting()"
Expand Down Expand Up @@ -96,7 +96,7 @@
},
"outputs": [],
"source": [
"A = AbelProjector(x_gt.shape)\n",
"A = AbelTransform(x_gt.shape)\n",
"y = A @ x_gt\n",
"np.random.seed(12345)\n",
"y = y + np.random.normal(size=y.shape).astype(np.float32)"
Expand Down
6 changes: 3 additions & 3 deletions notebooks/ct_abel_tv_admm_tune.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"import scico.numpy as snp\n",
"from scico import functional, linop, loss, metric, plot\n",
"from scico.examples import create_circular_phantom\n",
"from scico.linop.abel import AbelProjector\n",
"from scico.linop.abel import AbelTransform\n",
"from scico.optimize.admm import ADMM, LinearSubproblemSolver\n",
"from scico.ray import tune\n",
"plot.config_notebook_plotting()"
Expand Down Expand Up @@ -109,7 +109,7 @@
},
"outputs": [],
"source": [
"A = AbelProjector(x_gt.shape)\n",
"A = AbelTransform(x_gt.shape)\n",
"y = A @ x_gt\n",
"np.random.seed(12345)\n",
"y = y + np.random.normal(size=y.shape).astype(np.float32)"
Expand Down Expand Up @@ -179,7 +179,7 @@
" # Get arrays passed by tune call.\n",
" self.x_gt, self.x0, self.y = snp.array(x_gt), snp.array(x0), snp.array(y)\n",
" # Set up problem to be solved.\n",
" self.A = AbelProjector(self.x_gt.shape)\n",
" self.A = AbelTransform(self.x_gt.shape)\n",
" self.f = loss.SquaredL2Loss(y=self.y, A=self.A)\n",
" self.C = linop.FiniteDifference(input_shape=self.x_gt.shape)\n",
" self.reset_config(config)\n",
Expand Down
12 changes: 5 additions & 7 deletions notebooks/ct_astra_3d_tv_admm.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
" $$\\mathrm{argmin}_{\\mathbf{x}} \\; (1/2) \\| \\mathbf{y} - A \\mathbf{x}\n",
" \\|_2^2 + \\lambda \\| C \\mathbf{x} \\|_{2,1} \\;,$$\n",
"\n",
"where $A$ is the Radon transform, $\\mathbf{y}$ is the sinogram, $C$ is\n",
"a 3D finite difference operator, and $\\mathbf{x}$ is the desired\n",
"image."
"where $A$ is the X-ray transform (the CT forward projection operator),\n",
"$\\mathbf{y}$ is the sinogram, $C$ is a 3D finite difference operator,\n",
"and $\\mathbf{x}$ is the desired image."
]
},
{
Expand All @@ -42,7 +42,7 @@
"import scico.numpy as snp\n",
"from scico import functional, linop, loss, metric, plot\n",
"from scico.examples import create_tangle_phantom\n",
"from scico.linop.radon_astra import TomographicProjector\n",
"from scico.linop.xray.astra import XRayTransform\n",
"from scico.optimize.admm import ADMM, LinearSubproblemSolver\n",
"from scico.util import device_info\n",
"plot.config_notebook_plotting()"
Expand Down Expand Up @@ -79,9 +79,7 @@
"\n",
"n_projection = 10 # number of projections\n",
"angles = np.linspace(0, np.pi, n_projection) # evenly spaced projection angles\n",
"A = TomographicProjector(\n",
" tangle.shape, [1.0, 1.0], [Nz, max(Nx, Ny)], angles\n",
") # Radon transform operator\n",
"A = XRayTransform(tangle.shape, [1.0, 1.0], [Nz, max(Nx, Ny)], angles) # CT projection operator\n",
"y = A @ tangle # sinogram"
]
},
Expand Down
6 changes: 3 additions & 3 deletions notebooks/ct_astra_modl_train_foam2.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"from scico import metric, plot\n",
"from scico.flax.examples import load_ct_data\n",
"from scico.flax.train.traversals import clip_positive, construct_traversal\n",
"from scico.linop.radon_astra import TomographicProjector\n",
"from scico.linop.xray.astra import XRayTransform\n",
"plot.config_notebook_plotting()"
]
},
Expand Down Expand Up @@ -175,12 +175,12 @@
"outputs": [],
"source": [
"angles = np.linspace(0, np.pi, n_projection) # evenly spaced projection angles\n",
"A = TomographicProjector(\n",
"A = XRayTransform(\n",
" input_shape=(N, N),\n",
" detector_spacing=1,\n",
" det_count=N,\n",
" angles=angles,\n",
") # Radon transform operator\n",
") # CT projection operator\n",
"A = (1.0 / N) * A # normalized"
]
},
Expand Down
8 changes: 4 additions & 4 deletions notebooks/ct_astra_noreg_pcg.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
" $$\\mathrm{argmin}_{\\mathbf{x}} \\; (1/2) \\| \\mathbf{y} - A \\mathbf{x}\n",
" \\|_2^2 \\;,$$\n",
"\n",
"where $A$ is the Radon transform, $\\mathbf{y}$ is the sinogram, and\n",
"$\\mathbf{x}$ is the reconstructed image."
"where $A$ is the X-ray transform (the CT forward projection operator),\n",
"$\\mathbf{y}$ is the sinogram, and $\\mathbf{x}$ is the reconstructed image."
]
},
{
Expand Down Expand Up @@ -44,7 +44,7 @@
"\n",
"from scico import loss, plot\n",
"from scico.linop import CircularConvolve\n",
"from scico.linop.radon_astra import TomographicProjector\n",
"from scico.linop.xray.astra import XRayTransform\n",
"from scico.solver import cg\n",
"plot.config_notebook_plotting()"
]
Expand Down Expand Up @@ -102,7 +102,7 @@
"source": [
"n_projection = N # matches the phantom size so this is not few-view CT\n",
"angles = np.linspace(0, np.pi, n_projection) # evenly spaced projection angles\n",
"A = 1 / N * TomographicProjector(x_gt.shape, 1, N, angles) # Radon transform operator\n",
"A = 1 / N * XRayTransform(x_gt.shape, 1, N, angles) # CT projection operator\n",
"y = A @ x_gt # sinogram"
]
},
Expand Down
6 changes: 3 additions & 3 deletions notebooks/ct_astra_odp_train_foam2.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"from scico import metric, plot\n",
"from scico.flax.examples import load_ct_data\n",
"from scico.flax.train.traversals import clip_positive, construct_traversal\n",
"from scico.linop.radon_astra import TomographicProjector\n",
"from scico.linop.xray.astra import XRayTransform\n",
"plot.config_notebook_plotting()"
]
},
Expand Down Expand Up @@ -179,12 +179,12 @@
"outputs": [],
"source": [
"angles = np.linspace(0, np.pi, n_projection) # evenly spaced projection angles\n",
"A = TomographicProjector(\n",
"A = XRayTransform(\n",
" input_shape=(N, N),\n",
" detector_spacing=1,\n",
" det_count=N,\n",
" angles=angles,\n",
") # Radon transform operator\n",
") # CT projection operator\n",
"A = (1.0 / N) * A # normalized"
]
},
Expand Down
10 changes: 5 additions & 5 deletions notebooks/ct_astra_tv_admm.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
" $$\\mathrm{argmin}_{\\mathbf{x}} \\; (1/2) \\| \\mathbf{y} - A \\mathbf{x}\n",
" \\|_2^2 + \\lambda \\| C \\mathbf{x} \\|_{2,1} \\;,$$\n",
"\n",
"where $A$ is the Radon transform, $\\mathbf{y}$ is the sinogram, $C$ is\n",
"a 2D finite difference operator, and $\\mathbf{x}$ is the desired\n",
"image."
"where $A$ is the X-ray transform (the CT forward projection operator),\n",
"$\\mathbf{y}$ is the sinogram, $C$ is a 2D finite difference operator, and\n",
"$\\mathbf{x}$ is the desired image."
]
},
{
Expand All @@ -41,7 +41,7 @@
"\n",
"import scico.numpy as snp\n",
"from scico import functional, linop, loss, metric, plot\n",
"from scico.linop.radon_astra import TomographicProjector\n",
"from scico.linop.xray.astra import XRayTransform\n",
"from scico.optimize.admm import ADMM, LinearSubproblemSolver\n",
"from scico.util import device_info\n",
"plot.config_notebook_plotting()"
Expand Down Expand Up @@ -101,7 +101,7 @@
"source": [
"n_projection = 45 # number of projections\n",
"angles = np.linspace(0, np.pi, n_projection) # evenly spaced projection angles\n",
"A = TomographicProjector(x_gt.shape, 1, N, angles) # Radon transform operator\n",
"A = XRayTransform(x_gt.shape, 1, N, angles) # CT projection operator\n",
"y = A @ x_gt # sinogram"
]
},
Expand Down
14 changes: 7 additions & 7 deletions notebooks/ct_astra_weighted_tv_admm.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
" $$\\mathrm{argmin}_{\\mathbf{x}} \\; (1/2) \\| \\mathbf{y} - A \\mathbf{x}\n",
" \\|_W^2 + \\lambda \\| C \\mathbf{x} \\|_{2,1} \\;,$$\n",
"\n",
"where $A$ is the Radon transform, $\\mathbf{y}$ is the sinogram, the norm\n",
"weighting $W$ is chosen so that the weighted norm is an approximation to\n",
"the Poisson negative log likelihood <cite data-cite=\"sauer-1993-local\"/>, $C$ is\n",
"a 2D finite difference operator, and $\\mathbf{x}$ is the desired\n",
"image."
"where $A$ is the X-ray transform (the CT forward projection),\n",
"$\\mathbf{y}$ is the sinogram, the norm weighting $W$ is chosen so that\n",
"the weighted norm is an approximation to the Poisson negative log\n",
"likelihood <cite data-cite=\"sauer-1993-local\"/>, $C$ is a 2D finite difference\n",
"operator, and $\\mathbf{x}$ is the desired image."
]
},
{
Expand All @@ -42,7 +42,7 @@
"\n",
"import scico.numpy as snp\n",
"from scico import functional, linop, loss, metric, plot\n",
"from scico.linop.radon_astra import TomographicProjector\n",
"from scico.linop.xray.astra import XRayTransform\n",
"from scico.optimize.admm import ADMM, LinearSubproblemSolver\n",
"from scico.util import device_info\n",
"plot.config_notebook_plotting()"
Expand Down Expand Up @@ -108,7 +108,7 @@
"𝛼 = 1e-2 # attenuation coefficient\n",
"\n",
"angles = np.linspace(0, 2 * np.pi, n_projection) # evenly spaced projection angles\n",
"A = TomographicProjector(x_gt.shape, 1.0, N, angles) # Radon transform operator\n",
"A = XRayTransform(x_gt.shape, 1.0, N, angles) # CT projection operator\n",
"y_c = A @ x_gt # sinogram"
]
},
Expand Down
6 changes: 3 additions & 3 deletions notebooks/ct_fan_svmbir_ppp_bm3d_admm_prox.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"from scico import metric, plot\n",
"from scico.functional import BM3D\n",
"from scico.linop import Diagonal, Identity\n",
"from scico.linop.radon_svmbir import SVMBIRExtendedLoss, TomographicProjector\n",
"from scico.linop.xray.svmbir import SVMBIRExtendedLoss, XRayTransform\n",
"from scico.optimize.admm import ADMM, LinearSubproblemSolver\n",
"from scico.util import device_info\n",
"plot.config_notebook_plotting()"
Expand Down Expand Up @@ -122,15 +122,15 @@
"\n",
"dist_source_detector = 1500.0\n",
"magnification = 1.2\n",
"A_fan = TomographicProjector(\n",
"A_fan = XRayTransform(\n",
" x_gt.shape,\n",
" angles,\n",
" num_channels,\n",
" geometry=\"fan-curved\",\n",
" dist_source_detector=dist_source_detector,\n",
" magnification=magnification,\n",
")\n",
"A_parallel = TomographicProjector(\n",
"A_parallel = XRayTransform(\n",
" x_gt.shape,\n",
" angles,\n",
" num_channels,\n",
Expand Down
Loading