2D to 3D Registration

hi,

i was looking an example for registration of 2D images with 3D images, i can’t find any examples on this topic.

can someone please direct me to an example or a library that can do this

Thanks

Hi @svabhishek29,

Welcome to the ITK community! :sunny:

The ITKTwoProjectionRegistration module can be used:

A description is found in the Insight Journal article:

https://www.insight-journal.org/browse/publication/784

https://www.insight-journal.org/download/viewpdf/784/3/download

Python packages can be installed with

pip install itk-twoprojectionregistration
3 Likes

is it possible to write a simple example for this please? i am not a professional developer and an example would help greatly.

Thanks

Have you looked at TwoProjection2D3DRegistration.cxx?

This example looks like a good starting point, even if you can’t use it as is.

oh,
sorry, my bad, i did not go through all the files, saw the root folder and then tried to implement it.

Hi, I am also doing this topic now, but in Python.
Are there useful usage instructions or documentations of itk-twoprojectionregistration module.

Thank you for the help.

That module came with an Insight Journal paper titled ITK-Based Implementation of Two-Projection 2D/3D Registration Method with an Application in Patient Setup for External Beam Radiotherapy.

1 Like

Hi,

I am trying to use the GetDRRSiddonJacobsRayTracing function https://github.com/InsightSoftwareConsortium/ITKTwoProjectionRegistration/blob/master/test/GetDRRSiddonJacobsRayTracing.cxx.

However, I am a little confused about the usage in python. After running the pip install (pip install itk-twoprojectionregistration), I am not sure how to actually use the function. Does anyone have any example code in python on importing and usage of the function?

Thank you!

@simon.rit might have some advice.

Not really, I am not very familiar with this module. I think itk::SiddonJacobsRayCastInterpolateImageFunction is an interpolator for the registration framework of ITK so maybe you need to find a python registration example and adapt it to your case? Or a resample image filter example? Sorry I can’t help more…

This is my first quistion.
I am confused about the usage in python for this module.
I have two images(0&90 degree, 512512) and a CT volume(512512, z=256). I want get the transform after the registration in python. I pip installed this module and I learned how to read the DICOM files.
What’s the code I should write? There is no example code for python after Google and github researching.
Thanks.

You should write out the final transform. This example shows how.

Dear dzenanz:
Thank you very much!

import itk

a=itk.TwoProjectionRegistrationPython
helpInformation=a.getDRRSiddonJacobsRayTracing('-h')
print(helpInformation)

I get som problem:

  File "d:\ProgramData\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 668, in runfile
    execfile(filename, namespace)

  File "d:\ProgramData\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 108, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

  File "C:/Users/1/.spyder-py3/temp.py", line 10, in <module>
    a=itk.TwoProjectionRegistrationPython

  File "d:\ProgramData\Anaconda3\lib\site-packages\itkLazy.py", line 48, in __getattribute__
    value = types.ModuleType.__getattribute__(self, attr)

AttributeError: module 'itk' has no attribute 'TwoProjectionRegistrationPython'

This is the paper’s code:

REM Test using down-sized CT
getDRRSiddonJacobsRayTracing -rp 0 -rx -3 -ry 4 -rz 2 -t 5 5 5 -iso 99.62 101.18 65 -res 1 1 -size 256 256 -o boxheadDRRDev1_G0.tif BoxheadCT.img
getDRRSiddonJacobsRayTracing -rp 90 -rx -3 -ry 4 -rz 2 -t 5 5 5 -iso 99.62 101.18 65 -res 1 1 -size 256 256 -o boxheadDRRDev1_G90.tif BoxheadCT.img
2D3DTwoProjRegistration -res 1 1 1 1 -iso 99.62 101.18 65 -o boxheadDRRDev1_G0_Reg.tif boxheadDRRDev1_G90_Reg.tif boxheadDRRDev1_G0.tif 0 boxheadDRRDev1_G90.tif 90 BoxheadCT.img

Can I use this module in python just given such argv?
Thanks

It seems error…

@timeanddoctor

To install the itk-twoprojectionregistration Python package:

python -m pip install --upgrade itk-twoprojectionregistration
1 Like
python -m pip install --upgrade itk-twoprojectionregistration
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting itk-twoprojectionregistration
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/65/d9/019f54967c7ff39ddb9b617d5640c0a5e3ea33781519f925e487c2f522bf/itk_twoprojectionregistration-1.1.0-cp35-cp35m-win_amd64.whl (457kB)
    100% |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 460kB 313kB/s
Collecting itk>=5.1.0.post2 (from itk-twoprojectionregistration)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/4e/38/51e8635c30bcb755531ff72369fb9853dab53138c5221b38475b71dcb84c/itk-5.1.0.post2-cp35-cp35m-win_amd64.whl
Requirement not upgraded as not directly required: numpy in d:\programdata\anaconda3\lib\site-packages (from itk>=5.1.0.post2->itk-twoprojectionregistration) (1.14.5)
Collecting itk-io==5.1.0.post2 (from itk>=5.1.0.post2->itk-twoprojectionregistration)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/0c/82/1068ed9941e140ab556a1b2ee57786cb9e70bb0371b3851b0525dc7c2dcf/itk_io-5.1.0.post2-cp35-cp35m-win_amd64.whl (5.7MB)
    100% |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 5.7MB 1.3MB/s
Collecting itk-filtering==5.1.0.post2 (from itk>=5.1.0.post2->itk-twoprojectionregistration)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/5c/0d/a933eb2d9617329eaeb923435482d639eb2d57c4f98d5fb525c555f8badf/itk_filtering-5.1.0.post2-cp35-cp35m-win_amd64.whl (23.7MB)
    100% |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 23.7MB 195kB/s
Collecting itk-registration==5.1.0.post2 (from itk>=5.1.0.post2->itk-twoprojectionregistration)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/9d/93/749dbe63bab8a10a2619f854befb013ea4797df9df6458b4f4b2561ab76e/itk_registration-5.1.0.post2-cp35-cp35m-win_amd64.whl (4.5MB)
    100% |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 4.5MB 1.6MB/s
Collecting itk-core==5.1.0.post2 (from itk>=5.1.0.post2->itk-twoprojectionregistration)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/82/7b/32057792ca5c4a8b0e2ec3501a25bc21125bd00c4adf389fd5a93dcced13/itk_core-5.1.0.post2-cp35-cp35m-win_amd64.whl (25.3MB)
    100% |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 25.3MB 145kB/s
Collecting itk-segmentation==5.1.0.post2 (from itk>=5.1.0.post2->itk-twoprojectionregistration)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/fa/a8/5eead8d6d8384733c8cd7163800662bad311923deb8ae3826bdb5dfafdde/itk_segmentation-5.1.0.post2-cp35-cp35m-win_amd64.whl (3.3MB)
    100% |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 3.3MB 1.9MB/s
Collecting itk-numerics==5.1.0.post2 (from itk>=5.1.0.post2->itk-twoprojectionregistration)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/f7/8e/29ea13d6b709d7125d05a94690ce74df6620afcdbf3005c23dc2da0463ad/itk_numerics-5.1.0.post2-cp35-cp35m-win_amd64.whl (12.3MB)
    100% |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 12.3MB 900kB/s
twisted 18.7.0 requires PyHamcrest>=1.9.0, which is not installed.
tensorflow 1.10.0 has requirement setuptools<=39.1.0, but you'll have setuptools 40.2.0 which is incompatible.
tensorflow-gpu 1.10.0 has requirement setuptools<=39.1.0, but you'll have setuptools 40.2.0 which is incompatible.
pygmsh 5.0.1 has requirement meshio<3.0,>=2.0, but you'll have meshio 4.0.13 which is incompatible.
Installing collected packages: itk-core, itk-io, itk-numerics, itk-filtering, itk-registration, itk-segmentation, itk, itk-twoprojectionregistration
  Found existing installation: itk-core 5.1.0
    Uninstalling itk-core-5.1.0:
      Successfully uninstalled itk-core-5.1.0
  Found existing installation: itk-io 5.1.0
    Uninstalling itk-io-5.1.0:
      Successfully uninstalled itk-io-5.1.0
  Found existing installation: itk-numerics 5.1.0
    Uninstalling itk-numerics-5.1.0:
      Successfully uninstalled itk-numerics-5.1.0
  Found existing installation: itk-filtering 5.1.0
    Uninstalling itk-filtering-5.1.0:
      Successfully uninstalled itk-filtering-5.1.0
  Found existing installation: itk-registration 5.1.0
    Uninstalling itk-registration-5.1.0:
      Successfully uninstalled itk-registration-5.1.0
  Found existing installation: itk-segmentation 5.1.0
    Uninstalling itk-segmentation-5.1.0:
      Successfully uninstalled itk-segmentation-5.1.0
  Found existing installation: itk 5.1.0
    Uninstalling itk-5.1.0:
      Successfully uninstalled itk-5.1.0
  Found existing installation: itk-twoprojectionregistration 1.0.1
    Uninstalling itk-twoprojectionregistration-1.0.1:
      Successfully uninstalled itk-twoprojectionregistration-1.0.1
Successfully installed itk-5.1.0.post2 itk-core-5.1.0.post2 itk-filtering-5.1.0.post2 itk-io-5.1.0.post2 itk-numerics-5.1.0.post2 itk-registration-5.1.0.post2 itk-segmentation-5.1.0.post2 itk-twoprojectionregistration-1.1.0
You are using pip version 19.0.1, however version 20.2b1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

I update the code and still get the some error.

  File "d:\ProgramData\Anaconda3\lib\site-packages\itkLazy.py", line 48, in __getattribute__
value = types.ModuleType.__getattribute__(self, attr)

AttributeError: module 'itk' has no attribute 'TwoProjectionRegistrationPython'

To instantiate a TwoProjectionImageRegistrationMethod class,

ImageType = itk.Image[itk.F, 3]
registration_method = itk.TwoProjectionImageRegistrationMethod[ImageType, ImageType].New()

hi, I changed your program to a fixed image, but the result is an all black image.

Can you please start a new topic, and describe your problem in more detail?

1 Like