Code Monkey home page Code Monkey logo

cil's Introduction

CIL - Core Imaging Library

Master Development Conda binaries
CI-master CI-dev conda-ver conda-date conda-plat conda-dl

Binder

The Core Imaging Library (CIL) is an open-source Python framework for tomographic imaging with particular emphasis on reconstruction of challenging datasets. Conventional filtered backprojection reconstruction tends to be insufficient for highly noisy, incomplete, non-standard or multichannel data arising for example in dynamic, spectral and in situ tomography. CIL provides an extensive modular optimisation framework for prototyping reconstruction methods including sparsity and total variation regularisation, as well as tools for loading, preprocessing and visualising tomographic data.

Documentation

The documentation for CIL can be accessed here.

Installation of CIL

Conda

Binary installation of CIL can be achieved with conda.

We recommend using either miniconda or miniforge, which are both minimal installers for conda. We also recommend a conda version of at least 23.10 for quicker installation.

Install a new environment using:

conda create --name cil -c conda-forge -c intel -c ccpi cil=24.0.0

To install CIL and the additional packages and plugins needed to run the CIL demos install the environment with:

conda create --name cil -c conda-forge -c intel -c ccpi cil=24.0.0 astra-toolbox=*=cuda* tigre ccpi-regulariser tomophantom ipywidgets

where:

  • astra-toolbox enables CIL support for ASTRA toolbox CPU projector (2D Parallel beam only) (GPLv3 license)
  • astra-toolbox=*=cuda* (requires an NVIDIA GPU) enables CIL support for ASTRA toolbox GPU projectors (GPLv3 license)
  • tigre (requires an NVIDIA GPU) enables support for TIGRE toolbox projectors (BSD license)
  • ccpi-regulariser is the CCPi Regularisation Toolkit
  • tomophantom can generate phantoms to use as test data Tomophantom
  • ipywidgets enables visulisation tools within jupyter noteboooks

Dependencies

CIL's optimised FDK/FBP recon module requires:

  1. the Intel Integrated Performance Primitives Library (license) which can be installed via conda from the intel channel.
  2. TIGRE, which can be installed via conda from the ccpi channel.

Docker

Finally, CIL can be run via a Jupyter Notebook enabled Docker container:

docker run --rm --gpus all -p 8888:8888 -it ghcr.io/tomographicimaging/cil:latest

Tip

docker tag CIL branch/tag
latest latest tag v*.*.*
YY.M latest tag vYY.M.*
YY.M.m tag vYY.M.m
master master
only build & test (no tag) CI (current commit)

See ghcr.io/tomographicimaging/cil for a full list of tags.

Note

GPU support requires nvidia-container-toolkit and an NVIDIA GPU. Omit the --gpus all to run without GPU support.

Important

Folders can be shared with the correct (host) user permissions using --user $(id -u) --group-add users -v /local/path:/container/path where /local/path is an existing directory on your local (host) machine which will be mounted at /container/path in the docker container.

Tip

See jupyter-docker-stacks for more information.

Getting Started with CIL

CIL on binder

Binder

Jupyter Notebooks usage examples without any local installation are provided in Binder. Please click the launch binder icon above. For more information, go to CIL-Demos and https://mybinder.org.

CIL Videos

Building CIL from source code

Getting the code

In case of development it is useful to be able to build the software directly. You should clone this repository as

git clone --recurse-submodule [email protected]:TomographicImaging/CIL

The use of --recurse-submodule is necessary if the user wants the examples data to be fetched (they are needed by the unit tests). We have moved such data, previously hosted in this repo at Wrappers/Python/data to the CIL-data repository and linked it to this one as submodule. If the data is not available it can be fetched in an already cloned repository as

git submodule update --init --recursive

Build dependencies

To create a conda environment with all the dependencies for building CIL run the following shell script:

bash scripts/create_local_env_for_cil_development.sh

Or with the CIL build and test dependencies:

bash scripts/create_local_env_for_cil_development.sh -t

And then install CIL in to this environment using CMake.

Alternatively, one can use the scripts/requirements-test.yml to create a conda environment with all the appropriate dependencies on any OS, using the following command:

conda env create -f scripts/requirements-test.yml

Build with CMake

CMake and a C++ compiler are required to build the source code. Let's suppose that the user is in the source directory, then the following commands should work:

cmake -S . -B ./build -DCMAKE_INSTALL_PREFIX=<install_directory>
cmake --build ./build --target install

If targeting an active conda environment then the <install_directory> can be set to the CONDA_PREFIX environment variable (e.g. ${CONDA_PREFIX} in Bash, or %CONDA_PREFIX% in the Anaconda Prompt on Windows).

If not installing to a conda environment then the user will also need to set the locations of the IPP library and includes, and the path to CIL.

By default the location of the IPP library and includes is ${CMAKE_INSTALL_PREFIX}/lib and ${CMAKE_INSTALL_PREFIX}/include respectively. To pass the location of the IPP library and headers please pass the following parameters:

cmake -S . -B ./build -DCMAKE_INSTALL_PREFIX=<install_directory> -DIPP_LIBRARY=<path_to_ipp_library> -DIPP_INCLUDE=<path_to_ipp_includes>

The user will then need to add the path <install_directory>/lib to the environment variable PATH or LD_LIBRARY_PATH, depending on system OS.

Building with Docker

In the repository root, simply update submodules and run docker build:

git submodule update --init --recursive
docker build . -t ghcr.io/tomographicimaging/cil

Testing

One installed, CIL functionality can be tested using the following command:

export TESTS_FORCE_GPU=1  # optional, makes GPU test failures noisy
python -m unittest discover -v ./Wrappers/Python/test

Citing CIL

If you use CIL in your research, please include citations to both the software on Zenodo, and a CIL paper:

E. Pasca, J. S. Jørgensen, E. Papoutsellis, E. Ametova, G. Fardell, K. Thielemans, L. Murgatroyd, M. Duff and H. Robarts (2023)
Core Imaging Library (CIL)
Zenodo [software archive]
DOI: https://doi.org/10.5281/zenodo.4746198

In most cases, the first CIL paper will be the appropriate choice:

J. S. Jørgensen, E. Ametova, G. Burca, G. Fardell, E. Papoutsellis, E. Pasca, K. Thielemans, M. Turner, R. Warr, W. R. B. Lionheart and P. J. Withers (2021)
Core Imaging Library - Part I: a versatile Python framework for tomographic imaging.
Phil. Trans. R. Soc. A. 379: 20200192.
DOI: https://doi.org/10.1098/rsta.2020.0192
Code: https://github.com/TomographicImaging/Paper-2021-RSTA-CIL-Part-I

However, if your work is more closely related to topics covered in our second CIL paper then please additionally or alternatively reference the second paper:

E. Papoutsellis, E. Ametova, C. Delplancke, G. Fardell, J. S. Jørgensen, E. Pasca, M. Turner, R. Warr, W. R. B. Lionheart and P. J. Withers (2021)
Core Imaging Library - Part II: multichannel reconstruction for dynamic and spectral tomography.
Phil. Trans. R. Soc. A. 379: 20200193.
DOI: https://doi.org/10.1098/rsta.2020.0193)
Code: https://github.com/TomographicImaging/Paper-2021-RSTA-CIL-Part-II

cil's People

Contributors

asharits avatar casperdcl avatar clairedelplancke avatar danicastfc avatar dkazanc avatar epapoutsellis avatar evelinaametova avatar gfardell avatar github-actions[bot] avatar hrobarts avatar jakobsj avatar kpidge avatar kristhielemans avatar lauramurgatroyd avatar letizia97 avatar margaretduff avatar paskino avatar samtygier-stfc avatar tomaskulhanek avatar vais-ral avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cil's Issues

demo_IP to be moved to separate branch?

When going public, if not including support for importing FGP_TV etc from the FISTA/regularizer repo, I suppose we should move the demo_IP from the master branch to a separate (experimental) branch?

Average along one axis DataSetProcessor

It may be useful to have a DataSetProcessor to calculate the average of a DataSet along an axis and collapse that axis. For instance, when flats and darks are calculated they are a stack of N images.
It may be useful to have a processor that averages the slices out and creates a 2D DataSet out of it.

DataSet arithmetic operations to return specific subclass

Arithmetic operations etc. explicitly (hard coded) produce generic DataSet objects, despite original objects being from specific subclass. This for example means that after running FISTA, the reconstruction is a DataSet and not, as desired, a VolumeData. Perhaps possible to fix by replacing hard coded "DataSet" by "type(self)".

Demos

  • Diamond single channel parallel beam dataset
  • SophiaBeads single channel
  • Demo IP (multichannel)

Writer

DataSet should be able to save to HDF5

Implement dataset method to copy entire object with all properties

Running simple_demo in 59c01d8 causes the error

Traceback (most recent call last):

  File "<ipython-input-10-cd664ec232c5>", line 1, in <module>
    x_CGLS, it_CGLS, timing_CGLS, criter_CGLS = CGLS(Aop, b, 1000, x_init)

  File "..\ccpi\reconstruction\algs.py", line 142, in CGLS
    d = A.adjoint(r)

  File "..\ccpi\reconstruction\astra_ops.py", line 52, in adjoint
    self.bp.setInput(DATA)

  File "..\ccpi\framework.py", line 628, in setInput
    if self.checkInput(dataset):

  File "..\ccpi\astra\astra_processors.py", line 128, in checkInput
    if dataset.number_of_dimensions == 3 or dataset.number_of_dimensions == 2:

AttributeError: 'SinogramData' object has no attribute 'number_of_dimensions'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.