Skip to content

Commit

Permalink
octo-merge
Browse files Browse the repository at this point in the history
- closes #1713 bump astra
- closes #1764 bump tigre
- closes #1761 bump ccpi-regulariser
- closes #1765 bumpy python & numpy
  • Loading branch information
casperdcl committed Apr 16, 2024
1 parent 7618e99 commit 9014c4f
Show file tree
Hide file tree
Showing 17 changed files with 130 additions and 119 deletions.
20 changes: 10 additions & 10 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,15 +80,15 @@ 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}
- name: set requirements
run: sed -ri -e '/ python=/d' -e 's/(.* numpy=).*/\1${{ matrix.numpy-version }}/' scripts/requirements-test.yml
run: sed -ri -e '/ python=/d' -e 's/(.* numpy=).*/\1${{ matrix.numpy-version }}/' -e '/tigre/d' scripts/requirements-test.yml
- uses: conda-incubator/setup-miniconda@v3
with:
python-version: ${{ matrix.python-version }}
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,12 +132,12 @@ 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
conda install -c conda-forge -yq conda-merge
conda-merge ../scripts/requirements-test.yml docs_environment.yml > environment.yml
conda-merge ../scripts/requirements-test.yml docs_environment.yml | sed '/tigre/d' > environment.yml
conda env update -n test
conda list
- name: build cil
Expand Down
2 changes: 2 additions & 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 Expand Up @@ -47,6 +48,7 @@
- `FBP` kwarg (and thus all kwargs) in `cil.processors.CentreOfRotationCorrector` and `cil.processors.CofR_image_sharpness`
- `TXRMDataReader`
- 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
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ LABEL org.opencontainers.image.source=https://github.com/TomographicImaging/CIL
LABEL org.opencontainers.image.licenses="Apache-2.0 AND BSD-3-Clause AND GPL-3.0"

# CUDA-specific packages
ARG CIL_EXTRA_PACKAGES="tigre=2.4 astra-toolbox<2.1"
ARG CIL_EXTRA_PACKAGES="tigre=2.6 astra-toolbox<2.1"
# build & runtime dependencies
# TODO: sync scripts/create_local_env_for_cil_development.sh, scripts/requirements-test.yml, recipe/meta.yaml (e.g. missing libstdcxx-ng _openmp_mutex pip)?
# vis. https://github.com/TomographicImaging/CIL/pull/1590
Expand All @@ -20,7 +20,7 @@ COPY --chown="${NB_USER}" scripts/requirements-test.yml environment.yml
RUN sed -ri '/tigre|astra-toolbox/d' environment.yml \
&& for pkg in jupyter-server-proxy $CIL_EXTRA_PACKAGES; do echo " - $pkg" >> environment.yml; done \
&& conda config --env --set channel_priority strict \
&& for ch in defaults ccpi intel conda-forge; do conda config --env --add channels $ch; done \
&& for ch in defaults nvidia ccpi intel conda-forge; do conda config --env --add channels $ch; done \
&& mamba env update -n base \
&& mamba clean -a -y -f \
&& rm environment.yml \
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
4 changes: 3 additions & 1 deletion Wrappers/Python/cil/plugins/tigre/FBP.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ def process(self, out=None):
arr_out = np.squeeze(arr_out, axis=0)
else:
if self.acquisition_geometry.geom_type == 'cone':
arr_out = fdk(self.get_input().as_array(), self.tigre_geom, self.tigre_angles)
# suppress print statements from TIGRE https://github.com/CERN/TIGRE/issues/532
with contextlib.redirect_stdout(io.StringIO()):
arr_out = fdk(self.get_input().as_array(), self.tigre_geom, self.tigre_angles)
else:
arr_out = fbp(self.get_input().as_array(), self.tigre_geom, self.tigre_angles)

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
Loading

0 comments on commit 9014c4f

Please sign in to comment.