---
# System prepended metadata

title: SIRF training course @ PSMR/TBPET Isola d'Elba 2024

---

# SIRF training course @ PSMR/TBPET Isola d'Elba 2024

This page currently mostly contains information for SIRF/CIL training in general. Not all material is relevant for the training school at PSMR 2024, but is still provided in case you want to explore more. In particular, CT reconstruction will not be covered, and MR reconstruction only briefly.

This page contains supporting material in general, as well as more specifics on the software.

## New SIRF Discord server

https://discord.gg/TdNdqcmzVW




## Schedule
- 8.30 - 10.30
  - [School introduction](http://www.ccpsynerbi.ac.uk/wp-content/uploads/2024/05/PSMRTBP_2024-intro.pdf)
  - Introductory lectures
    - [PET+SPECT physics and SIRF](http://www.ccpsynerbi.ac.uk/wp-content/uploads/2024/05/PSMRTBP_2024_PET_SPECT.pdf) (Kris)
    - LAFOV challenges (Nikos)
    - [MR and SIRF](http://www.ccpsynerbi.ac.uk/wp-content/uploads/2024/05/MR_Recon_SIRF_CKolbitsch.pdf) (Christoph)
    - [Machine Learning](http://www.ccpsynerbi.ac.uk/wp-content/uploads/2024/05/ML_recon_hands_on_georg_schramm.pdf) (Georg)
  - Project descriptions
    - Introduction to SIRF and image reconstruction (Nicole)
    - LAFOV (Nikos)
    - Using anatomical guidance (Sam or Margaret)
    - ML and PET list-mode reconstruction (Georg)
    - Potential interactions between projects
- 10.30 - 11.00	Coffee break
- 11.00 - 12.40
   - Cloud access demo (Edo)
   - Group allocation and project work
   - Project status reports from each group
- 12.40 - 15.30 Lunch break
- 15.30 - 17.10
   - Group re-allocation if required and project work
- 17.10 - 17.40 Coffee break
- 17.30 - 19.00
  - Project work
  - Project status reports from each group
  - Summary and outlook

## Supporting Material

Below is a set of links towards recorded lectures or reading material which we hope will be useful for course participants. Please note that we will not cover this material ourselves (except very briefly).

### PET
- [PET acquisition, backprojection, sinograms](https://www.youtube.com/watch?v=8LTi0auyz2k)
Andrew Reader
- [Time of Flight PET](https://kuleuven.mediaspace.kaltura.com/media/Lecture+on+time-of-flight+in+positron+emission+tomography+%28Prof.+Johan+Nuyts%29/1_zqpnc5gw)
Johan Nuyts
- [PET acquisition modelling](https://liveuclac-my.sharepoint.com/:v:/g/personal/rmhathi_ucl_ac_uk/ERyfdeFKaptFiVv2hbJt89ABXSU2847gnOTgIGYFVEMATA?e=RedTba), including normalisation, scatter etc
Kris Thielemans

### MR
- [Basics of MRI and MR image reconstruction](https://www.youtube.com/watch?v=xCv38thzljw)
**Gastao Cruz**. Overview of the basics of MRI, from nuclear spins and magnetic fields to the sampling requirements for k-space. Also advanced topics such as reconstruction from undersampled data (GRAPPA, SENSE) are discussed. 
- [MR image reconstruction using SIRF](https://www.youtube.com/watch?v=vC66LgPfRNM) 
**Christoph Kolbitsch**. MR image reconstruction (k-space sampling, coil sensitivity maps, GRAPPA) and how it can be done in SIRF.


### CT
- [CT basics](https://youtu.be/PI6vgzg5l7E)
Elizabeth Edney
- [Physics of Computed Tomography](https://youtu.be/-AfF3O1_duw)
Daniel Wessell

### Machine Leaning in Image Reconstruction
- [Basics on how to train ML models using pytorch](https://pytorch.org/tutorials/beginner/basics/intro.html) containing an overview on tensors, data sets and loaders, building neural networks, torch's autograd, and training (optimizing) model weights
- [A deeper dive into pytorch's autograd](https://pytorch.org/tutorials/beginner/blitz/autograd_tutorial.html#differentiation-in-autograd) which is useful to understand when implementing the forward and backward pass for custom layers.
- [2023 MIC Image Reconstruction and AI short course slides and minimal examples](https://github.com/gschramm/2023-MIC-ImageRecon-Shortcourse/tree/main) showing how to use custom linear operators (e.g. PET projectors) with pytorch's autograd to build "reconstruction" networks

### MLAA
(Note: project not run at PSMR 2024)
- [MIC 2015 short course on image reconstruction (ppt presentation)](http://www.ccpsynerbi.ac.uk/wp-content/uploads/2024/04/MIC2015_shortcourse_jn.pptx) contains some details on joint estimation (slides 106 onward)
- [Simultaneous maximum a posteriori reconstruction of attenuation and activity distributions from emission sinograms](https://ieeexplore.ieee.org/document/774167) (non-TOF MLAA)
J. Nuyts, P. Dupont, S. Stroobants, R. Benninck, L. Mortelmans and P. Suetens, "Simultaneous maximum a posteriori reconstruction of attenuation and activity distributions from emission sinograms," in IEEE Transactions on Medical Imaging, vol. 18, no. 5, pp. 393-403, May 1999, doi: 10.1109/42.774167. Paper can be accessed for personal use [here](https://perswww.kuleuven.be/~u0015224/publications/jn_ieeetmi99.pdf).
- [Simultaneous Reconstruction of Activity and Attenuation in Time-of-Flight PET](https://ieeexplore.ieee.org/document/6264102)
A. Rezaei et al., "Simultaneous Reconstruction of Activity and Attenuation in Time-of-Flight PET," in IEEE Transactions on Medical Imaging, vol. 31, no. 12, pp. 2224-2233, Dec. 2012, doi: 10.1109/TMI.2012.2212719. Paper can be accessed for personal use [here](https://perswww.kuleuven.be/~u0015224/publications/Ahmad_TOF_MLAA.pdf).

### Synergistic Deconvolution with PET
- We'll begin by loosely following some of the work in this preprint: [Anatomically-guided deconvolution of PET using directional total variation regularization](https://www.medrxiv.org/content/10.1101/2023.04.23.23289004v1), A.Gillman et al.
- A good book chapter on structural priors [Multi-modality Imaging with Structure-Promoting Regularizers](https://link.springer.com/referenceworkentry/10.1007/978-3-030-98661-2_58), M. Ehrhardt
- PDHG seminal paper [A First-Order Primal-Dual Algorithm for Convex Problems with Applications to Imaging](https://link.springer.com/article/10.1007/s10851-010-0251-1), Chambolle & Pock


## Reading material on software and programming
- If you are new to Python and the Unix terminal, please check the excellent material on https://software-carpentry.org/lessons/. There are some additional links in the [Appendix of our starting guide for participants](https://github.com/SyneRBI/SIRF-Exercises/blob/master/DocForParticipants.md#appendix).
- [SIRF/CIL Docker on Mac video](https://mediacentral.ucl.ac.uk/Player/C1eAhHAi) and [PowerPoint](https://mediacentral.ucl.ac.uk/assoc_files/C1eAhHAi_0.pptx?token=16abhFB8)
- The SIRF paper:
Ovtchinnikov, Evgueni, Richard Brown, Christoph Kolbitsch, Edoardo Pasca, Casper da Costa-Luis, Ashley G. Gillman, Benjamin A. Thomas, et al. ‘SIRF: Synergistic Image Reconstruction Framework’. Computer Physics Communications 249 (1 April 2020): 107087. https://doi.org/10.1016/j.cpc.2019.107087. Link for the [accepted version](https://discovery.ucl.ac.uk/id/eprint/10087933/)
- The "SIRF and motion correction" paper:
Brown, Richard, Christoph Kolbitsch, Claire Delplancke, Evangelos Papoutsellis, Johannes Mayer, Evgueni Ovtchinnikov, Edoardo Pasca, et al. ‘Motion Estimation and Correction for Simultaneous PET/MR Using SIRF and CIL’. Philosophical Transactions of the Royal Society A: Mathematical, Physical and Engineering Sciences 379, no. 2204 (23 August 2021): 20200208. https://doi.org/10.1098/rsta.2020.0208.
- The CIL 1 paper: Jørgensen JS et al. 2021 Core Imaging Library Part I: a versatile python framework for tomographic imaging. Phil. Trans. R. Soc. A 20200192. [DOI: 10.1098/rsta.2020.0192](https://doi.org/10.1098/rsta.2020.0192)
- The CIL 2 paper: Papoutsellis E et al. 2021 Core Imaging Library – Part II: multichannel reconstruction for dynamic and spectral
tomography. Phil. Trans. R. Soc. A 20200193. [DOI: 10.1098/rsta.2020.0193](https://doi.org/10.1098/rsta.2020.0193)

## Notebooks with exercises

We have prepared a set of notebooks with examples and exercises on how to use SIRF and CIL. They can be run at any time. Our main repository is [SIRF-Exercises on GitHub](https://github.com/SyneRBI/SIRF-Exercises/blob/master/README.md) which contains instructions on how to run/install etc.

Below we give a brief overview of what is available

### General

* Start with the [Introductory notebooks](https://github.com/SyneRBI/SIRF-Exercises/blob/master/notebooks/Introductory/README.md)
* [image geometry notebooks](https://github.com/SyneRBI/SIRF-Exercises/tree/master/notebooks/Geometry/README.md) (optional but recommended for SIRF and medical imaging)
* [registration notebook](https://github.com/SyneRBI/SIRF-Exercises/tree/master/notebooks/Reg) (optional for the school)


### Basics for different image modalities
- [PET README](https://github.com/SyneRBI/SIRF-Exercises/tree/master/notebooks/PET/README.md)
- [MR README](https://github.com/SyneRBI/SIRF-Exercises/blob/master/notebooks/MR/README.md)
- [SPECT README](https://github.com/SyneRBI/SIRF-Exercises/tree/master/notebooks/SPECT/README.md)
- [CIL README](https://github.com/TomographicImaging/CIL-Demos/blob/main/demos/README.md)

### Advanced reconstruction
- [Deep learning reconstruction for PET](https://github.com/SyneRBI/SIRF-Exercises/blob/master/notebooks/Deep_Learning_PET/README.md)
- [Deep learning listmode reconstruction for PET](https://github.com/SyneRBI/SIRF-Exercises/blob/master/notebooks/Deep_Learning_listmode_PET/README.md)
- [Synergistic reconstruction](https://github.com/SyneRBI/SIRF-Exercises/tree/master/notebooks/Synergistic/README.md)
- [Synergistic deconvolution with PET](https://github.com/SyneRBI/SIRF-Exercises/blob/master/notebooks/synergistic_deconvolution/README.md)

### Some sirf.STIR pecularities

- To do simulations, you need to start from “template” `AcquisitionData`
  - Read one from file
  - Construct one based on a particular scanner (together with some extra parameters)

  Note that the sinogram-data in this “template” will not be used for the simulation (or even not exist!)

- sirf.STIR image dimensions have restrictions for a scanner:
  - axial spacing and number of slices is fixed
  - "in-plane" spacing and number of pixels is arbitrary in PET, but not in SPECT.
  - exercises are set-up such that images and acquisition data are compatible.
  - You can create an `ImageData`  from an `AcquisitionData`, which is guaranteed to work.

- STIR writes (too much) diagnostic output by default to the terminal but some of this is hidden when using Jupyter notebooks, and can also slow things down.
  - You can redirect it to files or discard (as illustrated in some notebooks), e.g.
    ```python
     _ = sirf.STIR.MessageRedirector('info.txt', 'warnings.txt', 'errors.txt')
    ```
  - You can reduce/increase number of `INFO` statements
    ```python
    sirf.STIR.set_verbosity(0)
    ```
## Introductory notebooks - order
**Simulating PET/SPECT acquisitions with SIRF**

- /notebooks/PET/display_and_projection.ipynb
- /notebooks/PET/image_creation_and_simulation.ipynb
- /notebooks/SPECT/SPECT_acquisition_model.ipynb

**Implementing reconstruction algorithm from formula “manually”**
- /notebooks/PET/DIY_OSEM.ipynb

**Using SIRF implemented functions to reconstruct PET data**
- /notebooks/PET/OSEM_reconstruction.ipynb
- /notebooks/SPECT/SPECT_OSEM_measured_data.ipynb

*Bonus*
- Reconstructing measured data
    /notebooks/PET/reconstruct_measured_data.ipynb
    /notebooks/SPECT/SPECT_OSEM_measured_data.ipynb
- Regularized Reconstruction
    /notebooks/PET/MAPEM.ipynb




# End of the day images


**Synergistic Deconvolution**
- Implemented MR guided dTV with SIRF and CIL
![PSMR_dtv](https://hackmd.io/_uploads/HJ9InswmC.png)
- Worked through synergistic deconvolution
![PSMR_synergistic](https://hackmd.io/_uploads/HkNB0ovQ0.png)


**Machine Learning + PET reconstruction**
- Implement an OSEM (listmode) pytorch layer that is compatible with pytorch's autograd magic (compatible with gradient back propagation)
![torch_OSEM_layer](https://hackmd.io/_uploads/S18nTjDQR.png)
- we trained a minimal "dummy" unrolled varitaional "denoising recon network" (on 1 data set :) - the training loss decreased :) 
![varnet_training_loss](https://hackmd.io/_uploads/S1ZVy2v7C.png)



**LAFOV**
- Tested sensitivity matrix tapering with TOF![myrgztdv](https://hackmd.io/_uploads/rJv10oPmC.png)

**Introduction DIY-MLEM (SPECT)**
* Phantom image
![immagine](https://hackmd.io/_uploads/ByZ9xnvXA.png)

* Reconstructed image after 3 iterations
![Schermata del 2024-05-19 18-48-30](https://hackmd.io/_uploads/B1SnRiw7R.png)
* Reconstructed image after 10 iterations
![immagine](https://hackmd.io/_uploads/rkL8ghDQC.png)




![IMG_2223](https://hackmd.io/_uploads/SkEMfhD7C.jpg)
