[Rtk-users] WaterPreCorrectionFilter Example - Python

Amarnath S amarnaths161 at gmail.com
Wed Feb 13 02:02:34 EST 2019


Hi,

     Thanks for creating the Python version of RTK, and enabling us to get
it via pip. I downloaded it yesterday, and successfully ran the First
Reconstruction Python example.

     Am now trying to convert the WaterPreCorrection example, which was
earlier available using Simple RTK, on this page
http://wiki.openrtk.org/index.php/WaterPreCorrection

    Am using the same dataset for this, as available in the archive
"beam_hardening.tgz" available on the same page. However, am getting an
error while running my code.

Have created a minimal code in Python, for getting the error, and it is
given here.

import sys
import itk
from itk import RTK as rtk
import glob
import os

# Script parameter
dir = "F:\\RTKDir\\output\\"

# List of filenames
fileNames = []
for file in os.listdir(dir):
    if file.startswith("attenuation") and file.endswith(".mha"):
        fileNames.append(dir + file)

projReader = rtk.ProjectionsReader.New()
projReader.SetFileNames(fileNames)
print("Filenames set")

waterPre = rtk.WaterPrecorrectionImageFilter.New();
wpcoeffs = [0, 0, 0, 0, 0, 0, 1]
print("Water Pre defined")

waterPre.SetCoefficients(wpcoeffs)
waterPre.SetInput(projReader.GetOutput())
print("Gives error on the above line - Expecting argument of type
itkImageF3 or itkImageSourceIF3")

It gives error for the line where we set the input to waterPre, the
last-but-one line of this script - waterPre.SetInput(projReader.GetOutput()).
The error message is TypeError: Expecting argument of type itkImageF3 or
itkImageSourceIF3.  As far as I know, I have replicated the code from the
example available for SimpleRTK. Note, I have created a folder called
F:\RTKDir\, which has the contents of the archive "beam_hardening.tgz" have
been extracted there.

So, my questions are:
1. Have the input types been changed for the WaterPreCorrection Filter,
since the posting of the earlier example?
2. If so, how can I specify projections as read in from 360 files as inputs
to this filter?

Any pointers in this regard will be greatly appreciated.

Thanks and Regards
- Amarnath
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://public.kitware.com/pipermail/rtk-users/attachments/20190213/adb85478/attachment.html>


More information about the Rtk-users mailing list