# How to do a standard FDK using itk-rtk in python.

**URL:** https://discourse.itk.org/t/how-to-do-a-standard-fdk-using-itk-rtk-in-python/6141
**Category:** Beginner Questions
**Tags:** python, rtk
**Created:** [August 11, 2023, 2:50pm UTC](https://discourse.itk.org/t/how-to-do-a-standard-fdk-using-itk-rtk-in-python/6141 "2023-08-11T14:50:40Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Victor\_Hu](https://discourse.itk.org/user_avatar/discourse.itk.org/victor_hu/32/3631_2.png) [@Victor\_Hu](https://discourse.itk.org/u/Victor_Hu)
#### Post date: [August 11, 2023, 2:50pm UTC](https://discourse.itk.org/t/how-to-do-a-standard-fdk-using-itk-rtk-in-python/6141/1 "2023-08-11T14:50:40Z")

</div>

I’m new to ITK and RTK. I’m so sad since there are not enough docs of RTK (in python). What I want to do is do a simple FDK reconstruction using a number of tif images with some geometry parameters. There are 360 tif files from 360 angles. I visited RTK maillist and it seems that I should use `rtk.ProjectionReader`? But I’m not sure how to use it in python.

I’ve read the example ‘FirstReconstruction.py’. However, the example just use constant white images to reconstruct. I’d like to load my own data(a number of .tif images at ‘./img/’). Even if I tried to load them using `itk.ImageSeriesReader`, I failed due to some strange errors like ‘writer.Update()’'s runtime error: ITK ERROR: ImageSeriesReader(0x4c97f80): At least one filename is required.

In additon, I just couldn’t figure out why `rtk.RayEllipsoidIntersectionImageFilter` is used and how to choose its parameters. Is are any comments available? In fact, what I have is only the geometry parameters.

Thanks in advance.

* * *

By the way, I tried to build RTK-2.4.1 in c++ at first, after successfully building ITK-5.3.0. But I was encountered with error:  
‘CMake Error at CMakeLists.txt:215 (message):  
Modules can only be built against an ITK build tree; they cannot be built  
against an ITK install tree.’  
even I set ITK\_DIR=path/to/ITK-5.3.0/build.

After setting ITK\_SOURCEE\_DIR=path/to/ITK-5.3.0, anthor error occured:  
‘CMake Error at utilities/lp\_solve/CMakeLists.txt:105 (itk\_module\_target\_export):  
Unknown CMake command “itk\_module\_target\_export”.’

I tried to search solutions but it didn’t help. Therefore I quit c++ and turned to python. I’d appreciate it if any suggestions for building RTK-2.4.1 in c++.

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [August 11, 2023, 4:47pm UTC](https://discourse.itk.org/t/how-to-do-a-standard-fdk-using-itk-rtk-in-python/6141/2 "2023-08-11T16:47:21Z")

</div>

@simon.rit might have some pointers.

---

<div class="post-metadata">

### Author: ![simon.rit](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/f08c70/32.png) [@simon.rit](https://discourse.itk.org/u/simon.rit)
#### Post date: [August 13, 2023, 1:25pm UTC](https://discourse.itk.org/t/how-to-do-a-standard-fdk-using-itk-rtk-in-python/6141/3 "2023-08-13T13:25:58Z")

</div>

Don’t be sad… We are doing our best. RTK questions are still best answered on RTK’s mailing list. Your problem is reading the images. There are examples for `ProjectionsReader` on the mailing list archives, e.g. [here](https://www.creatis.insa-lyon.fr/pipermail/rtk-users/2023-March/001955.html). You error message with `itk.ImageSeriesReader` indicates that you have not set properly the image file names with `SetFileNames`.

`rtk.RayEllipsoidIntersectionImageFilter` is used to simulate projections of ellipsoids. See documentation [here](http://www.openrtk.org/Doxygen/classrtk_1_1RayEllipsoidIntersectionImageFilter.html).

I don’t understand your error message for compilation. If your C++ build was correct, it should not occur, see code [here](https://github.com/RTKConsortium/RTK/blob/master/CMakeLists.txt#L204-L207). You can also just try to active RTK compilation at the same time as ITK, see [INSTALLATION.md](https://github.com/SimonRit/RTK/blob/master/INSTALLATION.md).

---

<div class="post-metadata">

### Author: ![Victor\_Hu](https://discourse.itk.org/user_avatar/discourse.itk.org/victor_hu/32/3631_2.png) [@Victor\_Hu](https://discourse.itk.org/u/Victor_Hu)
#### Post date: [August 17, 2023, 2:12pm UTC](https://discourse.itk.org/t/how-to-do-a-standard-fdk-using-itk-rtk-in-python/6141/4 "2023-08-17T14:12:29Z")

</div>

Thanks for your reply!

I’ve referred to the example for PorjectionsReader and rewritten my code. However the reconstrction result is empty(all tif files are white), which confused me a lot. The python file is attached, where some questions are brought up (Q1, Q2, Q3). In Q1, I’m not sure whether the geometry data is enough. Are there some angles needed but I don’t offer? See Q2 and Q3 in python file’s comment.

In addition, I want to save the reconstruction result as a volume data in .raw format. However, it seems not feasible so I saved it as TIF. Any suggestions?

Thank you.

Simon Rit via ITK \<[noreply@discourse.itk.org](mailto:noreply@discourse.itk.org)\> 于2023年8月13日周日 21:27写道：

[FirstReconstruction.py](https://discourse.itk.org/uploads/short-url/b4ehgwtlVl5XAC68CBHSaXbRjnS.py) (2.25 KB)

---

<div class="post-metadata">

### Author: ![simon.rit](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/f08c70/32.png) [@simon.rit](https://discourse.itk.org/u/simon.rit)
#### Post date: [August 19, 2023, 5:54am UTC](https://discourse.itk.org/t/how-to-do-a-standard-fdk-using-itk-rtk-in-python/6141/5 "2023-08-19T05:54:44Z")

</div>

To answer your questions:

Q1: I’m not sure what you mean but the geometry object relates the projection images to the reconstructed CT image. As far as I can see, you have projections which are 1536x1536 mm², which will be 768x768 mm² given the ratio source-to-isocenter distance to source-to-detector distance, so a reconstructed image of 128x128x128 mm^3 seems quite small.

Q2: ConstantImageSource is used to create an empty image in which the CT image will be reconstructed. This strategy has been used instead of passing all the image information (origin, spacing, direction) as separate options of each reconstruction algorithm.

Q3: The default geometry in RTK assumes that the center of rotation is at coordinate (0,0,0). Which means that the origin of the reconstructed image (i.e. the coordinates of the first pixel in memory) has negative coordinates.

You can use the mhd file format which will save the meta information in a mhd file and the image data in a raw file.
