[Neuroimaging] Load, Modify and Save Nifti

Ángel Torrado Carvajal angel.torrado at urjc.es
Mon Jul 20 13:20:20 CEST 2015


Hi all,

I am a newby using nibabel and I am having some trouble.

I want to load a Nifti volume, modify its image, and save it. However, if I
do something like this:

img = nb.load("input.nii.gz")

matrix = img.get_data()
matrix = np.zeros(matrix.shape)
nb.save(img, "output.nii.gz")


and open the saved volume, I obtain the same input volume, not zeros...

Is there any step I am missing? Maybe an "update" or "set_data" method...

Thank you in advance!
*--*
*      Ángel Torrado Carvajal*

*      Research Assistant*
      Medical Image Analysis Laboratory
      Universidad Rey Juan Carlos

      Despacho 155 - Departamental II
      Calle Tulipán s/n
      28933 Móstoles - Madrid

*      Before printing this message, make sure it's necessary. Protecting
the environment is in your hand.*
*      Antes de imprimir este mensaje, asegúrate de que es necesario.
Proteger el medio ambiente está también en tu mano.*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/neuroimaging/attachments/20150720/e6f57284/attachment.html>


More information about the Neuroimaging mailing list