You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found my mistake. The argument that is causing the error is not the output filename for WriteParameterFile, but the parameter map itself. It didn't occur to me that WriteParameter also passes "self" as an argument and therefore that "argument 2" refers to the "parameterMap" and not the "filename" argument.
In the toy example I posted above, the solution is simply to use the first element of the structure returned by GetTransformParameterMap:
Hi,
I've come across the following error when trying to use WriteParameterFile. Below is a toy example that reproduces this problem on my system.
import SimpleITK as sitk
import numpy as np
f = sitk.ElastixImageFilter()
fixedImage = sitk.GetImageFromArray(np.array([[0, 0, 1, 0, 0 ],[0, 0, 1, 0, 0],[1, 1, 1, 1, 1],[0, 0, 1, 0, 0 ],[0, 0, 1, 0, 0] ]))
movingImage = sitk.GetImageFromArray(np.array([[1, 0, 0, 0, 1 ],[0, 1, 0, 1, 0],[0, 0, 1, 0, 0],[0, 1, 0, 1, 0 ],[1, 0, 0, 0, 1] ]))
elastixImageFilter = sitk.ElastixImageFilter()
elastixImageFilter.SetFixedImage(fixedImage)
elastixImageFilter.SetMovingImage(movingImage)
elastixImageFilter.SetParameterMap(sitk.GetDefaultParameterMap("rigid"))
elastixImageFilter.Execute()
transformParameterMap = elastixImageFilter.GetTransformParameterMap()
elastixImageFilter.WriteParameterFile( transformParameterMap, "test_transform.txt" )
Here is the error that I get:
Traceback (most recent call last):
File "example.py", line 17, in
elastixImageFilter.WriteParameterFile( transformParameterMap, "test_transform.txt" )
File "/usr/local/lib/python3.6/dist-packages/SimpleITK-1.0.1rc1.dev345+g9dfa8-py3.6-linux-x86_64.egg/SimpleITK/SimpleITK.py", line 10127, in WriteParameterFile
return _SimpleITK.ElastixImageFilter_WriteParameterFile(self, parameterMap, filename)
TypeError: in method 'ElastixImageFilter_WriteParameterFile', argument 2 of type 'std::map< std::string,std::vector< std::string,std::allocator< std::string > >,std::less< std::string >,std::allocator< std::pair< std::string const,std::vector< std::string,std::allocator< std::string > > > > > const'
Not sure if it's relevant, but I'm using Ubuntu 17.10 and SWIG 3.0.
The text was updated successfully, but these errors were encountered: