Skip to content

Commit

Permalink
Clean up some example scripts and rerun some notebooks (#464)
Browse files Browse the repository at this point in the history
* Clean up example script

* Revert unintentional changes

* Update submodule

* Bump max jaxlib/jax version

* Remove device_put from new example scripts

* Update examples index

* Update submodule

---------

Co-authored-by: Brendt Wohlberg <[email protected]>
  • Loading branch information
bwohlberg and Brendt Wohlberg authored Nov 9, 2023
1 parent 08a5896 commit 092a917
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 21 deletions.
2 changes: 1 addition & 1 deletion data
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

0 comments on commit 092a917

Please sign in to comment.