[Neuroimaging] Load, Modify and Save Nifti

John Pellman pellman.john at gmail.com
Mon Jul 20 13:32:55 CEST 2015


Hi Angel,

You might also want to submit this question to neurostars.org, as the
format of that website is much more suited for Q&A.  I've noticed that this
mailing list tends to focus more on issues of software development.



2015-07-20 7:20 GMT-04:00 Ángel Torrado Carvajal <angel.torrado at urjc.es>:

> 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.*
>
> _______________________________________________
> Neuroimaging mailing list
> Neuroimaging at python.org
> https://mail.python.org/mailman/listinfo/neuroimaging
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/neuroimaging/attachments/20150720/89c8bf63/attachment.html>


More information about the Neuroimaging mailing list