Skip to content

Commit

Permalink
Merge branch 'rgl24' into bump-versions
Browse files Browse the repository at this point in the history
  • Loading branch information
casperdcl committed Apr 16, 2024
2 parents da6c452 + 3dc669a commit 2e6bf76
Show file tree
Hide file tree
Showing 19 changed files with 121 additions and 117 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ jobs:
runs-on: [self-hosted, python, cuda]
strategy:
matrix:
python-version: [3.9]
numpy-version: [1.22]
python-version: [3.11]
numpy-version: [1.25]
steps:
- uses: actions/checkout@v4
with: {fetch-depth: 0, submodules: recursive}
Expand Down Expand Up @@ -80,10 +80,10 @@ jobs:
strategy:
matrix:
include:
- python-version: 3.8
numpy-version: 1.21
- python-version: '3.10'
numpy-version: 1.24
numpy-version: 1.23
- python-version: 3.12
numpy-version: 1.26
steps:
- uses: actions/checkout@v4
with: {fetch-depth: 0, submodules: recursive}
Expand All @@ -105,8 +105,8 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.9]
numpy-version: [1.22]
python-version: [3.11]
numpy-version: [1.25]
steps:
- uses: actions/checkout@v4
with: {fetch-depth: 0, submodules: recursive}
Expand All @@ -132,7 +132,7 @@ jobs:
- uses: actions/checkout@v4
with: {fetch-depth: 0, submodules: recursive}
- uses: conda-incubator/setup-miniconda@v3
with: {python-version: '3.10'}
with: {python-version: 3.11}
- name: install dependencies
run: |
cd docs
Expand Down
4 changes: 1 addition & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +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 Expand Up @@ -52,7 +51,6 @@
- Added the ApproximateGradientSumFunction and SGFunction to allow for stochastic gradient algorithms to be created using functions with an approximate gradient and deterministic algorithms
- CIL plugin support for TIGRE version v2.6


* 23.1.0
- Fix bug in IndicatorBox proximal_conjugate
- Allow CCPi Regulariser functions for non CIL object
Expand Down
2 changes: 1 addition & 1 deletion NOTICE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Kyle Pidgeon (2023) - 1
Letizia Protopapa (2023) - 1
Tommi Heikkilä (2023) - 11
Ashley Gillman (2024) -12
Zeljko Kerata (2024) - 5
Zeljko Kereta (2024) - 5
Evgueni Ovtchinnikov (2024) -1
Georg Schramm (2024) - 13

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=2.1` enables CIL support for [ASTRA toolbox](http://www.astra-toolbox.com) CPU projector (2D Parallel beam only) (GPLv3 license)
- `astra-toolbox=2.1=cuda*` (requires an NVIDIA GPU) enables CIL support for [ASTRA toolbox](http://www.astra-toolbox.com) GPU 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,7 +18,7 @@
# - Daniel Deidda (National Physical Laboratory, UK)
# - Claire Delplancke (Electricite de France, Research and Development)
# - Ashley Gillman (Australian e-Health Res. Ctr., CSIRO, Brisbane, Queensland, Australia)
# - Zeljko Kerata (Department of Computer Science, University College London, UK)
# - Zeljko Kereta (Department of Computer Science, University College London, UK)
# - Evgueni Ovtchinnikov (STFC - UKRI)
# - Georg Schramm (Department of Imaging and Pathology, Division of Nuclear Medicine, KU Leuven, Leuven, Belgium)

Expand Down
2 changes: 1 addition & 1 deletion Wrappers/Python/cil/optimisation/functions/SGFunction.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# - Daniel Deidda (National Physical Laboratory, UK)
# - Claire Delplancke (Electricite de France, Research and Development)
# - Ashley Gillman (Australian e-Health Res. Ctr., CSIRO, Brisbane, Queensland, Australia)
# - Zeljko Kerata (Department of Computer Science, University College London, UK)
# - Zeljko Kereta (Department of Computer Science, University College London, UK)
# - Evgueni Ovtchinnikov (STFC - UKRI)
# - Georg Schramm (Department of Imaging and Pathology, Division of Nuclear Medicine, KU Leuven, Leuven, Belgium)

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
44 changes: 22 additions & 22 deletions Wrappers/Python/test/test_DataProcessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,21 +572,21 @@ def test_process_acquisition(self):

proc.set_input(data_in.geometry)
geometry_out = proc.process()
self.assertEquals(geometry_out, geometry_gold,
self.assertEqual(geometry_out, geometry_gold,
msg="Binner failed with geometry mismatch. Got:\n{0}\nExpected:\n{1}".format(geometry_out, geometry_gold))

proc.set_input(data_in)
data_out = proc.process()

numpy.testing.assert_array_equal(data_gold, data_out.array)
self.assertEquals(data_out.geometry, geometry_gold,
self.assertEqual(data_out.geometry, geometry_gold,
msg="Binner failed with geometry mismatch. Got:\n{0}\nExpected:\n{1}".format(data_out.geometry, geometry_gold))

data_out.fill(0)
proc.process(out=data_out)

numpy.testing.assert_array_equal(data_gold, data_out.array)
self.assertEquals(data_out.geometry, geometry_gold,
self.assertEqual(data_out.geometry, geometry_gold,
msg="Binner failed with geometry mismatch. Got:\n{0}\nExpected:\n{1}".format(data_out.geometry, geometry_gold))


Expand All @@ -606,21 +606,21 @@ def test_process_image(self):

proc.set_input(data_in.geometry)
geometry_out = proc.process()
self.assertEquals(geometry_out, geometry_gold,
self.assertEqual(geometry_out, geometry_gold,
msg="Binner failed with geometry mismatch. Got:\n{0}\nExpected:\n{1}".format(geometry_out, geometry_gold))

proc.set_input(data_in)
data_out = proc.process()

numpy.testing.assert_array_equal(data_gold, data_out.array)
self.assertEquals(data_out.geometry, geometry_gold,
self.assertEqual(data_out.geometry, geometry_gold,
msg="Binner failed with geometry mismatch. Got:\n{0}\nExpected:\n{1}".format(data_out.geometry, geometry_gold))

data_out.fill(0)
proc.process(out=data_out)

numpy.testing.assert_array_equal(data_gold, data_out.array)
self.assertEquals(data_out.geometry, geometry_gold,
self.assertEqual(data_out.geometry, geometry_gold,
msg="Binner failed with geometry mismatch. Got:\n{0}\nExpected:\n{1}".format(data_out.geometry, geometry_gold))


Expand Down Expand Up @@ -1343,21 +1343,21 @@ def test_process_acquisition(self):

proc.set_input(data_in.geometry)
geometry_out = proc.process()
self.assertEquals(geometry_out, geometry_gold,
self.assertEqual(geometry_out, geometry_gold,
msg="Slicer failed with geometry mismatch. Got:\n{0}\nExpected:\n{1}".format(geometry_out, geometry_gold))

proc.set_input(data_in)
data_out = proc.process()

numpy.testing.assert_array_equal(data_gold, data_out.array)
self.assertEquals(data_out.geometry, geometry_gold,
self.assertEqual(data_out.geometry, geometry_gold,
msg="Slicer failed with geometry mismatch. Got:\n{0}\nExpected:\n{1}".format(data_out.geometry, geometry_gold))

data_out.fill(0)
proc.process(out=data_out)

numpy.testing.assert_array_equal(data_gold, data_out.array)
self.assertEquals(data_out.geometry, geometry_gold,
self.assertEqual(data_out.geometry, geometry_gold,
msg="Slicer failed with geometry mismatch. Got:\n{0}\nExpected:\n{1}".format(data_out.geometry, geometry_gold))


Expand All @@ -1375,21 +1375,21 @@ def test_process_image(self):

proc.set_input(data_in.geometry)
geometry_out = proc.process()
self.assertEquals(geometry_out, geometry_gold,
self.assertEqual(geometry_out, geometry_gold,
msg="Slicer failed with geometry mismatch. Got:\n{0}\nExpected:\n{1}".format(geometry_out, geometry_gold))

proc.set_input(data_in)
data_out = proc.process()

numpy.testing.assert_array_equal(data_gold, data_out.array)
self.assertEquals(data_out.geometry, geometry_gold,
self.assertEqual(data_out.geometry, geometry_gold,
msg="Slicer failed with geometry mismatch. Got:\n{0}\nExpected:\n{1}".format(data_out.geometry, geometry_gold))

data_out.fill(0)
proc.process(out=data_out)

numpy.testing.assert_array_equal(data_gold, data_out.array)
self.assertEquals(data_out.geometry, geometry_gold,
self.assertEqual(data_out.geometry, geometry_gold,
msg="Slicer failed with geometry mismatch. Got:\n{0}\nExpected:\n{1}".format(data_out.geometry, geometry_gold))


Expand Down Expand Up @@ -1770,7 +1770,7 @@ def test_process_acquisition_geometry(self):
proc.set_input(geometry)
geometry_padded = proc._process_acquisition_geometry()

self.assertEquals(geometry_padded, self.ag_padded,
self.assertEqual(geometry_padded, self.ag_padded,
msg="Padder failed with geometry mismatch. Got:\n{0}\nExpected:\n{1}".format(geometry_padded, self.ag_padded))


Expand All @@ -1784,7 +1784,7 @@ def test_process_acquisition_geometry(self):
0., 90., 180., 270.,\
360., 450., 540., 630., 720.]

self.assertEquals(geometry_padded, geometry_gold,
self.assertEqual(geometry_padded, geometry_gold,
msg="Padder failed with geometry mismatch. Got:\n{0}\nExpected:\n{1}".format(geometry_padded, geometry_gold))


Expand All @@ -1795,7 +1795,7 @@ def test_process_acquisition_geometry_origin(self):
proc.set_input(geometry)
geometry_padded = proc._process_acquisition_geometry()

self.assertEquals(geometry_padded, self.ag2_padded,
self.assertEqual(geometry_padded, self.ag2_padded,
msg="Padder failed with geometry mismatch. Got:\n{0}\nExpected:\n{1}".format(geometry_padded, self.ag2_padded))


Expand All @@ -1807,7 +1807,7 @@ def test_process_image_geometry(self):
proc.set_input(geometry)
geometry_padded = proc._process_image_geometry()

self.assertEquals(geometry_padded, self.ig_padded,
self.assertEqual(geometry_padded, self.ig_padded,
msg="Padder failed with geometry mismatch. Got:\n{0}\nExpected:\n{1}".format(geometry_padded, self.ig_padded))


Expand Down Expand Up @@ -1846,21 +1846,21 @@ def test_process_acquisition(self):

proc.set_input(data_in.geometry)
geometry_out = proc.process()
self.assertEquals(geometry_out, self.ag_padded,
self.assertEqual(geometry_out, self.ag_padded,
msg="Padder failed with geometry mismatch. Got:\n{0}\nExpected:\n{1}".format(geometry_out, self.ag_padded))

proc.set_input(data_in)
data_out = proc.process()

numpy.testing.assert_array_equal(data_gold.array, data_out.array)
self.assertEquals(data_out.geometry, self.ag_padded,
self.assertEqual(data_out.geometry, self.ag_padded,
msg="Padder failed with geometry mismatch. Got:\n{0}\nExpected:\n{1}".format(data_out.geometry, self.ag_padded))

data_out.fill(0)
proc.process(out=data_out)

numpy.testing.assert_array_equal(data_gold.array, data_out.array)
self.assertEquals(data_out.geometry, self.ag_padded,
self.assertEqual(data_out.geometry, self.ag_padded,
msg="Padder failed with geometry mismatch. Got:\n{0}\nExpected:\n{1}".format(data_out.geometry, self.ag_padded))


Expand All @@ -1880,21 +1880,21 @@ def test_process_image(self):

proc.set_input(data_in.geometry)
geometry_out = proc.process()
self.assertEquals(geometry_out, self.ig_padded,
self.assertEqual(geometry_out, self.ig_padded,
msg="Padder failed with geometry mismatch. Got:\n{0}\nExpected:\n{1}".format(geometry_out, self.ig_padded))

proc.set_input(data_in)
data_out = proc.process()

numpy.testing.assert_array_equal(data_gold.array, data_out.array)
self.assertEquals(data_out.geometry, self.ig_padded,
self.assertEqual(data_out.geometry, self.ig_padded,
msg="Padder failed with geometry mismatch. Got:\n{0}\nExpected:\n{1}".format(data_out.geometry, self.ig_padded))

data_out.fill(0)
proc.process(out=data_out)

numpy.testing.assert_array_equal(data_gold.array, data_out.array)
self.assertEquals(data_out.geometry, self.ig_padded,
self.assertEqual(data_out.geometry, self.ig_padded,
msg="Padder failed with geometry mismatch. Got:\n{0}\nExpected:\n{1}".format(data_out.geometry, self.ig_padded))


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
Loading

0 comments on commit 2e6bf76

Please sign in to comment.