Comments (13)
One approach is to construct a 4D image of labels using the same sequence as for the intensity images and then warp with transformix. Assuming you have already run registration, do something along the lines of
transformParameterMapVector = SimpleElastix.GetTransformParameterMap()
# Turn off interpolation for labels (a bug in SWIG wrapping prevents us from writing directly to a parameter map in a vector so we have unwrap it first)
transformParameterMap = transformParameterMapVector[0]
transformParameterMap["ResampleInterpolator"] = ["FinalNearestNeighborInterpolator"]
resultLabel = sitk.Transformix(label4d, transformParameterMap)
I have just tried to run this on my own system and I see a big memory leak when the image is being warped. Let me know if you experience the same problem.
from simpleelastix.
Thanks for the reply. I had seen your post elsewhere about GetTransformParameterMap() but somehow had my brain stuck that there would be one for each individual volume. Joining the labels together in the same fashion makes a lot more sense.
So, I tried it this way and I actually got another pixel/4D error, attached:
resultLabel = sitk.Transformix(labelImage, transformParameterMap) Traceback (most recent call last): File "<ipython-input-21-b4d4d169a6d6>", line 1, in <module> resultLabel = sitk.Transformix(labelImage, transformParameterMap) File "/Users/gattia/anaconda2/envs/sitkConda4D/lib/python2.7/site-packages/SimpleITK-0.9.1.dev21-py2.7-macosx-10.5-x86_64.egg/SimpleITK/SimpleITK.py", line 9059, in Transformix return _SimpleITK.Transformix(*args) RuntimeError: Exception thrown in SimpleITK Transformix: /Users/gattia/Programming/Elastix/SimpleElastix/Code/Elastix/src/sitkSimpleTransformix.cxx:90: sitk::ERROR: SimpleITK does not support the combination of image type "16-bit signed integer" (short) and dimension 4
from simpleelastix.
Ah, I forgot, SimpleTransformix support for 4D has been disabled because of said memory leak. Add
m_MemberFactory->RegisterMemberFunctions< BasicPixelIDTypeList, 4, SimpleTransformixAddressor< MemberFunctionType > >();
here.
from simpleelastix.
I have a question about CMake... sorry its somewhat off topic. I find that whenever I make a change to the SimpleElastix folder i.e. this case or a git pull that simply going back into ccmake . in my build directory and regenerating and then doing another make -jx doesn't do the trick. I find that I need to make an entire new build directory and do a new build for the changes to work. Is this normal? I've tried the quick approach and it didn't allow me to do the transform so I am about to do another build directory but wanted to check if there is a quicker way as a new build takes quite a while.
from simpleelastix.
Yes, this happens if you are in the top-level SuperBuild directory. After SimpleElastix has been build the first time, you can step into the SimpleITK-build directory and work from there. Running make in this directory will pick up any changes :)
from simpleelastix.
Thanks for that. Made things a little easier.
So. I do get an error on the transform.
runfile('/Users/gattia/Programming/Segmentation/PCApython/importRegisterDisplay.py',
wdir='/Users/gattia/Programming/Segmentation/PCApython')
Traceback (most recent call last):File "", line 1, in
runfile('/Users/gattia/Programming/Segmentation/PCApython/importRegisterDisplay.py', wdir='/Users/gattia/Programming/Segmentation/PCApython')File "/Users/gattia/anaconda2/envs/sitkConda4D/lib/python2.7/site-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 699, in runfile
execfile(filename, namespace)File "/Users/gattia/anaconda2/envs/sitkConda4D/lib/python2.7/site-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 81, in execfile
builtins.execfile(filename, *where)File "/Users/gattia/Programming/Segmentation/PCApython/importRegisterDisplay.py", line 137, in
resultLabel = sitk.Transformix(labelImage, transformParameterMap)File "/Users/gattia/anaconda2/envs/sitkConda4D/lib/python2.7/site-packages/SimpleITK-0.9.1.dev21-py2.7-macosx-10.5-x86_64.egg/SimpleITK/SimpleITK.py", line 9059, in Transformix
return _SimpleITK.Transformix(*args)RuntimeError: Exception thrown in SimpleITK Transformix: /Users/gattia/Programming/Elastix/SimpleElastix/Code/Elastix/src/sitkSimpleTransformix.hxx:62:
sitk::ERROR: Errors occured in transformix. If you do not see any other error message, set LogToConsoleOn() or LogToFolder("path/to/folder") to view transformix output.`
and when looking at the console log there are a bunch of warnings and then an error:
transformix is started at Fri Mar 4 14:53:56 2016.
Installing all components.
InstallingComponents was successful.ELASTIX version: 4.801
Command line options from ElastixBase:
-out output_path_not_set
-threads unspecified, so all available threads are used
-def unspecified, so no input points transformed
-jac unspecified, so no det(dT/dx) computed
-jacmat unspecified, so no dT/dx computed<Reading input image ...
Reading input image took 0.000012 s
Calling all ReadFromFile()'s ...
WARNING: The parameter "BSplineTransformSplineOrder", requested at entry number 0, does not exist at all.
The default value "3" is used instead.
WARNING: The parameter "NumberOfSubTransforms", requested at entry number 0, does not exist at all.
The default value "2" is used instead.
WARNING: The parameter "StackOrigin", requested at entry number 0, does not exist at all.
The default value "5.3475e-314" is used instead.
WARNING: The parameter "StackSpacing", requested at entry number 0, does not exist at all.
The default value "2.08601e-308" is used instead.
WARNING: The parameter "GridSize", requested at entry number 0, does not exist at all.
The default value "1" is used instead.
WARNING: The parameter "GridIndex", requested at entry number 0, does not exist at all.
The default value "0" is used instead.
WARNING: The parameter "GridSpacing", requested at entry number 0, does not exist at all.
The default value "1" is used instead.
WARNING: The parameter "GridOrigin", requested at entry number 0, does not exist at all.
The default value "0" is used instead.
WARNING: The parameter "GridDirection", requested at entry number 0, does not exist at all.
The default value "1" is used instead.
WARNING: The parameter "GridDirection", requested at entry number 1, does not exist at all.
The default value "0" is used instead.
WARNING: The parameter "GridDirection", requested at entry number 2, does not exist at all.
The default value "0" is used instead.
WARNING: The parameter "GridSize", requested at entry number 1, does not exist at all.
The default value "1" is used instead.
WARNING: The parameter "GridIndex", requested at entry number 1, does not exist at all.
The default value "0" is used instead.
WARNING: The parameter "GridSpacing", requested at entry number 1, does not exist at all.
The default value "1" is used instead.
WARNING: The parameter "GridOrigin", requested at entry number 1, does not exist at all.
The default value "0" is used instead.
WARNING: The parameter "GridDirection", requested at entry number 3, does not exist at all.
The default value "0" is used instead.
WARNING: The parameter "GridDirection", requested at entry number 4, does not exist at all.
The default value "1" is used instead.
WARNING: The parameter "GridDirection", requested at entry number 5, does not exist at all.
The default value "0" is used instead.
WARNING: The parameter "GridSize", requested at entry number 2, does not exist at all.
The default value "1" is used instead.
WARNING: The parameter "GridIndex", requested at entry number 2, does not exist at all.
The default value "0" is used instead.
WARNING: The parameter "GridSpacing", requested at entry number 2, does not exist at all.
The default value "1" is used instead.
WARNING: The parameter "GridOrigin", requested at entry number 2, does not exist at all.
The default value "0" is used instead.
WARNING: The parameter "GridDirection", requested at entry number 6, does not exist at all.
The default value "0" is used instead.
WARNING: The parameter "GridDirection", requested at entry number 7, does not exist at all.
The default value "0" is used instead.
WARNING: The parameter "GridDirection", requested at entry number 8, does not exist at all.
The default value "1" is used instead.--------------- Exception ---------------
itk::ExceptionObject (0x285216db8)
Location: "unknown"
File: /Users/gattia/Programming/Elastix/sitkConda4D/elastix/src/Components/Transforms/StackTransform/itkStackTransform.hxx
Line: 51
Description: itk::ERROR: StackTransform(0x28520fce0): Number of parameters does not match the number of subtransforms * the number of parameters per sub transform.
Errors occurred
from simpleelastix.
I assume you are trying to warp the 4D label image (correct me if I'm wrong). Can you double check that there is an equal amount of label images in the 4D label as in the 4D image and that the field of view for corresponding images are the same?
from simpleelastix.
You are correct. And they are the same. I went through and they are both the same dimensions: 94,512,512,10. They even have the same origin, direction, index to point, and inverse direction matrices.
from simpleelastix.
Looking at the log, it says StackOrigin
is equal to 5.3475e-314
and StackSpacing
is equal to 2.08601e-308
. These values are probably misconfigured by elastix. What happens if you set these to zero manually? To test this add them to the parameter map like this
parameterMap["StackOrigin"] = ["0.0"]
(Python)
from simpleelastix.
Thanks for the help... and sorry it took so long to finally give it a try. So, I tried that and it changed things up... but there is still an issue. Im not sure what the side-effects or presentation of a memory leak is but that might be what it is. Anyways, I got an error in my console indicating that
It seems the kernel died unexpectedly. Use 'Restart kernel' to continue using this console.
It did run for a little while before giving this error. Probably ran for longer than it should have, as I am guessing just applying the transform should be relatively quick (?).
and the kernel log gave the same/similar info as previously.
transformix is started at Wed Mar 23 09:54:50 2016.
Installing all components.
InstallingComponents was successful.ELASTIX version: 4.801
Command line options from ElastixBase:
-out output_path_not_set
-threads unspecified, so all available threads are used
-def unspecified, so no input points transformed
-jac unspecified, so no det(dT/dx) computed
-jacmat unspecified, so no dT/dx computedReading input image ...
Reading input image took 0.000013 s
Calling all ReadFromFile()'s ...
WARNING: The parameter "BSplineTransformSplineOrder", requested at entry number 0, does not exist at all.
The default value "3" is used instead.
WARNING: The parameter "NumberOfSubTransforms", requested at entry number 0, does not exist at all.
The default value "1035248976" is used instead.
WARNING: The parameter "GridSize", requested at entry number 0, does not exist at all.
The default value "1" is used instead.
WARNING: The parameter "GridIndex", requested at entry number 0, does not exist at all.
The default value "0" is used instead.
WARNING: The parameter "GridSpacing", requested at entry number 0, does not exist at all.
The default value "1" is used instead.
WARNING: The parameter "GridOrigin", requested at entry number 0, does not exist at all.
The default value "0" is used instead.
WARNING: The parameter "GridDirection", requested at entry number 0, does not exist at all.
The default value "1" is used instead.
WARNING: The parameter "GridDirection", requested at entry number 1, does not exist at all.
The default value "0" is used instead.
WARNING: The parameter "GridDirection", requested at entry number 2, does not exist at all.
The default value "0" is used instead.
WARNING: The parameter "GridSize", requested at entry number 1, does not exist at all.
The default value "1" is used instead.
WARNING: The parameter "GridIndex", requested at entry number 1, does not exist at all.
The default value "0" is used instead.
WARNING: The parameter "GridSpacing", requested at entry number 1, does not exist at all.
The default value "1" is used instead.
WARNING: The parameter "GridOrigin", requested at entry number 1, does not exist at all.
The default value "0" is used instead.
WARNING: The parameter "GridDirection", requested at entry number 3, does not exist at all.
The default value "0" is used instead.
WARNING: The parameter "GridDirection", requested at entry number 4, does not exist at all.
The default value "1" is used instead.
WARNING: The parameter "GridDirection", requested at entry number 5, does not exist at all.
The default value "0" is used instead.
WARNING: The parameter "GridSize", requested at entry number 2, does not exist at all.
The default value "1" is used instead.
WARNING: The parameter "GridIndex", requested at entry number 2, does not exist at all.
The default value "0" is used instead.
WARNING: The parameter "GridSpacing", requested at entry number 2, does not exist at all.
The default value "1" is used instead.
WARNING: The parameter "GridOrigin", requested at entry number 2, does not exist at all.
The default value "0" is used instead.
WARNING: The parameter "GridDirection", requested at entry number 6, does not exist at all.
The default value "0" is used instead.
WARNING: The parameter "GridDirection", requested at entry number 7, does not exist at all.
The default value "0" is used instead.
WARNING: The parameter "GridDirection", requested at entry number 8, does not exist at all.
The default value "1" is used instead.
from simpleelastix.
Look there is something wrong with the way elastix pick up the number of sub transforms. Will have to take a closer look. In the meantime, what happens when you manually set "NumberOfSubTransforms" to the number of images in your groupwise registration?
from simpleelastix.
This issue should now be fixed on the develop branch. Let me know if you try it out and anything goes wrong
from simpleelastix.
Closing issue. Feel free to reopen if your problem was not fixed.
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.