input_path = 'problemdata'
inputlist = os.listdir(input_path)
for i in inputlist:
file_path = input_path + "/"+i
try:
image = sitk.ReadImage(file_path)
except:
print(f'cosines problem occures, try to fix it...')
img = nb.load(file_path)
qform = img.get_qform()
img.set_qform(qform)
sform = img.get_sform()
img.set_sform(sform)
nb.save(img,file_path)
image = sitk.ReadImage(file_path)
print(f'now we have fixed it!')
print(image.GetSize())
sitk.ReadImage出现报错