我正在python(Windows)中的.nii文件中进行N4偏差校正。为此,我正在使用SimpleITK。在输入图像时,我在读取文件时遇到问题。
代码 :
print("N4 bias correction runs.")
inputImage =sitk.ReadImage("C/Users/LENOVO/Desktop/Brats18_2013_1_1_t1.nii")
maskImage = sitk.OtsuThreshold(inputImage,0,1,200)
sitk.WriteImage(maskImage,"C/Users/LENOVO/Desktop/Brats18_2013_1_1_t1_Mask.nii")
inputImage = sitk.Cast(inputImage,sitk.sitkFloat32)
corrector = sitk.N4BiasFieldCorrectionImageFilter();
output = corrector.Execute(inputImage,maskImage)
sitk.WriteImage(output,"C/Users/LENOVO/Desktop/Brats18_2013_1_1_t1_Mask.nii")
print("Finished N4 Bias Field Correction.....")
错误 :
RuntimeError
Traceback (most recent call last)
<ipython-input-26-0835d7f75708> in <module>()
1
2 print("N4 bias correction runs.")
----> 3 inputImage = sitk.ReadImage("C/Users/LENOVO/Desktop/Brats18_2013_1_1_t1.nii")
4
5 maskImage = sitk.OtsuThreshold(inputImage,0,1,200)
~\Anaconda3\lib\site-packages\SimpleITK\SimpleITK.py in ReadImage(*args)
8612
8613 """
-> 8614 return _SimpleITK.ReadImage(*args)
8615 class HashImageFilter(ProcessObject):
8616 """
RuntimeError: Exception thrown in SimpleITK ReadImage: C:\Users\dashboard\Miniconda3\conda-bld\simpleitk_1521730316398\work\Code\IO\src\sitkImageReaderBase.cxx:89:
sitk::ERROR: The file "C/Users/LENOVO/Desktop/Brats18_2013_1_1_t1.nii" does not exist.