Comments (9)
New R bindings have now been merged into SimpleElastix.
from simpleelastix.
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.
Awesome, thanks a lot.
from simpleelastix.
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.
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.
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.
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.
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.
Thank you for the info Bradley, will do.
from simpleelastix.
Related Issues (20)
- RuntimeError: Exception thrown in SimpleITK Elastix HOT 1
- AffineDTITransform does not return the CenterOfRotationPoint
- windows user :thank you very much
- Gradient based optimizer: how to control learning rate HOT 2
- Rigid transformation warping with "TransformixImageFilter"
- error of compiling on linux
- Fatal error LNK1181
- Error while installing SimpleElastix on Windows. HOT 1
- Shearing matrix composition in Affine DTI 3D Transform
- Failed to build on Win10 HOT 3
- affine registration outcome measurement
- A lot of console output even after turning it off HOT 1
- Registration with initial transform obtained using SimpleITK/etc. (.tfm file) HOT 1
- The ElastixImageFilter stuck when using iterative InitialTransformParameterFileName.
- Unable to create/compile/build SimpleElastix C++ dynamic or static library in 32bit or 64-bit.
- Trouble understanding basic usage
- Is there a way to save the transform to a .tfm file?
- AttributeError: module 'SimpleITK' has no attribute 'VesselnessMeasureImageFilter'
- Use only corresponding points based transformation
- SimpleElastix no longer maintained, use SimpleITK or ITKElastix!
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from simpleelastix.