[Rtk-users] using RTK with python
Aurélien Coussat
aurelien.coussat at creatis.insa-lyon.fr
Wed Apr 22 03:22:37 EDT 2020
Hi!
FirstReconstruction.py is initially meant to be called from the command
line as it expects two command-line arguments (specified on line 7).
When ran from a Jupyter Notebook (as in FirstReconstruction.ipynb), you
need to manually provide values for sys.argv[1] (the output image) and
sys.argv[2] (the geometry). Here, you script tries to write the image
to an undefined place, producing the error.
In RTK.ipynb, you did specify the "geometry" variable as a
rtkFDKConeBeamReconstructionFilter, hence the error. It needs to be of
type rtkThreeDCircularProjectionGeometry.
Hope it helps!
Aurélien.
On Wed, 2020-04-22 at 11:33 +0900, 나윤호 wrote:
> Here's my jupyter file.
> I just found something strange.
>
> I'll send you two files.
>
> they both have same script in it but having different error.
>
> FirstReconstruction.ipynb is exactly same as the one in the github
> example.
>
> and the other one is same except for the plotting of sinogram data
> for practicing itk.
>
> I have no idea why they have different error
>
>
>
> 2020년 4월 21일 (화) 오후 10:22, Simon Rit <simon.rit at creatis.insa-lyon.fr>
> 님이 작성:
> > Please share your ipynb jupyter notebook file because I did the
> > test with a new conda environment right now and it works for me...
> > Thanks,
> > Simon
> >
> > On Tue, Apr 21, 2020 at 10:41 AM 나윤호 <yoonho94.na at gmail.com> wrote:
> > > Before I run the script, I installed itk and itk-rtk using
> > > pip.and then I copied
> > >
> > > and pasted
> > >
> > > the whole script in FirstReconstruction.py in a jupyter notebook
> > > cell.
> > > Do I need any additional installation to use rtk?
> > >
> > > Thank you for your answer of second question.
> > >
> > > 2020년 4월 21일 (화) 오후 5:27, Aurélien Coussat <aurelien.coussat at crea
> > > tis.insa-lyon.fr>님이 작성:
> > > > On Tue, 2020-04-21 at 17:15 +0900, 나윤호 wrote:
> > > > > Thank you for replying.
> > > > > I'm pretty sure that I haven't changed anything in the
> > > > > example script.
> > > > > What I just did is copy and paste and run it.
> > > >
> > > > What process did you follow in order to run it? Are you running
> > > > it from a shell command line (as in "python
> > > > FirstReconstruction.py") or from a Python command line (running
> > > > "python" then copy-pasting everything) ? Could you provide the
> > > > exact steps you followed in order to reproduce the problem?
> > > > > and could you explain me how to translate(?) does documents
> > > > > into pythonic way?
> > > > > (I don't know much about Clang)
> > > > >
> > > > > for example, in the link you gave me it says
> > > > >
> > > > > rtk::FDKConeBeamReconstructionFilter< TInputImage,
> > > > > TOutputImage, TFFTPrecision > Class Template Reference
> > > > >
> > > > >
> > > > > I empirically know that in python I have to type something
> > > > > like
> > > > >
> > > > > rtk.FDKConeBeamReconstructionFilter[InputImage, OutputImage,
> > > > > FFTPrecision]
> > > > >
> > > > >
> > > > > Am I right??
> > > >
> > > > Almost, but your intuition is correct! From
> > > > rtkFDKConeBeamReconstructionFilter header file (http://www.open
> > > > rtk.org/Doxygen/rtkFDKConeBeamReconstructionFilter_8h_source.ht
> > > > ml), you can see that default values are already provided for
> > > > TOutputImage and TFFTPrecision. From Python's point of view
> > > > only a single argument is therefore required (TInputImage). You
> > > > can see an example of FDKConeBeamReconstructionFilter starting
> > > > from the 65th line of FirstReconstruction.py.
> > > > Good luck!
> > > > Aurélien.
> > > > > 2020년 4월 21일 (화) 오후 4:58, Aurélien Coussat <aurelien.coussat@
> > > > > creatis.insa-lyon.fr>님이 작성:
> > > > > > Hi,
> > > > > > Your first error is really strange. The "geometry" variable
> > > > > > is supposed to be typed as
> > > > > > rtkThreeDCircularProjectionGeometry (defined line 14),
> > > > > > while according to your error message it is of type
> > > > > > rtkFDKConeBeamReconstructionFilter. Are you sure you
> > > > > > haven't somehow altered the example script?
> > > > > > About your second question, you can use
> > > > > > rtkFDKConeBeamReconstructionFilter and provide it a
> > > > > > parallel geometry. See the documentation for more details :
> > > > > > http://www.openrtk.org/Doxygen/classrtk_1_1FDKConeBeamRecon
> > > > > > structionFilter.html.
> > > > > > Don't hesitate if something remains unclear!
> > > > > > Aurélien.
> > > > > > On Tue, 2020-04-21 at 12:06 +0900, 나윤호 wrote:
> > > > > > > Hi.I'm a newbie to ITK and RTK.
> > > > > > > I'm currently using python not C++
> > > > > > >
> > > > > > >
> > > > > > > so I installed ITK package and RTK package using
> > > > > > >
> > > > > > > pip install itk
> > > > > > > pip install itk-rtk
> > > > > > >
> > > > > > > using ITK seems OK, but I'm having difficulties with
> > > > > > > RTK.
> > > > > > >
> > > > > > > When I run the ITK example code, It worked well.
> > > > > > > but when I tried to run the FirstReconstruction.py in the
> > > > > > > github,
> > > > > > > error occurrs.
> > > > > > >
> > > > > > > > -----------------------------------------------------
> > > > > > > > ----------------------
> > > > > > > > AttributeError Traceback
> > > > > > > > (most recent call last)
> > > > > > > > <ipython-input-1-be2ee9c70d3d> in <module>
> > > > > > > > 19 for x in range(0,numberOfProjections):
> > > > > > > > 20 angle = firstAngle + x * angularArc /
> > > > > > > > numberOfProjections
> > > > > > > > ---> 21 geometry.AddProjection(sid,sdd,angle)
> > > > > > > > 22
> > > > > > > > 23 # Writing the geometry to disk
> > > > > > > >
> > > > > > > > AttributeError: 'rtkFDKConeBeamReconstructionFilterIF3'
> > > > > > > > object has no attribute 'AddProjection'
> > > > > > >
> > > > > > > How can I fix this problem?
> > > > > > >
> > > > > > > and I have another question.
> > > > > > > I want the reconstruct the sinogram image to phantom.
> > > > > > >
> > > > > > > usually what I did was using skimage.transform.iradon().
> > > > > > > what should I use in RTK to do Inverse radon transform or
> > > > > > > Filtered back projection method?
> > > > > > >
> > > > > > >
> > > > > > > _______________________________________________
> > > > > > > Rtk-users mailing list
> > > > > > > Rtk-users at public.kitware.com
> > > > > > > https://public.kitware.com/mailman/listinfo/rtk-users
> > >
> > > _______________________________________________
> > >
> > > Rtk-users mailing list
> > >
> > > Rtk-users at public.kitware.com
> > >
> > > https://public.kitware.com/mailman/listinfo/rtk-users
> > >
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://public.kitware.com/pipermail/rtk-users/attachments/20200422/6f95606e/attachment.html>
More information about the Rtk-users
mailing list