# Synthetic X-ray tomography with Julia

**URL:** <https://discourse.julialang.org/t/synthetic-x-ray-tomography-with-julia/19353>\
**Category:** Modelling & Simulations\
**Created:** [January 7, 2019, 3:23pm UTC](https://discourse.julialang.org/t/synthetic-x-ray-tomography-with-julia/19353 "2019-01-07T15:23:22Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![KirillGerke](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kirillgerke/32/11383_2.png) [@KirillGerke](https://discourse.julialang.org/u/KirillGerke)\
**Post date:** [January 7, 2019, 3:23pm UTC](https://discourse.julialang.org/t/synthetic-x-ray-tomography-with-julia/19353/1 "2019-01-07T15:23:22Z")

</div>

Dear All,

Objective: My aim is to use Julia to combine a number of complex computational tasks, one of them being creation of synthetic tomography. My search provided no results on existing Julia packages related to X-ray image reconstructions or simulating projections by modelling X-ray propagation within the studied sample.  
I need both parts actually. The objective is to input a 3D image of a sample (attenuation coefficients) and then to create projections, which i later want to reconstruct back to attenuations.

Question: I would be grateful to any links or ideas of how one could use existing Julia functions or wrappings around other codes to solve this problem from Julia.

A somewhat more detailed list of objectives:

1. Simulate point X-ray source
2. Simulate projections with all necessary physics involved based on input 3D distribution of attenuations
3. Reconstruct images from these projections

Many thanks in advance!

---

<div class="post-metadata">

**Author:** ![oatlzzvztd](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oatlzzvztd/32/3285_2.png) [@oatlzzvztd](https://discourse.julialang.org/u/oatlzzvztd)\
**Post date:** [January 7, 2019, 3:44pm UTC](https://discourse.julialang.org/t/synthetic-x-ray-tomography-with-julia/19353/2 "2019-01-07T15:44:17Z")

</div>

If I were you, I would start by wrapping [Poulson’s distributed butterfly transform](https://github.com/poulson/dist-butterfly). There’s an example there of how to calculate a generalized Radon transform. See also [the paper](https://arxiv.org/abs/1305.4650), which is slightly less enlightening if you’re not already familiar with the butterfly algorithm. You can try using CxxWrap.jl or Cxx.jl, but I don’t believe either is stable yet. If that fails, you can write a C wrapper for the C++ library, and then wrap that in Julia.

With that in mind, it should be easier to swap physical models, create synthetic data sets, perform backprojection, and etc.

Another approach would involve writing a pure Julian butterfly.

---

<div class="post-metadata">

**Author:** ![SimonW](https://avatars.discourse-cdn.com/v4/letter/s/34f0e0/32.png) [@SimonW](https://discourse.julialang.org/u/SimonW)\
**Post date:** [January 7, 2019, 9:14pm UTC](https://discourse.julialang.org/t/synthetic-x-ray-tomography-with-julia/19353/3 "2019-01-07T21:14:56Z")

</div>

I’m guessing that you have some kind of material sample (e.g. bones, rocks, concrete, metal) with known properties from real x-ray scans but you use them for model validation only since you’re probably planning to use synthetic material models in the future because they are much cheaper and allow for more controlled variations.

> [@KirillGerke](#):
>
> Objective: My aim is to use Julia to combine a number of complex computational tasks, one of them being creation of synthetic tomography.

What else are you aiming to do? Are you trying to build some multi-physics toolbox?  
If you want to do experiments with wave propagation (active/passive), then you may want to have a look at [`SeismicJulia`](https://github.com/SeismicJulia). Further you may look into meshing and FEM/CFD packages to see how you may couple them.

If you are open to a less “physics-based” approach and if you have enough data, then you may look into a machine learning solution to generate synthetic X-ray results.

---

<div class="post-metadata">

**Author:** ![KirillGerke](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kirillgerke/32/11383_2.png) [@KirillGerke](https://discourse.julialang.org/u/KirillGerke)\
**Post date:** [March 25, 2019, 4:20pm UTC](https://discourse.julialang.org/t/synthetic-x-ray-tomography-with-julia/19353/4 "2019-03-25T16:20:49Z")

</div>

Thank you for your suggestions, Guys!

Just to let you know that i found an interesting package that solves some problems i was looking for: ASTRA Toolbox ([https://www.astra-toolbox.com/](https://www.astra-toolbox.com/)).  
I could not find anything that solves all my problems stated above completely. Your solutions may work fine, but very time consuming from the programming point of view (and i have lousy programming skills).

Thank you very much for your answers,  
K.

---

<div class="post-metadata">

**Author:** ![kevinczimmerman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kevinczimmerman/32/13040_2.png) [@kevinczimmerman](https://discourse.julialang.org/u/kevinczimmerman)\
**Post date:** [August 27, 2019, 3:35am UTC](https://discourse.julialang.org/t/synthetic-x-ray-tomography-with-julia/19353/5 "2019-08-27T03:35:58Z")

</div>

I just started a package to pull the x-ray linear attenuations from the [NIST XCOM Database](https://www.physics.nist.gov/PhysRefData/Xcom/html/xcom1.html) called [Attenuations.jl](https://github.com/kczimm/Attenuations.jl). It can help you start with creating your objects that you’ll forward project.

---

<div class="post-metadata">

**Author:** ![kevinczimmerman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kevinczimmerman/32/13040_2.png) [@kevinczimmerman](https://discourse.julialang.org/u/kevinczimmerman)\
**Post date:** [February 29, 2020, 3:57pm UTC](https://discourse.julialang.org/t/synthetic-x-ray-tomography-with-julia/19353/6 "2020-02-29T15:57:14Z")

</div>

The [Attenuations.jl](https://github.com/kczimm/Attenuations.jl) package got some substantial upgrades so now it contains all materials and elements from NIST tables 2 and 4. It also uses [Unitful.jl](https://github.com/PainterQubits/Unitful.jl) for energy requests and returns linear and mass attenuation coefficients with their respective SI units.

---

<div class="post-metadata">

**Author:** ![kevinczimmerman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kevinczimmerman/32/13040_2.png) [@kevinczimmerman](https://discourse.julialang.org/u/kevinczimmerman)\
**Post date:** [February 29, 2020, 4:00pm UTC](https://discourse.julialang.org/t/synthetic-x-ray-tomography-with-julia/19353/7 "2020-02-29T16:00:25Z")

</div>

Oh, and @tim.holy made the [JuliaImages/ImageReconstruction.jl](https://github.com/JuliaImages/ImageReconstruction.jl) package and we have implemented a radon and inverse radon transform for images (not volumes) so far.

You’ll need an estimate of your x-ray source energy distribution also. [An accurate method for computer‐generating tungsten anode x‐ray spectra from 30 to 140 kV](https://aapm.onlinelibrary.wiley.com/doi/abs/10.1118/1.597953) is a commonly implemented model for computed tomography applications.

Then, you’re probably just missing the physics measurement model which depends on the type of radiation detector you’re using.

---

<div class="post-metadata">

**Author:** ![jakeoung](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jakeoung/32/10167_2.png) [@jakeoung](https://discourse.julialang.org/u/jakeoung)\
**Post date:** [July 23, 2020, 3:57pm UTC](https://discourse.julialang.org/t/synthetic-x-ray-tomography-with-julia/19353/9 "2020-07-23T15:57:55Z")

</div>

I make a Julia wrapper for ASTRA toolbox: [https://github.com/JuliaTomo/TomoForward.jl](https://github.com/JuliaTomo/TomoForward.jl)

Currently, it only supports 2D parallel or fan beam.

---

<div class="post-metadata">

**Author:** ![KirillGerke](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kirillgerke/32/11383_2.png) [@KirillGerke](https://discourse.julialang.org/u/KirillGerke)\
**Post date:** [July 23, 2020, 5:37pm UTC](https://discourse.julialang.org/t/synthetic-x-ray-tomography-with-julia/19353/10 "2020-07-23T17:37:42Z")

</div>

Wow, looks pretty useful to me! We are using python wrapping at the moment in our research… But Julia would be cool to jump to.  
Did you wrap it through python or directly cpp code?  
Looking forward for the full 3D+Cuda version!  
Thank you!

---

<div class="post-metadata">

**Author:** ![KirillGerke](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kirillgerke/32/11383_2.png) [@KirillGerke](https://discourse.julialang.org/u/KirillGerke)\
**Post date:** [July 23, 2020, 5:44pm UTC](https://discourse.julialang.org/t/synthetic-x-ray-tomography-with-julia/19353/11 "2020-07-23T17:44:30Z")

</div>

Kevin,  
Sorry i somehow missed this msg of yours.  
Thank you for the reference - i shall look into it. I am not yet sure if this will work for our porous materials microCT applications or not.  
Are you planning to finish the full 3D/Cuda versions?  
K.

---

<div class="post-metadata">

**Author:** ![jakeoung](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jakeoung/32/10167_2.png) [@jakeoung](https://discourse.julialang.org/u/jakeoung)\
**Post date:** [July 23, 2020, 8:03pm UTC](https://discourse.julialang.org/t/synthetic-x-ray-tomography-with-julia/19353/12 "2020-07-23T20:03:23Z")

</div>

Welcome! I made it for my research purpose 🙂 It is implemented by porting from the cpp code, e.g. [https://github.com/astra-toolbox/astra-toolbox/blob/master/include/astra/ParallelBeamLinearKernelProjector2D.inl](https://github.com/astra-toolbox/astra-toolbox/blob/master/include/astra/ParallelBeamLinearKernelProjector2D.inl)

It’s nice to see people working on tomography. Yes, if I do for 3D later, I will reply here!
