---
# System prepended metadata

title: CIL Online Training Questions

---

# CIL Online Training Questions
## :question: Your Questions from Day 1

### General CIL and CT questions
##### How many channels does cil support?
*We can support multi-channel images e.g. hyperspectral or dynamic CT, with any number of channels. CIL Data containers have a maximum of 4 dimensions, 3 spatial + 1 **channel** dimension which could be energy or time, for instance.*

##### Will the github installation include the required ASTRA and TIGRE components?

To install CIL and its prerequisites you can follow the instructions at the GitHub repository https://github.com/TomographicImaging/CIL#installation-of-cil

In particular, if you use `conda` on the `ccpi` channel we provide the binaries of CIL and all its dependencies that are not available via the `conda-forge` or the Intel conda channel.

##### Can we import .xmu data e.g. from ZEISS Versa X-CT?

Currently the `ZeissDataReader` reads acquisition (experimental) data in `txrm` files for  and image data in `txm`, this was introduced in [version 22.0.0 ](https://github.com/TomographicImaging/CIL/releases/tag/v22.0.0)

We're not familiar with the .xmu file, do you know what it contains? Is it projection data or some meta data?

##### Is it possible to get some sort of certificate to show supervisors for credits?
Please email tomography@stfc.ac.uk to enquire about a certificate

##### Is there a default unit in CIL?

No, there is no default unit in CIL. We just ask that you are consistent with using the same unit in all places. Your reconstruction will have the units of the inverse of this.

##### islicer, can we reslice the reconstructed CT volume along any plane?

You can display data in any direction, but `islicer` will not **reslice** it will slice data and display it to you. 

#### Is CIL a wrapper for astra toolbox (for certain algorithms), should we just use CIL instead ?

CIL uses ASTRA or TIGRE as backend for forward and backprojection, and for certain filter back projection algorithms. 
We think that the geometry definitions in CIL are well defined and documented. CIL will translate its geometry to an ASTRA and/or TIGRE geometries.

CIL does not expose all functionality from ASTRA or TIGRE.


#### The image quality was highly dependent on the reduced factor. How do you determine the optimal number of angles for image acquisition in CT?

For filter back projection the standard rule is 
`num_angles = pi / 2  * horizontal_size_of_acquisition_panel`  This can be reduced if introducing prior knowledge with iterative reconstruction with regularisation.

#### Can CIL accomodate arbitrary sample-trajectories?  Not just a circle, or a helix, or a double-helix but some other trajectory? (For example ASTRA cannot)

We are looking to include "per projection" geometries in CIL which will allow for arbitrary trajectories. This is currently a work in progress: we are working with collobrators to test it before releasing the code. It will be available in the next CIL release - however this will initially use only ASTRA's vector geometry as the backend.

#### Are FDK and FBP the only reconstruction options available from CIL directly?

These are the analytic options available in CIL but there are other iterative options for reconstruction which allows for regularisation such as TV regularisation. This will covered in day 2 and 3 of the course.  


#### Will the jupyter notebooks be avialable off-line for post-lecture study? Or after the class has concluded?

Yes, they are available
https://github.com/TomographicImaging/CIL-Demos

You will be able to continue to use your cloud login until 5pm on Friday 28th of March.

If you go to the CIL-Demos GitHub page, you will see under "CIL on the cloud" one button for "launch binder" and one for "Open in Colab", click on either of these to start up a remote server where CIL will be installed (the binder one has no GPU, so only some small examples, whereas the google colab one does have a gpu)

https://github.com/TomographicImaging/CIL-Demos

#### Can you make that until Monday?  That gives us the weekend to play with this. (Sorry for being so pushy)

Sorry this is not possible as the jupyterhub platform will be in use for a different course.

If you contact us on discord/user support we might be able to set you up a cloud instance for a longer period. We can also help you instal CIL locally.

(Thank you so very much  - I'll do that!)

#### Is there a way to get all available functions from a given object ? Like a helper function to call ?

You can use `help()` function to display the documentation. You can also see our documentation here: https://tomographicimaging.github.io/CIL/v24.3.0/

#### Does CIL provide tools to perform the flat-field correction?
Yes, CIL provides a  pre-processors for flat-field correction, it's the normalisation pre-processor. Our pre-processors can be found in the documentation [here](https://tomographicimaging.github.io/CIL/v24.3.0/processors/#pre-processors)

#### Does CIL have a beam hardening corrector? 
We have pre-processors for normalisation, bad pixel correction, centre of rotation correction and more. We do not currently have a beam hardening correction but that is on our (long) to do list. We hope to add a single-material correction in the near-future.

#### How can we find the 'angle' to set the centre of rotation offset ?
You might be able to use one of the CIL centre of rotation methods to find the angle [Processors — CIL 24.3.0 documentation](https://tomographicimaging.github.io/CIL/v24.3.0/processors/#centre-of-rotation-corrector)

#### A question about alignment: For the cone beam geometry, the detector can have three angles of misalignment. (sometimes called theta/phi/eta). Does CIL have any method to correct this misalignment?

In the CIL geometry one can manually set these degrees of freedom.  The  laminography CIL demo (2_iterative/05_Laminography_with_TV.ipynb) demonstrates a tilt of the rotation access.  We are looking into ways of fitting some of the degrees of the freedom but this is not currently implemented. 

#### What does `backend` mean? 

Backend usually means the storage, compute and logic hidden from the user. In CIL backend could mean the software plugin used to do the CT operators (Tigre or Astra), or to do a calculation (sometimes we use numba) or it could mean the hardware (CPU or GPU)

#### Will there be any conflicts when we try to import custom data sets or non-CT data sets?
The notebook, "1_Introduction/exercises/03_where_is_my_reader.ipynb" talks you through how to set up your geometry for a custom data set. For non-CT datasets you can load them as numpy arrays and wrap them in a CIL Image Data before using the CIL operators and iterative reconstruction methods. For an example of a non-CT dataset, see "CIL-Demos/binder/PyData22_deblurring.ipynb"

---
### Technical questions

##### I cannot create a log in into jupyterhub

*Choose a user name from the online form and login as described [here](#-Training-platform-instructions).*

### :open_file_folder: `1_Introduction`
---
#### Questions about: `01_intro_walnut_conebeam.ipynb`

##### How can we make sure that the units are defined in the acquisition. Are they already defined in the ZEISS acquisition parameters ? 
*Yes the geometry is created in CIL using information from the Zeiss file, so as long as the units are consistent in the ZEISS data file your geometry will be correct*

##### Are there drawbacks to using too many projections/angles?
*The dataset will become larger so may be harder to process. The image quality won't significantly improve over a certain point.*

##### How would the reconstructed image look if the source size is in cm range? Does FBP or FDK work well?
A larger focal spot will blur your reconstruction, but it depends on the rest of the geometry, i.e. the magnification of the data.

##### Does CIL offer anything for MRI?

In combination with our "sister library" [SIRF](https://github.com/SyneRBI/SIRF/wiki/How-to-obtain-SIRF) it is possible to run MRI reconstruction in CIL, see for example this nice user-contributed showcase notebook:
https://github.com/TomographicImaging/CIL-User-Showcase/blob/main/005_dynamic_mr_recon/dynamic_mr_recon.ipynb

#### How do you change the reconstruction parameters. for example the filters.

Analytic methods like FBP and FDK are available in CIL via the ASTRA and TIGRE plugins, and with the recon class. 

The ASTRA and TIGRE plugins do not have any parameter to change. They use the Ram-Lak filter. 

With the `cil.recon.FBP` and `cil.recon.FDK` you can change the filter and some other filter related parameters.
The available default filters are `ram-lak`, `shepp-logan`, `cosine`, `hamming`, `hann`, but a numpy array with the filter data can also be passed in.

The filter can be specified at instantiation:

```
from cil.recon import FBP
fbp = FBP(data, filter='shepp-logan')
```

Or it can updated by:
```
fbp.set_filter(filter='ram-lak', cutoff=1.0)
```
See the documentation for more details https://tomographicimaging.github.io/CIL/nightly/recon/#fbp-reconstructor-for-parallel-beam-geometry


#### Are FDK and FBP the only reconstruction options available from CIL directly?


FBP and FDK are the analytic options available in CIL but there are other iterative options for reconstruction which allows for regularisation such as TV regularisation. This will covered in day 2 and 3 of the course. 

The `SIRT` and `CGLS` algorithms will only solve a least-squares problem, which may be what you want.

#### What other data readers exits in the CIL? What if I need a new kind of data reader?
Our documentation lists the readers here: [reader documentation](https://tomographicimaging.github.io/CIL/v24.3.0/io/#read-write-acquisitiondata-and-imagedata)

We have a limited number, but are looking to expand that in the future (contributions to the codebase are welcome!)

If you know how to describe your data you can create your own geometry. This exercise [1_Introduction/exercises/03_where_is_my_reader.ipynb](https://github.com/TomographicImaging/CIL-Demos/blob/main/demos/1_Introduction/exercises/03_where_is_my_reader.ipynb) will walk you through the process but please ask on discord/user support if you need help with your own dataset.

---
#### Questions about `02_intro_sandstone_parallel_roi.ipynb`
##### What did you use to generate .mat files from a projection .tiff stack ?

The dataset used in this notebook is provided [here](https://zenodo.org/records/4912435). 

Ah yes, I (Jakob) manually read in the original dataset into MATLAB and exported as .mat file from there, originally for exercises in MATLAB. Later on this .mat was then used in these python/CIL based exercises.

##### To what resolution should we do the manual COR? 

For this excercise, have a play and see what works!  When writing the exercise we expected pixel accuracy but in reality for your own data they may need to go subpixel. 

The purpose is to get familiar with the types of artefacts that you might get if your centre of rotation is incorrect and so you can understand the benefit of an automatic processor and not doing it manually!

##### Whats the stuff on the bottom left corner of the sandstone image? Is that an image artefact or some detail of the material?
![image](https://hackmd.io/_uploads/ryV2eIxTyg.png)

The data in the corner of the reconstruction volume isn't in the field-of-view over the full rotation so this is effectively missing data. Only data that is always in view of the detector can be reconstructed fully, so typically a circle with diameter equal to the panel width. However for a region of interest scan even data within this may show artefacts.

#### One can also see small white scattered spots in the above figure. Is this an artefact or is this from the actual sample?

They look like dense features to me.

#### I'm a little confused:  The shape of the projections (i.e., 'projs.shape' is (2560,1500) ) is taken to mean 1500 projections of size 2560 pixels, but isnt a projection a 2D gadget?  Does it mean 2560-by-2560 pixels?  This notational issue comes up elsehere in that notebook as well.

So this is a parallel beam dataset and, in this notebook, we consider just a single slice of the data, so each projection is just a 1D line and we reconstruct one 2D slice. 

`proj.dimension_labels` will help you see how the data is stored.


---
#### Questions about `03_preprocessing`
##### I don't quite understand the motivation for binning the data in code block 31

For very large datasets you might bin the data in order to get a smaller dataset that is quicker (or even just possible) to reconstruct on your system.  Binning also does some averaging, so could be useful to reduce noise in the data, though see the next two sessions for other ways to deal with noisy images. 


### :open_file_folder: `1_introduction/exercises`
---
#### Questions about: `01_intro_seeds_conebeam.ipynb`
##### Add your question here


#### So far we've looked at Zeiss and now Nikon ... others?  Specifically, ThermoFisher Heliscan? Waygate?

We currently don't have readers for those formats. We have a reader for TIFF data as well though. Later you'll have the chance to do an exercise 03_where_is_my_reader which takes you through setting up the geometry in CIL in the case where we don't have a reader. We are aiming to expand to having readers of more formats in the future and welcome contributions from users!

#### How would we modify the code to use Astra instead of Tigre?

Good question! Instead of the FDK implemented in the CIL recon class you could use the CIl astra plugin and the FBP reconstruction from there https://tomographicimaging.github.io/CIL/nightly/plugins/#id6. 

You may need to reorder your data for astra using the reorder function https://tomographicimaging.github.io/CIL/nightly/framework/#cil.framework.AcquisitionData.reorder. 


---
#### Questions about `02_preprocessing_seeds_conebeam.ipynb`
##### What's the physical meaning of the Dark Field? Why do we included it in the correction?

The dark field is a measurement when the beam is off (dark), this adds an offset to your measured data (i.e. a non-zero background).

The dark field corrects for noise which is inherent to the detector even when it's not collecting data. This includes things like shot noise, electronic noise, etc

#### Is normalisation useful for salt and pepper noise? 
Yes, salt and pepper noise can also be called impulse noise and includes sparsely occurring black and white pixels. It can be caused by malfunctioning detector pixels which can be corrected by normalisation using the dark and light fields. 

#### Is salt and pepper noise the same as Poisson noise? 

No, they are not the same distribution. 
 Salt and pepper noise, also known as impulse noise, appears as randomly scattered black and white pixels, while Poisson noise, or shot noise, is a type of noise related to the discrete nature of light and is characterized by fluctuations in the number of photons detected. 
So salt and pepper noise might be broken pixels on a detector while Poisson noise is more likely caused by not enough flux or inefficient detectors


#### Is there a way to renormalize projection who have irregular vertical fluctuations ? Like DMM-induced stripes for example 

I am not sure what DMM-induced stripes are. However, our flux normaliser can be used to normalise shot to shot variations in flux https://tomographicimaging.github.io/CIL/nightly/processors/#flux-normaliser. The ring remover, https://tomographicimaging.github.io/CIL/nightly/processors/#ring-remover, will also removes vertical stripes from acquisition data using the algorithm in https://doi.org/10.1364/OE.17.008567.

#### Can we do two ROI scans and then merge them in reconstruction?
In one of our user showcases we demonstrate how we set up an offset CT geometry, with an object coming in and out of the field of view as it rotates. For more information see here https://github.com/TomographicImaging/CIL-User-Showcase/tree/main/009_offset_CT_apple


#### How can we find the 'angle' to set the centre of rotation offset ?

The 'angle' is used when the rotation axis is not the same offset in each row of data. i.e. it's rolled with respect to the detector. You can fit the offset in two rows and calculate the angle, or use `set_centre_of_rotation_by_slice` to leave CIL to calculate the offset and angle.

You might be able to use one of the CIL centre of rotation methods to find the angle Processors — CIL 24.3.0 documentation.


#### With respect to 02_preprocessing_seeds... notebook: What is the purpose of the python snippet: data_absorption.reorder(order='tigre')  ?

CIL uses two different backends for CT projections and reconstructions, these are `tigre` and `astra`. Your data needs to be ordered in a particular way to work with these packages and it depends on which one you choose. This line reorders the data to work with tigre. If you forget this line, it is likely that your code will fail and the error message will tell you to consider using  `reorder(order='tigre')`.

## :question: Your Questions from Day 2

### General CIL and CT questions
##### I have a question concerning FBP. In a parallel configuration the FFT seem to be fast as the sampling is uniform right ? But in a cone geometry configuration the sampling because non uniform (dépends of the distance to the source) is the FFT implemented in CIL is the same for both configurations ?

The CIL [recon class](https://tomographicimaging.github.io/CIL/v24.3.0/recon/#analytical-reconstruction) FBP (for parallel-beam) and FDK (for cone-beam) performs the FFT step with geometry taken in to account so the weighting for cone-beam data is considered.

The back-projectors are then either from TIGRE or ASTRA. Currently for FDK we only support TIGRE as the backend as the FDK weighting is taken in to account.

We also wrap the algorithms implemented fully by [TIGRE](https://tomographicimaging.github.io/CIL/v24.3.0/plugins/#fbp) and [ASTRA](https://tomographicimaging.github.io/CIL/v24.3.0/plugins/#id6)
here although named `FBP` will provide geometry specific reconstruction.

##### How do we know we reached the actual minimum and not just a local valley ?

Excellent question! In CT the forward operator is linear. Choosing an objective function that is convex (like least squares) there is one unique local minimum. Therefore you can run your iterative algorithm until it stops decreasing, and the plot Edo showed flattens off. In this image the difference from the previous image is very small, suggesting the algorithm is near convergence. ![image](https://hackmd.io/_uploads/ryU_mFWaye.png)

##### Do you ever use a non-convex objective which has more than one minimum?

CIL is mostly built and designed for linear operators and convex objectives. However, in principle you could define your own functions or non-linear operators and set up an optimisation problem with more than one local minimum. In the case, where you initialise starts to make a difference to your final reconstruction. We have stochastic algorithms and soon to be momentum options which could help in thses cases. 

I believe the multi-bang case provided in a user showcase is nonconvex:
https://github.com/TomographicImaging/CIL-User-Showcase/blob/main/001_multibang_regularisation/Multibang_Hackathon2023.ipynb

##### Why do we care about the norm of the projection Operator ?

It is useful for setting the step sizes of the optimisation algorithms. For example, if the function we are trying to minimise is $f(x) =\|Ax-y\|_2^2$ then the Lipschitz constant of $f$ depends on the norm of the oeprator 

##### Have you done any speed benchmarking comparing to other reconstruction softwares?

We have some small discussion on FBP/FDK speed [here](https://github.com/TomographicImaging/CIL/discussions/1070). However these are using building blocks from TIGRE and ASTRA. CIL's focus is on flexibility rather than speed, letting you build and test new algorithms. The projection operators and the regularisation are the  computationally expensive parts and these can be offloaded to external packages. 

##### Can we simulate arbitrary domains or complex geometries, say a cylindrical domain for example?

Could you please elaborate on the question? Do you want to use CIL for different fields where you will need a different linear operator?

##### Are there options for doing L1 minimization either as a fidelity term or in the regularization term?


Yes, we have an L1 function in CIL and can be used in the regularisation term (you will see this today) or the fidelity term https://tomographicimaging.github.io/CIL/nightly/optimisation/#cil.optimisation.functions.L1Norm


##### Could you give a quick overview of the ASTRA and TIGRE toolboxes, are they interchangeable, I mainly wanted to understand when do you choose either of these.

Both packages are designed and optimised to solve the same problem. It's impossible to say which you should use, but maybe you can consider license (ASTRA is GPLv2 vs TIGRE is BSD), ease of installation, documentation/publications, features offered (i.e. ASTRA have some 2D CPU support) and speed and memory use.

In CIL ASTRA and TIGRE plugins are nearly completely interchangeable.

#### How does the version of algorithms used here for the linear solvers differ from MATLAB implementation of it.

I would hope that mathematcally the algorithms are identical. The idea behind the optimisation framework for CIL is to allow easy access to CT projectors and geometry using the ASTRA and TIGRE backends. We also want the optimisation framework to be very flexible, with a near-math syntax so users can quickly protytpe a range of optimisation objectives and optimisation algorithms to see what works for their data. And of course, CIl is mostly python. 

#### Is it possible to add your own regularization functions?

Yes, there are a range of other regularisation functions in CIL including L1, TV, Wavelet, 2-norm and more. We are always keen to help users to develop their own regularisation functions and some of our [user showcases](https://github.com/TomographicImaging/CIL-User-Showcase) show custom functions e.g. https://github.com/TomographicImaging/CIL-User-Showcase/tree/main/001_multibang_regularisation or https://github.com/TomographicImaging/CIL-User-Showcase/tree/main/013_anisotropic_regularization_for_FILD_measurements 

#### Does the initial guess influence the convergence of the regularized algorithms. Also, how can we fine tune the regularization parameters. Is it possible to give a regualrized algorithm an already computed FBP solution ? Or will it make the algorithm diverge ? 

For all of the optimisation objectives in the training and most created by CIL functions, the objective is convex which means there is only one minimum and it doesn't matter where you start, you should converge to the same place. Different starting points might give quicker convergence speeds. 

Choosing regularisation parameters is very difficult and trying lots of different values can be computationally and time  expensive. For one example of automatically choosing a regularisation parameter, see https://github.com/TomographicImaging/CIL-User-Showcase/tree/main/012_wavelet_sparsity_controlled_regularization

#### have you considered adding nonconvex regularisation capabilities?
Good question. In general our focus is on CT reconstruction problems, which are linear and thus generally have convex  optimisation objectives. Our algorithms can be used for non-convex objectives but most convergence bets are off. 

One of our user showcases looks at multi-bang regularisation, useful for denoising discrete data: https://github.com/TomographicImaging/CIL-User-Showcase/tree/main/001_multibang_regularisation

#### Stochastic algorithms? 

Stochastic intro: https://arxiv.org/pdf/2406.15159 and CIL documentation https://tomographicimaging.github.io/CIL/nightly/optimisation/#approximate-gradient-methods  and an old video https://www.youtube.com/watch?v=6yxOw0yFBjg&list=PLTuAla-OP8WXzK7PILTErRrG4iTN9v_yP&index=4

---
### Technical questions

##### I installed CIL on a remote system that I have access to but some of the older notebook demonstrations seem to break in several different places - for example deriv2 (and others).  (https://tomographicimaging.github.io/CIL/v24.3.0/demos/deriv2_cgls/ )Are they out of date?
We aim to keep all the notebooks in the CIL Demos (https://github.com/TomographicImaging/CIL-Demos) up to date with the latest versions of CIL (there is currently one exception). The notebook linked is part of out CIL User Showcase (https://github.com/TomographicImaging/CIL-User-Showcase/tree/main/003_1D_integral_inverse_problem) which are only checked with the version of CIL that was used when they were developed, in this case v23.0.1. However, I think we'd forgotten this is linked as a tutorial in the documentation so we will look at updating it (we opened a bug for you: https://github.com/TomographicImaging/CIL/issues/2119).


#### Problem when loading a tif file using PIL
I have a tif slice that I wanted to load using the TIFF Reader which is based on Pillow, if I use the tiffile module, the file is read correctly 
For the same file 
```python
import tifffile
data = tifffile.imread(filename)
```
works fine. But the PIL can't read the image. I get this error: `"UnidentifiedImageError: cannot identify image file"`

When you say "the TIFF Reader which is based on Pillow" - do you mean the CIL TIFFStackReader? 
https://tomographicimaging.github.io/CIL/nightly/io/#cil.io.TIFFStackReader

Is your data a single tiff file or a stack of tiffs?

Answer: I have a folder containing a stack of files. Yes the error comes from the PIL which is used by CIL's TIFFStackReader

I think the easiest is if you can share one such file with us.

Thank you. You can download the file from this links
https://limewire.com/d/rgMFr#R2Ynkzk77E

*If you can read in your data to a numpy array then it's best you continue to use tiff file as you know it works for your data. Tiffs can contain almost any form of data and not all readers will be implemented for every case.*

Alright, Thanks. I will define all the setup starting from the numpy array. 


---
### :open_file_folder: `1_Introduction`

#### Questions about `04_FBP_CGLS_SIRT.ipynb`
##### What method do you use to discretize the source-to-detector line for reconstruction? Siddon 1985, perhaps?  Or something newer, faster?

We don't have CIL projectors but allow users to choose backends from [ASTRA-toolbox](https://astra-toolbox.com/) or [TIGRE](https://github.com/CERN/TIGRE/). 

The CIL wrappers for TIGRE let you select the direct method (foward projection) as `Siddon`, or `interpolation` https://tomographicimaging.github.io/CIL/nightly/plugins/#projection-operator
The adjoint (back projection) is weighted to mirror the interpolated method. 
TIGRE have published on their projectors https://github.com/CERN/TIGRE/blob/master/Frontispiece/Further_reading.md

ASTRA don't have a publication on their projectors as far as I know, so this would have to be something you investigate in their code.

##### How to remove noise from the SIRT and CGLS reconstruction?

SIRT and CGLS exibit semi-convergence behaviour, which manifests as initially fitting the solution well and then overfitting to the noise in the data.   Early stopping, pausing the algorithms after a few iterations, can give you a good reconstruction.  In the next session we will look at regularisation which  can prevent th semi-convergence beahviour and is an alternative to early stopping. 

##### Any good bibliographical reference for SIRT? I liked that they were included in yesterday's material

https://tomographicimaging.github.io/CIL/nightly/optimisation/#cil.optimisation.algorithms.SIRT



##### Why the constrained SIRT reconstruction result still have negative voxels?
It doesn't, which we can see in the final line profile graph - the purple line does not go below 0. Perhaps what's confusing is on the colour bar it goes below zero but this was so that we had the same scale for each of the 4 plots - we don't actually see any pixels of the colours below 0 in the image for SIRT:

![image](https://hackmd.io/_uploads/rksyIKZpJx.png)


##### Is it possible to use SIRT for some other type of minimization problem? In the context of CT what are the possible type of Operators available in CIL?

Yes, SIRT looks to minimise objectives of the form $\|Ax-b\|_2^2$ and $A$ could be a CT projection operator (from Astra or Tigre in CIL) or it could be a mask, blur or the identity operator, for example, all of which are available in CIL. For more examples of non-CT inverse problems, see the next session.  


##### Is there any reason to start ig at zero rather than at the FBP reconstruction for example ?

The algorithms does not necessarily converge faster to the solution even if it starts from close to it. Also, the FBP/FDK solution is not quite the right least-squares solution.

##### Are there any algorithms to determine when to stop iterating?

A paper on stopping rules: https://www.sciencedirect.com/science/article/pii/S0141635925000315?via%3Dihub

#### Does increasing the number of iterations increase the resolution?

If you define resolution to be pixels per a given distance then no, the image geeometry is constant with the number of iterations. However, if you define resolution to be the amount of detail int the image then in general, yes, most iterative algorithms fit the broad featues in the early iterations and then in later iterations make smaller changes.  

#### How do we know when to stop iterating?

Good question! One way is to plot the objective value, as we do in the notebook CIL-Demos/demos/1_Introduction/04_FBP_CGLS_SIRT.ipynb in cell: 
![image](https://hackmd.io/_uploads/SyuSat-aye.png).

If the objective value stops decreasing, it is likely that the algorithm is converging.  

Tomorrow we will see CIL callbacks which an be used to automatically stop iterations if a certain criteria is met. 

#### The results at the bottom seem to suggest that SIRT and CGLS are superior to FBP (evidenced by the line profile and the difference from ground truth graphs), but my breakout room thought that the FBP reconstruction produced a clearer image and we could apply a noise reduction filter to improve it. Could you comment about what the conclusion of the exercise should have been? 

The eternal question in imaging is how to you tell what is a "good" image and the response is always, it depends what you are looking for! If your FBP reconstruction is good, then it is fine to stop there! I would say the risk of a denoising filter on top of the FBP image is that your reconstruction may no longer match your data. 

The SIRT and CGLS algorithms both minimise a least squares objective which is likely to blurr the edges in the reconstructed image and may be why the FBP image looks clearer. In the next session we will see examples of regularisers such as TV regularisation which can deal with the blurry edges. 

---
#### Questions about `05_usb_limited_angle_fbp_sirt.ipynb`
##### Add your question here

##### Could x-ray scanning the USB cause loss of data on it?
Yes x-rays can definitely cause damage to electronics. I think at this energy the total dose is unlikely to be a problem but perhaps you could have a problem with single events changing data?

##### Is there anything we can do about these black stripes coming from the high attenuating regions ?

The black regions could be caused by photon starvation, where the highly attenuating regions absorb most of the x-ray beam and therefore there is very little  information about the area in the shadow of these objects. The information is physically missing and so only by adding in more information can we make a difference to the reconstruction. For example, a non-negativity constraint could help or someting like TV regularisation  


##### Could a reference be provided for the implementation of the FISTA solver?

https://tomographicimaging.github.io/CIL/nightly/optimisation/#cil.optimisation.algorithms.FISTA

Amir Beck and Marc Teboulle. A fast iterative shrinkage-thresholding algorithm for linear inverse problems. SIAM Journal on Imaging Sciences, 2(1):183–202, 2009. URL: https://doi.org/10.1137/080716542, arXiv:https://doi.org/10.1137/080716542, doi:10.1137/080716542.



Amir Beck and Marc Teboulle. Fast gradient-based algorithms for constrained total variation image denoising and deblurring problems. IEEE Transactions on Image Processing, 18(11):2419–2434, 2009. doi:10.1109/TIP.2009.2028250

##### Are there CIL tools available for dual-energy reconstruction? (E. Machorro, PNNL)

Out of the box tools are not available but users have done dual-energy reconstruction with CIL in the past. Some of the notebooks in CIL-Demos/demos/3_Multichannel might be useful for you. 

It is something we would be happy to chat to you about

#### What tools are available to account for scattering or for polychromatic spectrums/x-rays sources such as in commerical CT systems? Is this discussed in the  various CIL workshops and conferences?

We currently do not have tools for scattering or for polychromatic spectrums/x-rays sources. beam hardening correction, in particular, has been on our wish list for some time 



---
### :open_file_folder: `binder`

#### Questions about: `PyData22_deblurring.ipynb`
##### Add your question here

#### What tools are available to estimate the regularization parameter to use in the various solvers?  GCV perhaps - others?


An excellent question. Something like GCV needs you to solve the optimisation problem for a range of different regularisers which is hugely computationally intensive for large scale inverse problems, like CT. We are considering implementing hybrid Krylov methods in Cil and the one of our user showcases demonstrate choosing the reguarisation parameter for wavelet regularisation using a  control loop: https://github.com/TomographicImaging/CIL-User-Showcase/tree/main/012_wavelet_sparsity_controlled_regularization


#### Which solvers are available in CIL?

There's a list in our documentation:
https://tomographicimaging.github.io/CIL/nightly/optimisation/

An incomplete list ![image](https://hackmd.io/_uploads/SyAiaqW6kg.png)


---
### :open_file_folder: `2_Iterative`

#### Questions about: `01_optimisation_gd_fista.ipynb`
##### Add your question here


---
#### Questions about: `05_Laminography_with_TV.ipynb`
##### Add your question here

##### What does tilt mean ? Is it at defined at projection 0 ?

![image](https://hackmd.io/_uploads/B1qtZhW6Je.png)

In CT the rotation axis is aligned with the z-axis in the above image. By 'tilting' the stage we can scan samples that are very challenging for CT (PCBs are a big usecase).

In CIL we define the system first, then add the sample rotation. This makes it very easy to set up the geometry in an intuitive way with reference to your CT scanner.


##### Is there a method to minimize some metric (SNR for example) to actually find the tilt angle ? For correction purposes

Ths is something we are considering in CIL but is not yet implemented. There is a large number of possible degrees of freedom and the cost of fitting increases non-linearly with each additional dimension. 

##### Is the "sinogram sampling" accounting for this tilt angle ? I might be confused sorry
Yes the reconstruction takes into account the tilt because the aspect ratio of the projection is altered by the tilt. 

---
### :open_file_folder: `3_Multichannel`

#### Questions about: `03_Hyperspectral_reconstruction.ipynb`
##### Add your question here

##### What would happen with more projections & less energy bins ?

More projections and fewer energy bins would give a higher flux per energy bin and this could mean (provided there was still sufficient projections) a better result when reconstructing each energy bin indvidually. Too few projections would leead to   limited angle artefacts in the reconstruction. Reduced energy bins might mean that the reconstructions of neighbouring energy bins might not be similar enough for the regularisation along energy channels to be useful. 

---
### :open_file_folder: Any other notebook questions
Working on other exercises today? Ask your questions here
##### Add your question here

##### What are the main differences between ASTRA, TIGER, and CIL? In other words, what are the main features - broadly - in CIL but might not be easily accessable or not available from TIGRE and ASTRA? 

CIL let's you define your geometry once, and then you can work with tigre or astra and we handle the conversion. This can help new users get started as there is consistency. We only wrap the Projection Operators and FBP. We will look to doing the same with other backends in the future (OpenRTK, LEAP).

We aim to let you plug-and-play to build new optimisation algorithms on your data which can make it fast to test soltuions. TIGRE has some algorithms implemented very efficiently but ridgidly, so that might impact your decision.

Our optimisation toolkit is also designed to be usable for other  inverse problems and we actively collaborate with SIRF and STIR, open source packages for PET, MRI and SPECT. One of our user showcases demonstrates has an example reconstructing [fast-ion loss detector (FILD)](https://github.com/TomographicImaging/CIL-User-Showcase/tree/main/013_anisotropic_regularization_for_FILD_measurements) measurements. Other collaborators have also worked on SAR or RADAR examples as well. 

CIL is actively developed and maintained with a user community and regular user support sessions. 


##### Are helical acquisition geometries - or other types of not un-common acquisition geometries available as options in setting up the reconstructions and regularization operations/methods?  IS the user able to set somethign like that up? ASTRA allows this I think,  yes.

Currently we only support rigid-body rotation set-ups. But the next release will add support for per-projection cone-beam geometry with ASTRA. We will extend this to use TIGRE in the following release.

Currently you could set this up using a block-geometry, but the foward/back projection steps will be costly.