[Neuroimaging] 2D NIFTI images in nibabel
Reid, Robert I. (Rob)
Reid.Robert at mayo.edu
Thu Sep 1 10:17:27 EDT 2016
I usually work with a mix of 3D and 4D NIFTIs, and like that the 3D ones appear as 3D arrays instead of 4D (or 5D, 6D,…) with the extra axis having length 1.
Also, if I select a volume from a 4D array, i.e.
vol = data[…, t],
it makes sense that I get a 3D array, just like selecting an element from a list of scalars gives you a scalar.
I understand that there are two ways of looking at it, but I think overall things are better as is.
Robert I. Reid, Ph.D. | Sr. Analyst/Programmer, Information Technology
Aging and Dementia Imaging Research | Opus Center for Advanced Imaging Research
Mayo Clinic | 200 First Street SW | Rochester, MN 55905 | mayoclinic.org<http://www.mayoclinic.org/>
From: Neuroimaging [mailto:neuroimaging-bounces+reid.robert=mayo.edu at python.org] On Behalf Of paul mccarthy
Sent: Thursday, September 01, 2016 4:15 AM
To: Neuroimaging analysis in Python
Subject: [Neuroimaging] 2D NIFTI images in nibabel
Nibabel truncates the third dimension of a NIFTI image with dim3=1.
(boo) ws189:nifti2D paulmc$ fslinfo MNI152_T1_2mm_sliceXY.nii.gz
(boo) ws189:nifti2D paulmc$ ipython
Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec 5 2015, 12:54:16)
Type "copyright", "credits" or "license" for more information.
IPython 5.1.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In : import nibabel as nib
In : i = nib.load('MNI152_T1_2mm_sliceXY.nii.gz')
In : i.shape
Out: (91, 109)
In : i.header.get_zooms()
Out: (2.0, 2.0)
Does anybody else think that this is a problem?
Note that the dimensions for an image of e.g. size (91, 1, 91) will be preserved.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Neuroimaging