mbirjax 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. mbirjax-0.2.0/LICENSE +29 -0
  2. mbirjax-0.2.0/MBIRJAX.egg-info/PKG-INFO +112 -0
  3. mbirjax-0.2.0/MBIRJAX.egg-info/SOURCES.txt +39 -0
  4. mbirjax-0.2.0/MBIRJAX.egg-info/dependency_links.txt +1 -0
  5. mbirjax-0.2.0/MBIRJAX.egg-info/requires.txt +17 -0
  6. mbirjax-0.2.0/MBIRJAX.egg-info/top_level.txt +7 -0
  7. mbirjax-0.2.0/PKG-INFO +112 -0
  8. mbirjax-0.2.0/README.rst +51 -0
  9. mbirjax-0.2.0/demo/demo_cone_beam_shepp_logan.py +63 -0
  10. mbirjax-0.2.0/demo/demo_parbeam_shepp_logan.py +59 -0
  11. mbirjax-0.2.0/demo/demo_slice_viewer.py +41 -0
  12. mbirjax-0.2.0/docs/build/html/_static/new_model_template.py +186 -0
  13. mbirjax-0.2.0/docs/source/_static/new_model_template.py +186 -0
  14. mbirjax-0.2.0/docs/source/conf.py +136 -0
  15. mbirjax-0.2.0/experiments/cone_beam_dev.py +201 -0
  16. mbirjax-0.2.0/experiments/cvpr-2024/vcd_figs_for_abst.py +110 -0
  17. mbirjax-0.2.0/experiments/gpu_performance/cumulative_memory.py +263 -0
  18. mbirjax-0.2.0/experiments/gpu_performance/display_results.py +163 -0
  19. mbirjax-0.2.0/experiments/gpu_performance/evaluate_over_indices.py +120 -0
  20. mbirjax-0.2.0/experiments/gpu_performance/initialize_evaluation.py +36 -0
  21. mbirjax-0.2.0/experiments/parallel_model_dev.py +181 -0
  22. mbirjax-0.2.0/experiments/prox_test.py +57 -0
  23. mbirjax-0.2.0/experiments/recon_experiments.py +138 -0
  24. mbirjax-0.2.0/mbirjax/__init__.py +9 -0
  25. mbirjax-0.2.0/mbirjax/_utils.py +57 -0
  26. mbirjax-0.2.0/mbirjax/cone_beam.py +638 -0
  27. mbirjax-0.2.0/mbirjax/memory_stats.py +55 -0
  28. mbirjax-0.2.0/mbirjax/parallel_beam.py +307 -0
  29. mbirjax-0.2.0/mbirjax/parameter_handler.py +271 -0
  30. mbirjax-0.2.0/mbirjax/plot_utils.py +294 -0
  31. mbirjax-0.2.0/mbirjax/projectors.py +336 -0
  32. mbirjax-0.2.0/mbirjax/tomography_model.py +978 -0
  33. mbirjax-0.2.0/mbirjax/vcd_utils.py +320 -0
  34. mbirjax-0.2.0/pyproject.toml +47 -0
  35. mbirjax-0.2.0/setup.cfg +4 -0
  36. mbirjax-0.2.0/tests/test_projectors.py +242 -0
mbirjax-0.2.0/LICENSE ADDED
@@ -0,0 +1,29 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2024, Charles A. Bouman and Gregery T. Buzzard
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ 1. Redistributions of source code must retain the above copyright notice, this
10
+ list of conditions and the following disclaimer.
11
+
12
+ 2. Redistributions in binary form must reproduce the above copyright notice,
13
+ this list of conditions and the following disclaimer in the documentation
14
+ and/or other materials provided with the distribution.
15
+
16
+ 3. Neither the name of the copyright holder nor the names of its
17
+ contributors may be used to endorse or promote products derived from
18
+ this software without specific prior written permission.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,112 @@
1
+ Metadata-Version: 2.1
2
+ Name: mbirjax
3
+ Version: 0.2.0
4
+ Summary: High-performance tomographic reconstruction
5
+ Author-email: MBIRJAX development team <buzzard@purdue.edu>
6
+ License: BSD 3-Clause License
7
+
8
+ Copyright (c) 2024, Charles A. Bouman and Gregery T. Buzzard
9
+ All rights reserved.
10
+
11
+ Redistribution and use in source and binary forms, with or without
12
+ modification, are permitted provided that the following conditions are met:
13
+
14
+ 1. Redistributions of source code must retain the above copyright notice, this
15
+ list of conditions and the following disclaimer.
16
+
17
+ 2. Redistributions in binary form must reproduce the above copyright notice,
18
+ this list of conditions and the following disclaimer in the documentation
19
+ and/or other materials provided with the distribution.
20
+
21
+ 3. Neither the name of the copyright holder nor the names of its
22
+ contributors may be used to endorse or promote products derived from
23
+ this software without specific prior written permission.
24
+
25
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
29
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35
+
36
+ Project-URL: homepage, https://mbirjax.readthedocs.io
37
+ Project-URL: source, https://github.com/cabouman/mbirjax
38
+ Keywords: tomography,tomographic reconstruction,computed tomography
39
+ Classifier: Programming Language :: Python :: 3
40
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
41
+ Classifier: License :: OSI Approved :: BSD License
42
+ Classifier: Operating System :: OS Independent
43
+ Requires-Python: >=3.9
44
+ Description-Content-Type: text/x-rst
45
+ License-File: LICENSE
46
+ Requires-Dist: matplotlib
47
+ Requires-Dist: numpy
48
+ Requires-Dist: setuptools
49
+ Requires-Dist: jax
50
+ Requires-Dist: jaxlib
51
+ Requires-Dist: ruamel.yaml
52
+ Requires-Dist: psutil
53
+ Provides-Extra: test
54
+ Requires-Dist: pytest; extra == "test"
55
+ Provides-Extra: docs
56
+ Requires-Dist: sphinx; extra == "docs"
57
+ Requires-Dist: sphinxcontrib-bibtex; extra == "docs"
58
+ Requires-Dist: sphinx-book-theme>=1.0.1; extra == "docs"
59
+ Requires-Dist: sphinx-design; extra == "docs"
60
+ Requires-Dist: sphinx-copybutton; extra == "docs"
61
+
62
+ .. docs-include-ref
63
+
64
+ MBIRJAX
65
+ =======
66
+
67
+ Model-Based Iterative Reconstruction (MBIR) for tomographic reconstruction that is based on the `JAX <https://github.com/google/jax>`__ library.
68
+ Full documentation is available at https://mbirjax.readthedocs.io .
69
+
70
+ Installing from PyPI
71
+ --------------------
72
+
73
+ .. code-block::
74
+
75
+ pip install mbirjax
76
+
77
+ Installing from Source
78
+ ----------------------
79
+
80
+ 1. *Clone the repository:*
81
+
82
+ .. code-block::
83
+
84
+ git clone git@github.com:cabouman/mbirjax.git
85
+
86
+ 2. Install the conda environment and package
87
+
88
+ a. Option 1: Clean install using dev_scripts - We provide bash scripts that will do a clean install of MBIRJAX in a new conda environment using the commands:
89
+
90
+ .. code-block::
91
+
92
+ cd dev_scripts
93
+ source clean_install_all.sh
94
+
95
+ b. Option 2: Manual install - You can also manually install MBIRJAX from the main directory of the repository with the following commands:
96
+
97
+ .. code-block::
98
+
99
+ conda create --name mbirjax python=3.10
100
+ conda activate mbirjax
101
+ pip install -r requirements.txt
102
+ pip install .
103
+
104
+ Running Demo(s)
105
+ ---------------
106
+
107
+ Run any of the available demo scripts with something like the following:
108
+
109
+ .. code-block::
110
+
111
+ python demo/<demo_file>.py
112
+
@@ -0,0 +1,39 @@
1
+ LICENSE
2
+ README.rst
3
+ pyproject.toml
4
+ MBIRJAX.egg-info/PKG-INFO
5
+ MBIRJAX.egg-info/SOURCES.txt
6
+ MBIRJAX.egg-info/dependency_links.txt
7
+ MBIRJAX.egg-info/requires.txt
8
+ MBIRJAX.egg-info/top_level.txt
9
+ demo/demo_cone_beam_shepp_logan.py
10
+ demo/demo_parbeam_shepp_logan.py
11
+ demo/demo_slice_viewer.py
12
+ docs/build/html/_static/new_model_template.py
13
+ docs/source/conf.py
14
+ docs/source/_static/new_model_template.py
15
+ experiments/cone_beam_dev.py
16
+ experiments/parallel_model_dev.py
17
+ experiments/prox_test.py
18
+ experiments/recon_experiments.py
19
+ experiments/cvpr-2024/vcd_figs_for_abst.py
20
+ experiments/gpu_performance/cumulative_memory.py
21
+ experiments/gpu_performance/display_results.py
22
+ experiments/gpu_performance/evaluate_over_indices.py
23
+ experiments/gpu_performance/initialize_evaluation.py
24
+ mbirjax/__init__.py
25
+ mbirjax/_utils.py
26
+ mbirjax/cone_beam.py
27
+ mbirjax/memory_stats.py
28
+ mbirjax/parallel_beam.py
29
+ mbirjax/parameter_handler.py
30
+ mbirjax/plot_utils.py
31
+ mbirjax/projectors.py
32
+ mbirjax/tomography_model.py
33
+ mbirjax/vcd_utils.py
34
+ mbirjax.egg-info/PKG-INFO
35
+ mbirjax.egg-info/SOURCES.txt
36
+ mbirjax.egg-info/dependency_links.txt
37
+ mbirjax.egg-info/requires.txt
38
+ mbirjax.egg-info/top_level.txt
39
+ tests/test_projectors.py
@@ -0,0 +1,17 @@
1
+ matplotlib
2
+ numpy
3
+ setuptools
4
+ jax
5
+ jaxlib
6
+ ruamel.yaml
7
+ psutil
8
+
9
+ [docs]
10
+ sphinx
11
+ sphinxcontrib-bibtex
12
+ sphinx-book-theme>=1.0.1
13
+ sphinx-design
14
+ sphinx-copybutton
15
+
16
+ [test]
17
+ pytest
@@ -0,0 +1,7 @@
1
+ demo
2
+ dev_scripts
3
+ dist
4
+ docs
5
+ experiments
6
+ mbirjax
7
+ tests
mbirjax-0.2.0/PKG-INFO ADDED
@@ -0,0 +1,112 @@
1
+ Metadata-Version: 2.1
2
+ Name: mbirjax
3
+ Version: 0.2.0
4
+ Summary: High-performance tomographic reconstruction
5
+ Author-email: MBIRJAX development team <buzzard@purdue.edu>
6
+ License: BSD 3-Clause License
7
+
8
+ Copyright (c) 2024, Charles A. Bouman and Gregery T. Buzzard
9
+ All rights reserved.
10
+
11
+ Redistribution and use in source and binary forms, with or without
12
+ modification, are permitted provided that the following conditions are met:
13
+
14
+ 1. Redistributions of source code must retain the above copyright notice, this
15
+ list of conditions and the following disclaimer.
16
+
17
+ 2. Redistributions in binary form must reproduce the above copyright notice,
18
+ this list of conditions and the following disclaimer in the documentation
19
+ and/or other materials provided with the distribution.
20
+
21
+ 3. Neither the name of the copyright holder nor the names of its
22
+ contributors may be used to endorse or promote products derived from
23
+ this software without specific prior written permission.
24
+
25
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
29
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35
+
36
+ Project-URL: homepage, https://mbirjax.readthedocs.io
37
+ Project-URL: source, https://github.com/cabouman/mbirjax
38
+ Keywords: tomography,tomographic reconstruction,computed tomography
39
+ Classifier: Programming Language :: Python :: 3
40
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
41
+ Classifier: License :: OSI Approved :: BSD License
42
+ Classifier: Operating System :: OS Independent
43
+ Requires-Python: >=3.9
44
+ Description-Content-Type: text/x-rst
45
+ License-File: LICENSE
46
+ Requires-Dist: matplotlib
47
+ Requires-Dist: numpy
48
+ Requires-Dist: setuptools
49
+ Requires-Dist: jax
50
+ Requires-Dist: jaxlib
51
+ Requires-Dist: ruamel.yaml
52
+ Requires-Dist: psutil
53
+ Provides-Extra: test
54
+ Requires-Dist: pytest; extra == "test"
55
+ Provides-Extra: docs
56
+ Requires-Dist: sphinx; extra == "docs"
57
+ Requires-Dist: sphinxcontrib-bibtex; extra == "docs"
58
+ Requires-Dist: sphinx-book-theme>=1.0.1; extra == "docs"
59
+ Requires-Dist: sphinx-design; extra == "docs"
60
+ Requires-Dist: sphinx-copybutton; extra == "docs"
61
+
62
+ .. docs-include-ref
63
+
64
+ MBIRJAX
65
+ =======
66
+
67
+ Model-Based Iterative Reconstruction (MBIR) for tomographic reconstruction that is based on the `JAX <https://github.com/google/jax>`__ library.
68
+ Full documentation is available at https://mbirjax.readthedocs.io .
69
+
70
+ Installing from PyPI
71
+ --------------------
72
+
73
+ .. code-block::
74
+
75
+ pip install mbirjax
76
+
77
+ Installing from Source
78
+ ----------------------
79
+
80
+ 1. *Clone the repository:*
81
+
82
+ .. code-block::
83
+
84
+ git clone git@github.com:cabouman/mbirjax.git
85
+
86
+ 2. Install the conda environment and package
87
+
88
+ a. Option 1: Clean install using dev_scripts - We provide bash scripts that will do a clean install of MBIRJAX in a new conda environment using the commands:
89
+
90
+ .. code-block::
91
+
92
+ cd dev_scripts
93
+ source clean_install_all.sh
94
+
95
+ b. Option 2: Manual install - You can also manually install MBIRJAX from the main directory of the repository with the following commands:
96
+
97
+ .. code-block::
98
+
99
+ conda create --name mbirjax python=3.10
100
+ conda activate mbirjax
101
+ pip install -r requirements.txt
102
+ pip install .
103
+
104
+ Running Demo(s)
105
+ ---------------
106
+
107
+ Run any of the available demo scripts with something like the following:
108
+
109
+ .. code-block::
110
+
111
+ python demo/<demo_file>.py
112
+
@@ -0,0 +1,51 @@
1
+ .. docs-include-ref
2
+
3
+ MBIRJAX
4
+ =======
5
+
6
+ Model-Based Iterative Reconstruction (MBIR) for tomographic reconstruction that is based on the `JAX <https://github.com/google/jax>`__ library.
7
+ Full documentation is available at https://mbirjax.readthedocs.io .
8
+
9
+ Installing from PyPI
10
+ --------------------
11
+
12
+ .. code-block::
13
+
14
+ pip install mbirjax
15
+
16
+ Installing from Source
17
+ ----------------------
18
+
19
+ 1. *Clone the repository:*
20
+
21
+ .. code-block::
22
+
23
+ git clone git@github.com:cabouman/mbirjax.git
24
+
25
+ 2. Install the conda environment and package
26
+
27
+ a. Option 1: Clean install using dev_scripts - We provide bash scripts that will do a clean install of MBIRJAX in a new conda environment using the commands:
28
+
29
+ .. code-block::
30
+
31
+ cd dev_scripts
32
+ source clean_install_all.sh
33
+
34
+ b. Option 2: Manual install - You can also manually install MBIRJAX from the main directory of the repository with the following commands:
35
+
36
+ .. code-block::
37
+
38
+ conda create --name mbirjax python=3.10
39
+ conda activate mbirjax
40
+ pip install -r requirements.txt
41
+ pip install .
42
+
43
+ Running Demo(s)
44
+ ---------------
45
+
46
+ Run any of the available demo scripts with something like the following:
47
+
48
+ .. code-block::
49
+
50
+ python demo/<demo_file>.py
51
+
@@ -0,0 +1,63 @@
1
+ import numpy as np
2
+ import time
3
+ import jax.numpy as jnp
4
+ import matplotlib.pyplot as plt
5
+ import mbirjax.plot_utils as pu
6
+ import mbirjax.parallel_beam
7
+
8
+ if __name__ == "__main__":
9
+ """
10
+ This is a script to develop, debug, and tune the vcd reconstruction with a parallel beam projector
11
+ """
12
+ # Set parameters
13
+ num_views = 256
14
+ num_det_rows = 20
15
+ num_det_channels = 256
16
+ source_detector_dist = 4 * num_det_channels
17
+ source_iso_dist = source_detector_dist
18
+
19
+ start_angle = -np.pi*(1/2)
20
+ end_angle = np.pi*(1/2)
21
+ sharpness = 0.0
22
+
23
+ # Initialize sinogram
24
+ sinogram = jnp.zeros((num_views, num_det_rows, num_det_channels))
25
+ angles = jnp.linspace(start_angle, end_angle, num_views, endpoint=False)
26
+
27
+ # Set up parallel beam model
28
+ cone_model = mbirjax.ConeBeamModel(sinogram.shape, angles, source_detector_dist=source_detector_dist, source_iso_dist=source_iso_dist)
29
+
30
+ # Generate 3D Shepp Logan phantom
31
+ print('Creating phantom')
32
+ phantom = cone_model.gen_modified_3d_sl_phantom()
33
+
34
+ # Generate synthetic sinogram data
35
+ print('Creating sinogram')
36
+ sinogram = cone_model.forward_project(phantom)
37
+
38
+ # View sinogram
39
+ pu.slice_viewer(sinogram.transpose((1, 2, 0)), title='Original sinogram')
40
+
41
+ # Generate weights array
42
+ weights = cone_model.gen_weights(sinogram / sinogram.max(), weight_type='transmission_root')
43
+
44
+ # Set reconstruction parameter values
45
+ cone_model.set_params(sharpness=sharpness, verbose=1)
46
+
47
+ # Print out model parameters
48
+ cone_model.print_params()
49
+
50
+ # ##########################
51
+ # Perform VCD reconstruction
52
+ print('Starting recon')
53
+ time0 = time.time()
54
+ recon, recon_params = cone_model.recon(sinogram, weights=weights)
55
+
56
+ recon.block_until_ready()
57
+ elapsed = time.time() - time0
58
+ print('Elapsed time for recon is {:.3f} seconds'.format(elapsed))
59
+ # ##########################
60
+
61
+ # Display results
62
+ pu.slice_viewer(phantom, recon, title='Phantom (left) vs VCD Recon (right)')
63
+
@@ -0,0 +1,59 @@
1
+ import numpy as np
2
+ import time
3
+ import jax.numpy as jnp
4
+ import matplotlib.pyplot as plt
5
+ import mbirjax.plot_utils as pu
6
+ import mbirjax.parallel_beam
7
+
8
+ if __name__ == "__main__":
9
+ """
10
+ This is a script to develop, debug, and tune the parallel beam mbirjax code.
11
+ """
12
+ # Set parameters
13
+ num_views = 256
14
+ num_det_rows = 20
15
+ num_det_channels = 256
16
+ start_angle = -np.pi*(1/2)
17
+ end_angle = np.pi*(1/2)
18
+ sharpness = 0.0
19
+
20
+ # Initialize sinogram
21
+ sinogram = jnp.zeros((num_views, num_det_rows, num_det_channels))
22
+ angles = jnp.linspace(start_angle, end_angle, num_views, endpoint=False)
23
+
24
+ # Set up parallel beam model
25
+ parallel_model = mbirjax.ParallelBeamModel(sinogram.shape, angles)
26
+
27
+ # Generate 3D Shepp Logan phantom
28
+ print('Creating phantom')
29
+ phantom = parallel_model.gen_modified_3d_sl_phantom()
30
+
31
+ # Generate synthetic sinogram data
32
+ print('Creating sinogram')
33
+ sinogram = parallel_model.forward_project(phantom)
34
+
35
+ # View sinogram
36
+ pu.slice_viewer(sinogram.transpose((1, 2, 0)), title='Original sinogram')
37
+
38
+ # Generate weights array
39
+ weights = parallel_model.gen_weights(sinogram / sinogram.max(), weight_type='transmission_root')
40
+
41
+ # Set reconstruction parameter values
42
+ parallel_model.set_params(sharpness=sharpness, verbose=1)
43
+
44
+ # Print out model parameters
45
+ parallel_model.print_params()
46
+
47
+ # ##########################
48
+ # Perform VCD reconstruction
49
+ time0 = time.time()
50
+ recon, recon_params = parallel_model.recon(sinogram, weights=weights)
51
+
52
+ recon.block_until_ready()
53
+ elapsed = time.time() - time0
54
+ print('Elapsed time for recon is {:.3f} seconds'.format(elapsed))
55
+ # ##########################
56
+
57
+ # Display results
58
+ pu.slice_viewer(phantom, recon, title='Phantom (left) vs VCD Recon (right)')
59
+
@@ -0,0 +1,41 @@
1
+ import numpy as np
2
+ import jax.numpy as jnp
3
+ import mbirjax.plot_utils as pu
4
+ import mbirjax.parallel_beam
5
+
6
+ if __name__ == "__main__":
7
+ """
8
+ This is a script to demonstrate the built-in slice viewer
9
+ """
10
+ # Set parameters
11
+ num_views = 128
12
+ num_det_rows = 128
13
+ num_det_channels = 128
14
+ source_detector_dist = 4 * num_det_channels
15
+ source_iso_dist = source_detector_dist
16
+
17
+ detector_cone_angle = 2 * np.arctan2(num_det_channels / 2, source_detector_dist)
18
+ start_angle = -(np.pi + detector_cone_angle) * (1/2)
19
+ end_angle = (np.pi + detector_cone_angle) * (1/2)
20
+ sharpness = 0.0
21
+
22
+ # Initialize sinogram
23
+ sinogram = jnp.zeros((num_views, num_det_rows, num_det_channels))
24
+ angles = jnp.linspace(start_angle, end_angle, num_views, endpoint=False)
25
+
26
+ # Set up parallel beam model
27
+ cone_model = mbirjax.ConeBeamModel(sinogram.shape, angles, source_detector_dist=source_detector_dist, source_iso_dist=source_iso_dist)
28
+
29
+ # Generate 3D Shepp Logan phantom
30
+ print('Creating phantom')
31
+ phantom = cone_model.gen_modified_3d_sl_phantom()
32
+
33
+ # View the phantom
34
+ pu.slice_viewer(phantom, phantom.transpose((1, 2, 0)), title='Phantom axial and coronal', slice_label='View')
35
+
36
+ # Generate synthetic sinogram data
37
+ print('Creating sinogram')
38
+ sinogram = cone_model.forward_project(phantom)
39
+
40
+ # View sinogram
41
+ pu.slice_viewer(sinogram, title='Sinogram', slice_axis=0)