[Neuroimaging] Change sform and save
Markus Gramer
Markus.Gramer at kuleuven.be
Mon Aug 3 14:19:15 CEST 2015
Hi there,
I am new to nibabel (and also python) so maybe I am making an obvious mistake, but I could not find anything in the manual that would help me…
I am trying to update the sform in a Nifty1 image and save it with:
def update_sform(file_in, file_out, affine_out):
img = nib.load(file_in)
img_hdr = img.header
img_hdr.set_sform(affine_out)
nib.save(img,file_out)
However, I realised that due to the comparison between current header and affine:
np.allclose(self._affine, hdr.get_best_affine()) [spatialimages.py, line 426]
The sform in the header is reset to the affine when I am saving the image. Is there a way to directly set the affine? Or any other method that I can use to achieve this?
Thanks in advance,
Markus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/neuroimaging/attachments/20150803/bb31be35/attachment.html>
More information about the Neuroimaging
mailing list