迁移Simpleitk 1.x至2.x

发布于 2025-01-25 07:33:48 字数 756 浏览 3 评论 0 原文

我正在使用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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

空城缀染半城烟沙 2025-02-01 07:33:48

看来您正在尝试使用过程版本,重新采样,而不是类版本,RespampleImageFilter。

您可以在此处查看重新样本函数的文档:

您想进入第二版的重新样本。因此,您的代码看起来像这样:

img_sitk = sitk.Resample(img_sitk, curated_size, sitk.Transform(), method, img_sitk.GetOrigin(), curated_spacing, img_sitk.GetDirection(), 0, img_sitk.GetPixelIDValue()) 

如果要使用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:

img_sitk = sitk.Resample(img_sitk, curated_size, sitk.Transform(), method, img_sitk.GetOrigin(), curated_spacing, img_sitk.GetDirection(), 0, img_sitk.GetPixelIDValue()) 

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文