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

Clean up some example scripts and rerun some notebooks #464

Merged
merged 9 commits into from
Nov 9, 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
3 changes: 3 additions & 0 deletions docs/source/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Computed Tomography
examples/ct_astra_noreg_pcg
examples/ct_astra_3d_tv_admm
examples/ct_astra_tv_admm
examples/ct_tv_admm
examples/ct_astra_weighted_tv_admm
examples/ct_svmbir_tv_multi
examples/ct_svmbir_ppp_bm3d_admm_cg
Expand Down Expand Up @@ -129,6 +130,7 @@ Total Variation
examples/ct_abel_tv_admm
examples/ct_abel_tv_admm_tune
examples/ct_astra_tv_admm
examples/ct_tv_admm
examples/ct_astra_3d_tv_admm
examples/ct_astra_weighted_tv_admm
examples/ct_svmbir_tv_multi
Expand Down Expand Up @@ -197,6 +199,7 @@ ADMM
examples/ct_abel_tv_admm
examples/ct_abel_tv_admm_tune
examples/ct_astra_tv_admm
examples/ct_tv_admm
examples/ct_astra_3d_tv_admm
examples/ct_astra_weighted_tv_admm
examples/ct_svmbir_tv_multi
Expand Down
12 changes: 9 additions & 3 deletions examples/scripts/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ Computed Tomography
`ct_astra_3d_tv_admm.py <ct_astra_3d_tv_admm.py>`_
3D TV-Regularized Sparse-View CT Reconstruction
`ct_astra_tv_admm.py <ct_astra_tv_admm.py>`_
TV-Regularized Sparse-View CT Reconstruction
TV-Regularized Sparse-View CT Reconstruction (ASTRA Projector)
`ct_tv_admm.py <ct_tv_admm.py>`_
TV-Regularized Sparse-View CT Reconstruction (Integrated Projector)
`ct_astra_weighted_tv_admm.py <ct_astra_weighted_tv_admm.py>`_
TV-Regularized Low-Dose CT Reconstruction
`ct_svmbir_tv_multi.py <ct_svmbir_tv_multi.py>`_
Expand Down Expand Up @@ -159,7 +161,9 @@ Total Variation
`ct_abel_tv_admm_tune.py <ct_abel_tv_admm_tune.py>`_
Parameter Tuning for TV-Regularized Abel Inversion
`ct_astra_tv_admm.py <ct_astra_tv_admm.py>`_
TV-Regularized Sparse-View CT Reconstruction
TV-Regularized Sparse-View CT Reconstruction (ASTRA Projector)
`ct_tv_admm.py <ct_tv_admm.py>`_
TV-Regularized Sparse-View CT Reconstruction (Integrated Projector)
`ct_astra_3d_tv_admm.py <ct_astra_3d_tv_admm.py>`_
3D TV-Regularized Sparse-View CT Reconstruction
`ct_astra_weighted_tv_admm.py <ct_astra_weighted_tv_admm.py>`_
Expand Down Expand Up @@ -252,7 +256,9 @@ ADMM
`ct_abel_tv_admm_tune.py <ct_abel_tv_admm_tune.py>`_
Parameter Tuning for TV-Regularized Abel Inversion
`ct_astra_tv_admm.py <ct_astra_tv_admm.py>`_
TV-Regularized Sparse-View CT Reconstruction
TV-Regularized Sparse-View CT Reconstruction (ASTRA Projector)
`ct_tv_admm.py <ct_tv_admm.py>`_
TV-Regularized Sparse-View CT Reconstruction (Integrated Projector)
`ct_astra_3d_tv_admm.py <ct_astra_3d_tv_admm.py>`_
3D TV-Regularized Sparse-View CT Reconstruction
`ct_astra_weighted_tv_admm.py <ct_astra_weighted_tv_admm.py>`_
Expand Down
9 changes: 6 additions & 3 deletions examples/scripts/ct_astra_tv_admm.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
# with the package.

r"""
TV-Regularized Sparse-View CT Reconstruction
============================================
TV-Regularized Sparse-View CT Reconstruction (ASTRA Projector)
==============================================================

This example demonstrates solution of a sparse-view CT reconstruction
problem with isotropic total variation (TV) regularization
Expand All @@ -16,7 +16,10 @@

where $A$ is the X-ray transform (the CT forward projection operator),
$\mathbf{y}$ is the sinogram, $C$ is a 2D finite difference operator, and
$\mathbf{x}$ is the desired image.
$\mathbf{x}$ is the desired image. This example uses the CT projector
provided by the astra package, while the companion
[example script](ct_tv_admm.rst) uses the projector integrated into
scico.
"""

import numpy as np
Expand Down
5 changes: 1 addition & 4 deletions examples/scripts/ct_multi_cs_tv_admm.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@

import numpy as np

import jax

from xdesign import Foam, discrete_phantom

import scico.numpy as snp
Expand All @@ -38,8 +36,7 @@
"""
N = 512 # phantom size
np.random.seed(1234)
x_gt = discrete_phantom(Foam(size_range=[0.075, 0.0025], gap=1e-3, porosity=1), size=N)
x_gt = jax.device_put(x_gt)
x_gt = snp.array(discrete_phantom(Foam(size_range=[0.075, 0.0025], gap=1e-3, porosity=1), size=N))


"""
Expand Down
5 changes: 1 addition & 4 deletions examples/scripts/ct_multi_tv_admm.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@

import numpy as np

import jax

from xdesign import Foam, discrete_phantom

import scico.numpy as snp
Expand All @@ -37,8 +35,7 @@
"""
N = 512 # phantom size
np.random.seed(1234)
x_gt = discrete_phantom(Foam(size_range=[0.075, 0.0025], gap=1e-3, porosity=1), size=N)
x_gt = jax.device_put(x_gt)
x_gt = snp.array(discrete_phantom(Foam(size_range=[0.075, 0.0025], gap=1e-3, porosity=1), size=N))


"""
Expand Down
5 changes: 1 addition & 4 deletions examples/scripts/ct_tv_admm.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@

import numpy as np

import jax

from mpl_toolkits.axes_grid1 import make_axes_locatable
from xdesign import Foam, discrete_phantom

Expand All @@ -40,8 +38,7 @@
"""
N = 512 # phantom size
np.random.seed(1234)
x_gt = discrete_phantom(Foam(size_range=[0.075, 0.0025], gap=1e-3, porosity=1), size=N)
x_gt = jax.device_put(x_gt) # convert to jax type, push to GPU
x_gt = snp.array(discrete_phantom(Foam(size_range=[0.075, 0.0025], gap=1e-3, porosity=1), size=N))


"""
Expand Down
3 changes: 3 additions & 0 deletions examples/scripts/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Computed Tomography
- ct_astra_noreg_pcg.py
- ct_astra_3d_tv_admm.py
- ct_astra_tv_admm.py
- ct_tv_admm.py
- ct_astra_weighted_tv_admm.py
- ct_svmbir_tv_multi.py
- ct_svmbir_ppp_bm3d_admm_cg.py
Expand Down Expand Up @@ -98,6 +99,7 @@ Total Variation
- ct_abel_tv_admm.py
- ct_abel_tv_admm_tune.py
- ct_astra_tv_admm.py
- ct_tv_admm.py
- ct_astra_3d_tv_admm.py
- ct_astra_weighted_tv_admm.py
- ct_svmbir_tv_multi.py
Expand Down Expand Up @@ -154,6 +156,7 @@ ADMM
- ct_abel_tv_admm.py
- ct_abel_tv_admm_tune.py
- ct_astra_tv_admm.py
- ct_tv_admm.py
- ct_astra_3d_tv_admm.py
- ct_astra_weighted_tv_admm.py
- ct_svmbir_tv_multi.py
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ scipy>=1.6.0
tifffile
imageio>=2.17
matplotlib
jaxlib>=0.4.3,<=0.4.19
jax>=0.4.3,<=0.4.19
jaxlib>=0.4.3,<=0.4.20
jax>=0.4.3,<=0.4.20
flax>=0.6.1,<=0.6.9
svmbir>=0.3.3
pyabel>=0.9.0
Loading