[Neuroimaging] chainging sform and save back image

federico nemmi federico.nemmi at gmail.com
Thu Jan 31 05:38:55 EST 2019


Hi everyone,
I am trying to change the sform of an image to those of another image and
save the first image back as a nifti file.
To do so I do something in the line of
> import nipy as ni
> img_to_change = ni.load_image("my_image_to_change.nii")
> ref_image = ni.load_image("my_ref_image.nii")
>  img_to_change .metadata["header"]["sform_code"]  = ref_image
.metadata["header"]["sform_code"]

When I wheck now the value of the sform code for the first image it is
indeed equal to the value of the sform code in the reference image.
However, if I now save the first image with

>ni.save_image(img_to_change, "modified_img.nii")

load it back

>new_img = ni.load_image("modified_img.nii")

and check the sform code, this is as in the original image !

Am I missing something, is there a step that I skipping between changing
the header of the first image and save it ?
Thank in advance

F.
-- 
Federico Nemmi, PhD
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/neuroimaging/attachments/20190131/20562407/attachment.html>


More information about the Neuroimaging mailing list