Description
I have written a small function in IPython to delete the origin information from an image:
In [1]: def removeOrigin(imPath):
...: nii=nib.load(imPath)
...: affine = nii.affine
...: affine[:3, 3] = 0
...: data = nii.get_data()
...: new = nib.Nifti1Pair(data, affine)
...: nib.save(new, imPath)
My images are in Nifti1Pair format and very small (500 kB - 1 MB).
When I call my function, IPython crashes, the Terminal says Bus error
and something very bad happens: my image data is gone!! The .hdr/.imgs file contain now 0 bytes, so I just lost my data.
I've tried outside the function and it happens the same when I try to overwrite the original image, i.e.:
nib.save(new, imPath)
-> Bus error
nib.save(new, imPath.replace('.hdr', '_2.hdr'))
-> Ok