【Debug记录】Exception thrown in SimpleITK ImageFileReader_Execute|路径不存在|../../..\ is not exist
RuntimeError: Exception thrown in SimpleITK ImageFileReader_Execute: /tmp/SimpleITK/Code/IO/src/sitkImageReaderBase.cxx:97:sitk::ERROR: The file "./dataset/data_fix\ct_0001.nii.gz" does not exist.
·
RuntimeError: Exception thrown in SimpleITK ImageFileReader_Execute: /tmp/SimpleITK/Code/IO/src/sitkImageReaderBase.cxx:97:sitk::ERROR: The file “./dataset/data_fix\ct_0001.nii.gz” does not exist.
报错解释:
使用sitk.ReadImage(路径)读取ct图像,错误提示:路径不存在。
报错原因:
并不是SimpleITK读取的问题,只是路径不正确。仔细看下会发现路径组成既有/又有\。
我们设置的根路径是由是/连接的,但后面由os.path.join拼接起来的部分默认是由\连接的
解决方案: 使用replace函数将\统一替换成/就好了
ct_path = os.path.join(self.fixed_path, 'ct',name).replace("\\","/")
参考博文:Python 解决os.path.join()以反斜杠\,拼接路径问题。(使用replace()函数)
总结: 有一点不解是,这个由/ 和\混合组成的路径在本机上运行是没问题的,但是在远程服务器端这个路径就不可,也不知是咋回事……
更多推荐



所有评论(0)