Skip to content

Commit a63847a

Browse files
committed
updates to TomoPhantom plugin to use v3.0
1 parent f8f2e31 commit a63847a

File tree

2 files changed

+9
-27
lines changed

2 files changed

+9
-27
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ While building the CIL package we test with specific versions of dependencies. T
5454
| [ASTRA toolbox](http://www.astra-toolbox.com) | 2.1 | CPU: `conda-forge::astra-toolbox=2.1=py*` <br> GPU: `conda-forge::astra-toolbox=2.1=cuda*` | CT projectors, FBP and FDK. | [GPL-3.0](https://github.com/astra-toolbox/astra-toolbox/blob/master/COPYING) |
5555
| [TIGRE](https://github.com/CERN/TIGRE) | 2.6 | `ccpi::tigre=2.6` | CT projectors, FBP and FDK. | [BSD-3-Clause](https://github.com/CERN/TIGRE/blob/master/LICENSE.txt) |
5656
| [CCPi Regularisation Toolkit](https://github.com/TomographicImaging/CCPi-Regularisation-Toolkit) | 24.0.1 | `ccpi::ccpi-regulariser=24.0.1` | Toolbox of regularisation methods. | [Apache-2.0](https://github.com/TomographicImaging/CCPi-Regularisation-Toolkit/blob/master/LICENSE) |
57-
| [TomoPhantom](https://github.com/dkazanc/TomoPhantom) | [2.0.0](https://github.com/dkazanc/TomoPhantom/releases/tag/v2.0.0) | `ccpi::tomophantom=2.0.0` | Generates phantoms to use as test data. | [Apache-2.0](https://github.com/dkazanc/TomoPhantom/blob/master/LICENSE) |
57+
| [TomoPhantom](https://github.com/dkazanc/TomoPhantom) | >=0[3.0](https://github.com/dkazanc/TomoPhantom/releases/tag/v3.0) | `httomo::tomophantom` | Generates phantoms to use as test data. | [Apache-2.0](https://github.com/dkazanc/TomoPhantom/blob/master/LICENSE) |
5858
| [ipykernel](https://github.com/ipython/ipykernel) || `ipykernel` | Provides the IPython kernel to run Jupyter notebooks. | [BSD-3-Clause](https://github.com/ipython/ipykernel/blob/main/LICENSE) |
5959
| [ipywidgets](https://github.com/jupyter-widgets/ipywidgets) || `ipywidgets` | Enables visualisation tools within jupyter noteboooks. | [BSD-3-Clause](https://github.com/jupyter-widgets/ipywidgets/blob/main/LICENSE) |
6060
|[zenodo_get](https://github.com/dvolgyes/zenodo_get)|>= 1.6|`zenodo_get>=1.6`| Downloads datasets from Zenodo, is used by `dataexample` to get data used in CIL-Demos |[AGPL-3.0](https://github.com/dvolgyes/zenodo_get?tab=AGPL-3.0-1-ov-file)|

Wrappers/Python/cil/plugins/TomoPhantom.py

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,12 @@
2323
import os
2424
import numpy as np
2525

26-
import ctypes, platform
27-
from ctypes import util
28-
# check for the extension
29-
if platform.system() == 'Linux':
30-
dll = 'libctomophantom.so'
31-
elif platform.system() == 'Windows':
32-
dll_file = 'ctomophantom.dll'
33-
dll = util.find_library(dll_file)
34-
elif platform.system() == 'Darwin':
35-
dll = 'libctomophantom.dylib'
36-
else:
37-
raise ValueError('Not supported platform, ', platform.system())
38-
39-
libtomophantom = ctypes.cdll.LoadLibrary(dll)
40-
41-
26+
import ctypes
27+
import tomophantom.ctypes.external as external
4228

4329
path = os.path.dirname(tomophantom.__file__)
44-
path_library2D = os.path.join(path, "Phantom2DLibrary.dat")
45-
path_library3D = os.path.join(path, "Phantom3DLibrary.dat")
30+
path_library2D = os.path.join(path, "phantomlib", "Phantom2DLibrary.dat")
31+
path_library3D = os.path.join(path, "phantomlib", "Phantom3DLibrary.dat")
4632

4733
def is_model_temporal(num_model, num_dims=2):
4834
'''Returns whether a model in the TomoPhantom library is temporal
@@ -89,24 +75,20 @@ def check_model_params(num_model, num_dims=2):
8975
:type num_dims: int, default 2
9076
'''
9177
if num_dims == 2:
92-
libtomophantom.checkParams2D.argtypes = [ctypes.POINTER(ctypes.c_int), # pointer to the params array
78+
external.c_checkParams2D.argtypes = [ctypes.POINTER(ctypes.c_int), # pointer to the params array
9379
ctypes.c_int, # model number selector (int)
9480
ctypes.c_char_p] # string to the library file
9581
params = np.zeros([10], dtype=np.int32)
96-
params_p = params.ctypes.data_as(ctypes.POINTER(ctypes.c_int))
97-
lib2d_p = str(path_library2D).encode('utf-8')
98-
libtomophantom.checkParams2D(params_p, num_model, lib2d_p)
82+
external.c_checkParams2D(params, num_model, str(path_library2D))
9983

10084
return params
10185

10286
elif num_dims == 3:
103-
libtomophantom.checkParams3D.argtypes = [ctypes.POINTER(ctypes.c_int), # pointer to the params array
87+
external.c_checkParams3D.argtypes = [ctypes.POINTER(ctypes.c_int), # pointer to the params array
10488
ctypes.c_int, # model number selector (int)
10589
ctypes.c_char_p] # string to the library file
10690
params = np.zeros([11], dtype=np.int32)
107-
params_p = params.ctypes.data_as(ctypes.POINTER(ctypes.c_int))
108-
lib2d_p = str(path_library3D).encode('utf-8')
109-
libtomophantom.checkParams3D(params_p, num_model, lib2d_p)
91+
external.c_checkParams3D(params, num_model, str(path_library3D))
11092

11193
return params
11294

0 commit comments

Comments
 (0)