[sitk.ImageFileWriter()] Unable to read a saved image when moved to a different location

I save a file with .mha extension as follows.

writer = sitk.ImageFileWriter()


  • I am able to read the file via sitk.ImageFileReader() and also load it into 3D Slicer/MeVisLab.
  • But weirdly, when I move the file to another file location, I am unable to read the file using all the the three method mentioned above. I suspect the problem is with writer.SetFileName(), but I could not find any relevant issues/documentation to back this claim.


  • Windows 10
  • sitk.version == 2.0.0

Hello @pmody,

Given that you are working on windows I suspect there are unique characters (non ascii) in the file path and that this isn’t an issue with the writing itself.

Below is simplified code for writing that you can try:

import SimpleITK as sitk

sitk.WriteImage(sitk.GaussianSource(), 'gauss.mha')