我使用SimpleITK
安装了ITK
版本1.2.4,pip
版本4.13库,当我运行以下代码来读取Nifti image时,出现以下错误: line 4, in loadSimpleITK
result = sitk.ReadImage(path)
AttributeError: module 'SimpleITK' has no attribute 'ReadImage'
在库website上提出的解决方案是安装虚拟环境。
是否有另一种简单的方法可以避免使用虚拟环境来解决问题?
编辑: print(sitk)
和print(dir(sitk))
给出了结果:
<module 'SimpleITK' from 'D:\\My_Project\\SimpleITK.py'>
['__builtins__', '__cached__', '__doc__', '__file__',
'__loader__', '__name__', '__package__', '__spec__', 'nib', 'sitk']
<module 'SimpleITK' from 'D:\\My_Project\\SimpleITK.py'>
['__builtins__', '__cached__', '__doc__', '__file__',
'__loader__', '__name__', '__package__', '__spec__', 'loadSimpleITK', 'nib', 'sitk']
代码:
import SimpleITK as sitk
def loadSimpleITK(path):
result = sitk.ReadImage(path)
return result
path = 'mypath'
img2 = loadSimpleITK(path)