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

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++.

@simon.rit might have some pointers.

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. 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.

I don’t understand your error message for compilation. If your C++ build was correct, it should not occur, see code here. You can also just try to active RTK compilation at the same time as ITK, see INSTALLATION.md.

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> 于2023年8月13日周日 21:27写道:

FirstReconstruction.py (2.25 KB)

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.

2 Likes