我正在使用Python 2.7( https://github.com/ AIM-HARVARD/DEEPCAC )
我已经做出了最相关的更改,以将其更新为Python 3.7,但是我固定了有关Simpleitk的错误消息。
错误消息:
TypeError: Execute() takes 2 positional arguments but 10 were given
它源于此代码:
res_filter = sitk.ResampleImageFilter()
----> img_sitk = res_filter.Execute(img_sitk, curated_size, sitk.Transform(), method, img_sitk.GetOrigin(), curated_spacing, img_sitk.GetDirection(), 0, img_sitk.GetPixelIDValue())
根据SimpleItk文档从1.x切换到2.X(使用Python 3.7使用的版本)应该这样完成(),但我无法完全掌握它。
有人可以帮忙吗?
谢谢
I'm working on a project on GitHub that was made with Python 2.7 (https://github.com/AIM-Harvard/DeepCAC)
I've made most relevant changes as to update it to Python 3.7, but I'm fixed on an error message regarding simpleITK.
Error message:
TypeError: Execute() takes 2 positional arguments but 10 were given
It stems from this code:
res_filter = sitk.ResampleImageFilter()
----> img_sitk = res_filter.Execute(img_sitk, curated_size, sitk.Transform(), method, img_sitk.GetOrigin(), curated_spacing, img_sitk.GetDirection(), 0, img_sitk.GetPixelIDValue())
According to the simpleITK document on switching from 1.x to 2.x (version that is available with python 3.7) it should be done like this (https://simpleitk.readthedocs.io/en/master/migrationGuide2.0.html#filter-s-execute-method) but I can't quite grasp it.
Can someone help out?
Thanks
发布评论
评论(1)
看来您正在尝试使用过程版本,重新采样,而不是类版本,RespampleImageFilter。
您可以在此处查看重新样本函数的文档:
您想进入第二版的重新样本。因此,您的代码看起来像这样:
如果要使用resplameImageFilter,则使用过滤器的各种设置方法设置所有参数,然后只需将输入image的执行方法调用为唯一的参数即可。
It looks like you're trying to use the procedural version, Resample, not the class version, ResampleImageFilter.
You can see the documentation for the Resample function here:
https://simpleitk.org/doxygen/latest/html/namespaceitk_1_1simple.html#aadbb243c10d1aedea8e955e8beda4df0
You want to the second version of Resample. So your code would look like this:
If you want to use the ResampleImageFilter, you would set all the parameters using the filter's various Set methods, and then just call the Execute method with the input image as the only parameter.