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

Update CCPi-Regularisation plugin for version 24.0.0 #1761

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
* x.x.x
- Update to new CCPi-Regularisation toolkit v24.0.0. This is a backward incompatible release of the toolkit.
- Set CMake Policy CMP0148 to OLD to avoid warnings in CMake 3.27
- AcquisitionGeometry prints the first and last 10 angles, or all if there are 30 or less, rather than the first 20
- Added a weight argument to the L1Norm function
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ where:

- `astra-toolbox` (requires an NVIDIA GPU) enables CIL support for [ASTRA toolbox](http://www.astra-toolbox.com) projectors (GPLv3 license)
- `tigre` (requires an NVIDIA GPU) enables support for [TIGRE](https://github.com/CERN/TIGRE) toolbox projectors (BSD license)
- `ccpi-regulariser` is the [CCPi Regularisation Toolkit](https://github.com/vais-ral/CCPi-Regularisation-Toolkit)
- `ccpi-regulariser` is the [CCPi Regularisation Toolkit](https://github.com/TomographicImaging/CCPi-Regularisation-Toolkit)
- `tomophantom` can generate phantoms to use as test data [Tomophantom](https://github.com/dkazanc/TomoPhantom)

### Dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@

try:
from ccpi.filters import regularisers
from ccpi.filters.cpu_regularisers import TV_ENERGY
from ccpi.filters.TV import TV_ENERGY
except ImportError as exc:
raise ImportError('Please `conda install "ccpi::ccpi-regulariser>=20.04"`') from exc
raise ImportError('Please `conda install "ccpi::ccpi-regulariser>=24"`') from exc


from cil.framework import DataOrder
Expand Down Expand Up @@ -229,14 +229,17 @@ def _fista_on_dual_rof(self, in_arr, tau):

"""

res , info = regularisers.FGP_TV(\
info = np.zeros((2,), dtype=np.float32)

res = regularisers.FGP_TV(\
in_arr,\
self.alpha * tau,\
self.max_iteration,\
self.tolerance,\
self.methodTV,\
self.nonnegativity,\
self.device)
infovector = info,
device = self.device)

return res, info

Expand Down Expand Up @@ -315,14 +318,18 @@ def alpha1(self):
return 1.

def proximal_numpy(self, in_arr, tau):
res , info = regularisers.TGV(in_arr,

info = np.zeros((2,), dtype=np.float32)

res = regularisers.TGV(in_arr,
self.alpha * tau,
self.alpha1,
self.alpha2,
self.max_iteration,
self.LipshitzConstant,
self.tolerance,
self.device)
infovector = info,
device = self.device)

# info: return number of iteration and reached tolerance
# https://github.com/vais-ral/CCPi-Regularisation-Toolkit/blob/master/src/Core/regularisers_CPU/TGV_core.c#L168
Expand Down Expand Up @@ -400,7 +407,10 @@ def __call__(self,x):
return np.nan

def proximal_numpy(self, in_arr, tau):
res , info = regularisers.FGP_dTV(\

info = np.zeros((2,), dtype=np.float32)

res = regularisers.FGP_dTV(\
in_arr,\
self.reference,\
self.alpha * tau,\
Expand All @@ -409,7 +419,8 @@ def proximal_numpy(self, in_arr, tau):
self.eta,\
self.methodTV,\
self.nonnegativity,\
self.device)
infovector = info,
device = self.device)
return res, info

def convex_conjugate(self, x):
Expand Down Expand Up @@ -454,7 +465,7 @@ def __call__(self,x):
def proximal_numpy(self, in_arr, tau):
# remove any dimension of size 1
in_arr = np.squeeze(in_arr)

res = regularisers.TNV(in_arr,
self.alpha * tau,
self.max_iteration,
Expand Down
6 changes: 3 additions & 3 deletions Wrappers/Python/test/test_PluginsRegularisation.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def test_functionality_FGP_TV(self):
fcil = FGP_TV()
outcil = fcil.proximal(data, tau=tau)
# use CIL defaults
outrgl, info = regularisers.FGP_TV(datarr, fcil.alpha*tau, fcil.max_iteration, fcil.tolerance, 0, 1, 'cpu' )
outrgl = regularisers.FGP_TV(datarr, fcil.alpha*tau, fcil.max_iteration, fcil.tolerance, 0, 1, device='cpu' )
np.testing.assert_almost_equal(outrgl, outcil.as_array())


Expand All @@ -118,7 +118,7 @@ def test_functionality_TGV(self):
fcil = TGV()
outcil = fcil.proximal(data, tau=tau)
# use CIL defaults
outrgl, info = regularisers.TGV(datarr, fcil.alpha*tau, 1,1, fcil.max_iteration, 12, fcil.tolerance, 'cpu' )
outrgl = regularisers.TGV(datarr, fcil.alpha*tau, 1,1, fcil.max_iteration, 12, fcil.tolerance, device='cpu' )

np.testing.assert_almost_equal(outrgl, outcil.as_array())

Expand All @@ -133,7 +133,7 @@ def test_functionality_FGP_dTV(self):
fcil = FGP_dTV(ref)
outcil = fcil.proximal(data, tau=tau)
# use CIL defaults
outrgl, info = regularisers.FGP_dTV(datarr, ref.as_array(), fcil.alpha*tau, fcil.max_iteration, fcil.tolerance, 0.01, 0, 1, 'cpu' )
outrgl = regularisers.FGP_dTV(datarr, ref.as_array(), fcil.alpha*tau, fcil.max_iteration, fcil.tolerance, 0.01, 0, 1, device='cpu' )
np.testing.assert_almost_equal(outrgl, outcil.as_array())


Expand Down
3 changes: 2 additions & 1 deletion Wrappers/Python/test/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,13 @@ def initialise_tests():
#ccpi-regularisation toolkit
module_info = importlib.util.find_spec("ccpi")
if module_info != None:
module_info = importlib.util.find_spec("ccpi.filters.cpu_regularisers")
module_info = importlib.util.find_spec("ccpi.filters.regularisers")

if module_info is None:
has_ccpi_regularisation = False
else:
has_ccpi_regularisation = True

system_state['has_ccpi_regularisation']= has_ccpi_regularisation


Expand Down
4 changes: 2 additions & 2 deletions recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ test:
- tomophantom=2.0.0 # [ linux ]
- tigre=2.4 # [ not osx ]
- packaging
- ccpi-regulariser=22.0.0 # [ not osx ]
- ccpi-regulariser=24.0.0 # [ not osx ]
- astra-toolbox>=1.9.9.dev5,<2.1

source_files:
Expand Down Expand Up @@ -93,7 +93,7 @@ requirements:
- tomophantom=2.0.0
- astra-toolbox>=1.9.9.dev5,<2.1
- tigre=2.4
- ccpi-regulariser=22.0.0
- ccpi-regulariser=24.0.0
- ipywidgets <8

about:
Expand Down
2 changes: 1 addition & 1 deletion scripts/create_local_env_for_cil_development.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ if test $test_deps = 0; then
else
conda_args+=(
astra-toolbox'>=1.9.9.dev5,<2.1'
ccpi-regulariser=22.0.0
ccpi-regulariser=24.0.0
cil-data
cvxpy
ipywidgets
Expand Down
2 changes: 1 addition & 1 deletion scripts/requirements-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ dependencies:
- numpy=1.24
- cil-data
- tigre=2.4
- ccpi-regulariser=22.0.0
- ccpi-regulariser=24.0.0
- tomophantom=2.0.0
- astra-toolbox >=1.9.9.dev5,<2.1
- cvxpy
Expand Down
Loading