owned this note
owned this note
Published
Linked with GitHub
# CIL Online Training March 2025
## :information_source: About
[comment]: https://hackmd.io/@ccpi/cil-online24
Welcome to the [CIL Online Training March 2025](https://ccpi.ac.uk/events/cil-online-training-march-2025/). This training course will take place on Tuesday 25th, Wednesday 26th and Thursday 27th March 2025 from 1-5pm UK time.
This document is for participants to find information about the course, ask questions and share answers with each other.
> [!TIP]
> As participants, you're welcome to contribute to this document by pressing the 'Edit' button at the top of the page. You can edit the text in the left panel and view changes on the right. We'd love to hear from you in the [Questions](#-Your-Questions) section!
## :mega: Current activity: Training is complete
## :clock1: Training timetable
### Day 1: Tuesday 25th March - Getting Started with CIL
Learn how to use CIL for standard CT datasets, including analytical reconstruction methods (FBP and FDK), pre-processing techniques, and visualisation tools.
<!--
| Time | Topic | Presenter |
| ----------- | ----- | --------- |
| 1:00 - 1:10 | Welcome, course overview and icebreaker | Hannah Robarts |
| 1:10 - 2:05 | **Session 1: Geometry, data reading and analytical reconstruction** <li>Introductory lecture</li> <li>Explore notebook in breakout rooms: <br> :open_file_folder: `1_Introduction` <br> :page_facing_up:`01_intro_walnut_conebeam.ipynb`</br> </li> | Franck Vidal |
| 2:05 - 2:35 | **Session 2: Writing your own code in CIL** <li>CIL's structure and documentation</li><li>Explore notebook in break out rooms: <br> :open_file_folder: `1_Introduction` <br> :open_file_folder: `exercises`<br> :page_facing_up:`01_intro_seeds_conebeam.ipynb`</br> </li> | Laura Murgatroyd |
| 2:35 - 2:50 | Break | |
| 2:50 - 3:40 | **Session 3: Pre-processing** <li>Introduction to pre-processing in CIL lecture</li><li>Explore notebook in break out rooms<br> :open_file_folder: `1_Introduction` <br> :page_facing_up:`02_intro_sandstone_parallel_roi.ipynb`</br> </li> | Laura Murgatroyd |
| 3:40 - 4:00 | Break | |
| 4:00 - 4:45 | **Session 4: Time to explore and discuss**<li>Introduction</li> <li>Choose from the following notebooks to explore in breakout rooms: <br> :open_file_folder: `1_Introduction` <br> :page_facing_up:`00_CIL_geometry.ipynb`</br> :page_facing_up:`03_preprocessing.ipynb`</br> :open_file_folder: `exercises` <br> :page_facing_up:`02_preprocessing_seeds_conebeam.ipynb`</br> :page_facing_up:`03_where_is_my_reader.ipynb`<br> :open_file_folder: `4_Deep_Dives` <br> :page_facing_up:`02_phase_retrieval.ipynb`</br></li> | Franck Vidal |
| 4:45 - 5:00 | Wrap up and questions | Laura Murgatroyd |
Which notebooks did you try? Add a # to tell us!
- 00_CIL_geometry.ipynb....... ... .... #####
- 03_preprocessing.ipynb.......... ... ...#####
- 03_where_is_my_reader.ipynb ######
- 02_phase_retrieval.ipynb... ... .#####
-->
### Day 2: Wednesday 26th March -- Iterative Reconstruction Techniques with CIL
Explore iterative reconstruction methods, going beyond SIRT and CGLS, and incorporating regularisation for improved results.
<!-- | Time | Topic | Presenter |
| ----------- | ----- | --------- |
| 1:00 - 1:15 |Welcome, intro and cloud setup| Edoardo Pasca |
| 1:15 - 2:15 | **Session 1: optimisation** <li>Introduction to optimisation lecture</li> <li>Explore notebooks in breakout rooms: <br> :open_file_folder: `1_Introduction` <br> :page_facing_up:`04_FBP_CGLS_SIRT.ipynb`</br> :page_facing_up:`05_usb_limited_angle_fbp_sirt.ipynb` (extension)</li>| Edoardo Pasca |
| 2:15 - 2:30 | Break | |
| 2:30 - 3:45 | **Session 2: regularisation** <li>Introduction to regularisation lecture and demo of notebook:<br>:open_file_folder: `binder` <br> :page_facing_up:`PyData22_deblurring.ipynb`</br></li><li>Explore notebook in breakout rooms: <br>:open_file_folder: `2_Iterative` <br> :page_facing_up:`01_optimisation_gd_fista.ipynb`</br></li>| Jakob Sauer Jørgensen |
| 3:45 - 4:00 | Break | |
| 4:00 - 4:45 | **Session 3: Time to explore and discuss**<li>Introduction</li> <li>Choose from the following notebooks to explore in breakout rooms: <br> :open_file_folder: `2_Iterative` <br> :page_facing_up:`05_Laminography_with_TV.ipynb`</br>:open_file_folder: `3_Multichannel`<br> :page_facing_up:`03_Hyperspectral_reconstruction.ipynb`</br></li> |Jakob Sauer Jørgensen|
| 4:45 - 5:00 | Wrap-up and questions | Margaret Duff | -->
### Day 3: Thursday 27th March - Advanced Topics in CIL
Dive into advanced capabilities, including building custom optimisation problems, using callbacks and preconditioners, and creating objective functions.
| Time | Topic | Presenter |
| ----------- | ----- | --------- |
|1:00 - 1:15 | Welcome, intro and cloud setup | Margaret Duff|
| 1:15 - 2:30 | **Session 1: Building your own optimisation problem using the block framework** <li>Introduction to the Block framework and demo of notebook:<br> :open_file_folder: `2_Iterative `<br> :page_facing_up:`02_tikhonov_block_framework.ipynb`</br> </li><li> Explore notebook in breakout rooms<br> :open_file_folder: `4_Deep_Dives`<br> :page_facing_up:`03_htc_2022.ipynb`</br> </li> |Jakob Sauer Jørgensen|
| 2:30 - 2:45 | Break | |
| 2:45 - 3:45 | **Session 2: Customising your optimisation method** <li>Introduction and demo of notebook<br> :open_file_folder: `4_Deep_Dives`<br> :page_facing_up:`01_callbacks.ipynb`</br></li><li>Explore notebook in breakout rooms: <br> :open_file_folder: `4_Deep_Dives` <br> :page_facing_up:`04_preconditioner_stepsize.ipynb`</br></li> |Margaret Duff|
| 3:45 - 4:00 | Break | |
| 4:00 - 4:45 | **Session 3: Time to explore and discuss**<li>Choose from the following notebooks to explore in breakout rooms: <br> :open_file_folder: `1_Introduction` <br> :page_facing_up:`03_where_is_my_reader.ipynb`</br>:open_file_folder: `3_Multichannel` <br> :page_facing_up:`02_Dynamic_CT.ipynb`</br>:open_file_folder: `4_Deep_Dives` <br> :page_facing_up:`06_directional_TV.ipynb`</br> :page_facing_up:`02_phase_retrieval.ipynb`</li> | Margaret Duff |
| 4:45 - 5:00 | Wrap-up, next steps and questions |Jakob Sauer Jørgensen|
## :question: Your Questions
> [!TIP]
> To create a new question, make sure you're in edit mode then type `#####` in the relevant section below. A trainer will answer your question in *italics*
#### Thank you for all your excellent questions on days 1 and 2! You can find all questions and answers archived [here](https://hackmd.io/@ccpi/H1eIgLb6yg)
Please continue adding any questions from today in the relevant sections below:
---
### General CIL and CT questions
##### What is the unit of the pixel value given by FBP/iterative methods ? Is it already scaled using the pixel_size value?
The value per voxel in the reconstruction is the linear attenenuation coefficient (μ) in units of 1/length.For example, if you have set up your geometry in mm (i.e. pixel size for parallel, source to detector distance/source to object distance and pixel size for cone-beam) then your units are 1/mm.
##### When reconstructing my own synchrotron CT data, there is a difference in scaling between FBP and iterative methods, even though I use the same geometry for both. By scaling I mean both in pixel values and in (x,y) scaling
Happy to take a look together and discuss - please get in touch on discord.
---
### Technical questions
##### Add your question here
---
### :open_file_folder: `2_Iterative`
#### Questions about: `02_tikhonov_block_framework.ipynb`
##### How does the block representation affect the conditioning of the problem? I guess this also has some implications in the step sizing, right?
By adding in the Tikhonov regularisation the operator A becomes better conditioned. Indeed, it should no longer be as sensitive to the noise in the data.
In general, if you change the operators, you may need to choose a different step size for your algorithm. However, for CGLS all these step-sizes are chosen by the algorithm and do not need to be specified by the user.
##### How can I plot the CGLS convergence error?
Each algorithm stores the claculated objective values in a member called objective (if that has been evaluated). This can then be plotted
For example:
```
cgls = CGLS(initial=initial, operator=A, data=sino, update_objective_interval = 1)
cgls.run(1000, verbose=True)
plt.plot(cgls.objective)
```
For plotting other metrics, see this afternoon
#### Why does the objective very often stabilize at a specific value and neither increase or decrease? Is it "stuck" in a local minima?
The problems we are solving are convex, there is no local minima. With Tikhonov regularisation, the problem has a unique solution.
The objective value could stablise if you are near the minima, near convergence. You could of course just be moving very slowly.
(from a participant) - Also, sometimes the optimisation landscape can be tough on these problems. Once you are getting close to a minimiser, either the area where it “lies” is very flat or gradients can be wild [meaning that if you take a bad step, then your objective will increase], so it is common to see algorithms to go slower.
#### Can you add a non-negativity constraint to CGLS?
The non-negativity constraint is not differentiable so is not compatible with our implementation of CGLS. It can be included in other algorithms e.g. the FISTA algorithm. For example, see in CIL-Demos/demos/2_Iterative
/01_optimisation_gd_fista.ipynb.
(from a participant) - An implementation (variant) of CG with non-negativity constraints: https://github.com/jnagy1/IRtools
#### Is there a handy reference for what the different regularisation methods can do? e.g. L1 makes it more sparse reducing removing low pixel values and preserves edges, Tikhnov makes it a bit more blurry but reduces noise
Jakob would like to recommend his book (though in all seriousnes the CIL team find it useful) https://epubs.siam.org/doi/book/10.1137/1.9781611976670
There is also a good review paper here: https://arxiv.org/abs/1801.09922
#### How do you choose the right optimisation algorithm?
The algorithms all are designed to be used for different types of problem. A non-complete list of what algorithms are used for what is below:
Often more than one algorithm might be suitable for your problem but one might converge quicker than another

#### Are you perhaps aware of more references towards this direction? I have seen this kind of ill-conditioning in other nonlinear problems
So in CIL, we have implemented algorithms in section 3F of this paper https://ieeexplore.ieee.org/document/9872020. Boyd (/https://web.stanford.edu/~boyd/cvxbook/bv_cvxbook.pdf) looks at it a bit in section 9.3 and 9.5
You could also look at: https://www.cs.cornell.edu/courses/cs4787/2019sp/notes/lecture8.pdf
---
### :open_file_folder: `4_Deep_Dives`
#### Questions about: `03_htc_2022.ipynb`
##### Add your question here
#### Is the renormalisation of the sinogram linked to the CIL flux normaliser?
The CIL Flux normaliser (https://tomographicimaging.github.io/CIL/nightly/processors/#flux-normaliser ) normalises the differences in flux between different projections using an array of float values or the mean flux in a region of interest.
You could use the CIL Flux Normaliser either with a single float, of a background value, or with a background region of interest, to get a similar result.
##### What tools are available for doing sensitivity analaysis, uncertainty quantification? For example, understanding variations in regularization parameter's effect on reconstruction (for in small reconstructions of course) or effects of noise.
We don't have any tools for uncertainty quantification in CIL, but CIL is used as a plug-in to CUQIpy (computational uncertainty quantification for imaging in python) https://cuqi-dtu.github.io/CUQIpy/
#### Is there a reference for PDHG?
Chambolle, A., Pock, T. A First-Order Primal-Dual Algorithm for Convex Problems with Applications to Imaging. J Math Imaging Vis 40, 120–145 (2011). https://doi.org/10.1007/s10851-010-0251-1
#### Are there tools to convert matrices (or rather numpy arrays) into operators in CIL and vice-versa?
Yes, we have a CIL matrix operator https://tomographicimaging.github.io/CIL/nightly/optimisation/#cil.optimisation.operators.MatrixOperator
---
#### Questions about: `01_callbacks.ipynb`
##### Add your question here
#### Why doesn't the algorithm need to calculate the objective value every iteration?
For some algorithms it will be calculated every iteration e.g. CGLS calculates a residual each iteration. For something like gradient descent you don't need to know the objective value every iteration to make the next step.
The calculation of the objective value can be computationally expensive, therefore it could be better to omit the computation.
#### It appears that the call-back is called only with the outer iterations of FISTA (TV option in this notebook). Can the call-back be configured to be called w/in the inner iterations as well?
CIL's `TotalVariation` or other methods from the plugin regularisation toolkit are not developed as CIL `Algorithm` but instead they are CIL `Function`. Therefore, there is currently no way to pass callbacks down to them.
#### Other than CGLS, are there plans for other Krylov methods being incorporated into CIL (i.e. FGMRES for normal-equations and the like)?
Together the Computational Mathematics theme in STFC we are developing other Krylov methods, such as [LSQR](https://github.com/TomographicImaging/CIL/pull/1975) and hybrid methods to automatically determine regularisation parameters.
---
#### Questions about: `04_preconditioner_stepsize.ipynb`
##### Add your question here
#### Could you help us with more references on preconditioning for optimisation? I have seen this kind of ill-conditioning in other nonlinear problems.
So in CIL, we have implemented algorithms in section 3F of this paper https://ieeexplore.ieee.org/document/9872020. Boyd (/https://web.stanford.edu/~boyd/cvxbook/bv_cvxbook.pdf) looks at it a bit in section 9.3 and 9.5
You could also look at: https://www.cs.cornell.edu/courses/cs4787/2019sp/notes/lecture8.pdf
---
#### Questions about: `02_phase_retrieval.ipynb`
##### Does the input dataset have to be 3D for the Paganin processor to work ? I am trying it on a sinogram I have and the output comes empty
Yes, the input dataset does need to be 3D
---
#### Questions about: `06_directional_TV.ipynb`
##### Add your question here
---
### :open_file_folder: `1_Introduction/exercises`
#### Questions about: `03_where_is_my_reader.ipynb`
##### Add your question here
---
### :open_file_folder: `3_Multichannel`
#### Questions about `02_Dynamic_CT.ipynb`
##### Could this idea be reworked to handle unusable data within a sinogram ? Instead of subsampling angles, the last n angles would be considered corrupt for example (sample movement etc..)
You could use CIL's Slicer processor to keep only the 'good' angles with
Slicer(roi={'angle':(0,x+1,1)})(data)
where x is your last 'good' angle
This means you then have a limited angle problem like we had in the Helsinki Tomography Challenge. Note that if your missing angles are all in one chunk then it's more difficult to reconstruct than if they're distributed evenly throughout the data. Iterative methods should be able to help but the difficulty depends on how many angles are missing!
## :computer: Training platform instructions
- Go to: https://tinyurl.com/cil-online-25 write your name next to a username to claim it for the exercises
- Go to the CIL Jupyter notebook server: https://training.jupyter.stfc.ac.uk/
- **Sign up** with the username you claimed and a password of your choice. Create a memorable password.
- Then **Log in** with your username and password
> [!WARNING]
> We can't change your password, so make sure you choose something memorable
## Mentimeter
We will be using mentimeter for interactive content and feedback: https://www.menti.com/alzfkfjnbhfo
## :book: Resources
**Get the code**
- Find CIL on GitHub https://github.com/tomographicImaging/cil
- Installation instructions: https://github.com/TomographicImaging/CIL?tab=readme-ov-file#installation-of-cil
- Read the documentation: https://tomographicimaging.github.io/CIL/v23.1.0/index.html
**Try some examples**
- CIL demos: https://github.com/TomographicImaging/CIL-Demos
- CIL User Show-case notebook collection: https://github.com/TomographicImaging/CIL-User-Showcase/
**Get support**
- Join CIL Discord support platform: https://discord.com/invite/9NTWu9MEGq
- Open an issue in CIL: https://github.com/TomographicImaging/CIL/issues
- Join the CCPi mailing list: https://www.jiscmail.ac.uk/cgi-bin/webadmin?A0=CCPI-MEMBERS
- Find out about upcoming events: https://ccpi.ac.uk/
**Read some CIL publications**
- About CIL https://doi.org/10.1098/rsta.2020.0192
- CIL for multichannel imaging https://doi.org/10.1098/rsta.2020.0193
- Recent paper from the CIL team on a directional reconstruction method (using the PDHG optimization algorithm) for limited-angle CT, which won third prize in the Helsinki Tomography Challenge 2022: https://www.aimsciences.org/article/doi/10.3934/ammc.2023011
**Course material**
- Slides from each day are available here
- Day 1: https://tomography.stfc.ac.uk/CIL-training-03-25/2025-Online-Introductory-Training.pdf
- Day 2: https://tomography.stfc.ac.uk/CIL-training-03-25/2025-CIL-iterative-training.pdf
- Day 3: https://tomography.stfc.ac.uk/CIL-training-03-25/2025-Online-AdvancedCIL-updated.pdf
**Additional software developed in our group**
- **iDVC** allows a digital volume correlation (DVC) analysis to be performed on a reference and correlate image volume. You may either use a point cloud you have pre-created, or generate this in the app.
https://tomographicimaging.github.io/iDVC/
https://github.com/TomographicImaging/iDVC
- **gVirtualXray (gVXR)** is a simulation framework for X-ray imaging. It is based on the Beer-Lambert law and computes the absorption of light (i.e. photons) by 3D objects (here polygon meshes). It is implemented on the graphics processing
(GPU) using the OpenGL Shading Language (GLSL), i.e. it works with GPUs from any manufacturers, inc. integrated graphics cards on laptops. It is available in Python, R, Ruby, Tcl, C#, Java, and GNU Octave:
https://gvirtualxray.sourceforge.io/
https://pypi.org/project/gVXR/
- **WebCT** is a feature-rich environment for previewing and simulating X-ray scans on the browser a web. It provides a frontend for simulating scans with gVXR and reconstructing them with CIL:
https://www.webct.io/
**Future Events**
Find our upcoming events at https://ccpi.ac.uk/
- **CCPi Show and Tell & User Support drop in - Thursday 10th April** - fortnightly zoom meeting with user talks and drop by after 2pm to ask any questions about CIL. https://ccpi.ac.uk/events/ccpi-show-tell-and-user-support-drop-in/
- **CIL and SIRF Pytorch Hackathon - 7-9 April UCL** - https://ccpi.ac.uk/events/hackathon-cil-pytorch25/
- **Maths of CT** - For more math, you're in luck - next January Jakob offers a 3-week intensive course starting on 5th Jan on the math of CT, it'll be at DTU just north of Copenhagen, open to external participants. Here's the link from the previous run, please get in touch if interested: https://www2.compute.dtu.dk/~pcha/HDtomo/SCforCT.html
- **Image-based simulation for industry (IBSim-4i) 2025**, 20-24 Oct 2025 - IBSim is the process by which 3D images (e.g. X-ray CT or laser scanning) are converted into ultra-high resolution simulations. IBSim-4i is a 5-day programme consisting of a 2-day training course followed by a 2-day users' forum and 1 day collaborative workshop. We've put together an exciting training programme this year, with one day on Machine Learning and AI for imaging, and one day on the [Fenics solver](https://fenicsproject.org/).
https://iop.eventsair.com/ibsim2025/