Git Product home page Git Product logo

Comments (9)

kaspermarstal avatar kaspermarstal commented on September 28, 2024 1

New R bindings have now been merged into SimpleElastix.

from simpleelastix.

kaspermarstal avatar kaspermarstal commented on September 28, 2024

Hi zarquon,

To set the inputs on the SimpleElastix objects in R, you need to use the following (admittedly, awkard) syntax:

elastix <- elastix$SetFixedImage(fixedImage)

This is because of the way SWIG wraps C++ code into R code. If you find this syntax annoying, you can use the procedural notation:

resultImage <- Elastix(fixedImage, movingImage, parameterMap)

Use Elastix(fixedImage, movingImage, parameterMap, TRUE) to print progress to console. This is the full example:

library(SimpleITK)

fixedImage <- ReadImage("target_trans.nii.gz")
movingImage <- ReadImage("moving_trans.nii.gz")
elastix <- SimpleElastix()
elastix <- elastix$SetFixedImage(fixedImage)
elastix <- elastix$SetMovingImage(movingImage)
parameterMap <- GetDefaultParameterMap("nonrigid")
elastix <- elastix$SetParameterMap(parameterMap)
elastix <- elastix$LogToConsoleOn()
elastix <- elastix$Execute()

Good luck! I hope you find it useful for your work.

from simpleelastix.

zarquon42b avatar zarquon42b commented on September 28, 2024

Awesome, thanks a lot.

from simpleelastix.

zarquon42b avatar zarquon42b commented on September 28, 2024

I still have a question: do you know why/how the generic SimpleITK R-wrapping provides this functionality (calling a member function using $)?
And: calling elastix$GetResultImage() fails (all Get functions - is there also a workaround?)

from simpleelastix.

kaspermarstal avatar kaspermarstal commented on September 28, 2024

I don't know why they use the $-notation. Perhaps you can ask at https://github.com/SimpleITK/SimpleITK/issues?

Can you provide a log of your R-commands, elastix output (i.e. run with LogToConsoleOn()) and full error message caused by GetResultImage()?

from simpleelastix.

zarquon42b avatar zarquon42b commented on September 28, 2024

Sorry, my last post was a bit confusing. I am OK with the $-notation. What I meant was why $DoSomething() does not work for elastix related functions but the core functions of SimpleITK. See the example with the CastImageFilter below. I guess this might be related to the issue of not being able to call the $Get* functions.

require(SimpleITK)
image1 <- ReadImage("./target_trans.nii-subvolume-scale_1.nii.gz")
image2 <- ReadImage("templateResampled.nii.gz")

ci <- CastImageFilter()
ci$SetOutputPixelType("sitkFloat32")
image1 <- ci$Execute(targetname)
image2 <- ci$Execute(movingimage)

elastix <- SimpleElastix()
elastix <- elastix$SetFixedImage(image2)
elastix <- elastix$SetMovingImage(image1)
pm <- GetDefaultParameterMap("affine")
elastix <- elastix$SetParameterMap(pm)
elastix <- elastix$LogToConsoleOn()
elastix <- elastix$Execute()
outimage <- Elastix(image1,image2,pm)
image <- elastix$GetResultImage()

Error in .getClassFromCache(Class, where, package = package, resolve.msg = resolve.msg) : 
  node stack overflow

I get the same error for all Get functions.
As you can see, the CastImageFilter from SimpleITK does not need the workaround but is pretty much identical to the code in python (with the "$" instead of the ".")

from simpleelastix.

kaspermarstal avatar kaspermarstal commented on September 28, 2024

You are right, I can reproduce the errors you see and will have to look into it before I can give a solution. Does the Elastix(image1,image2,pm) notation work for you?

from simpleelastix.

blowekamp avatar blowekamp commented on September 28, 2024

There is a bit of working going on in SimpleITK to fix some issues with the R wrapping. This is mostly done by @richardbeare

Please stay tuned to the SimpleITK repository for some changes.

Specifically you may be interested in this change in review:

http://review.source.kitware.com/#/c/20435/2/Examples/SimpleGaussian.R

from simpleelastix.

kaspermarstal avatar kaspermarstal commented on September 28, 2024

Thank you for the info Bradley, will do.

from simpleelastix.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.