[Neuroimaging] Opening an aparc+aseg.nii.gz programmatically in Python

Ariel Rokem arokem at gmail.com
Mon Mar 29 17:52:07 EDT 2021


Hi Paul,

Thanks for your email. I think this should do it:

    import nibabel as nib
    img = nib.load('aparc+aseg.nii.gz')
    data = img.get_fdata()

At this point, `data` should be a numpy array with the values stored in
that file.

Hope that helps,
Ariel


On Mon, Mar 29, 2021 at 2:11 PM Paul Reiners via Neuroimaging <
neuroimaging at python.org> wrote:

> This is my question: https://psychology.stackexchange.com/q/26872/28113
> _______________________________________________
> Neuroimaging mailing list
> Neuroimaging at python.org
> https://mail.python.org/mailman/listinfo/neuroimaging
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.python.org/pipermail/neuroimaging/attachments/20210329/560979de/attachment.html>


More information about the Neuroimaging mailing list