[Neuroimaging] 2D NIFTI images in nibabel
Christopher J Markiewicz
effigies at bu.edu
Thu Sep 1 11:56:57 EDT 2016
Paul,
Can you give us the output of:
>>> print(nib.load(nifti_file).header._structarr['dim'])
If the first number is 2, nibabel will (correctly) interpret to mean it
is to ignore dimensions 3+. If the first number is 3, then there's a bug.
That said, perhaps it is reasonable that a volumetric image should have
a minimum of three dimensions?
Chris
On 09/01/2016 05:14 AM, paul mccarthy wrote:
> Howdy all,
>
>
> Nibabel truncates the third dimension of a NIFTI image with dim3=1.
>
>
> (boo) ws189:nifti2D paulmc$ fslinfo MNI152_T1_2mm_sliceXY.nii.gz
> data_type INT16
> dim1 91
> dim2 109
> dim3 1
> dim4 1
> datatype 4
> pixdim1 2.000000
> pixdim2 2.000000
> pixdim3 2.000000
> pixdim4 1.000000
> cal_max 8000.0000
> cal_min 3000.0000
> file_type NIFTI-1+
>
>
> (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 [1]: import nibabel as nib
>
> In [2]: i = nib.load('MNI152_T1_2mm_sliceXY.nii.gz')
>
> In [3]: i.shape
> Out[3]: (91, 109)
>
> In [4]: i.header.get_zooms()
> Out[4]: (2.0, 2.0)
>
> In [5]:
>
>
> 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.
>
> Cheers,
>
> Paul
>
>
> _______________________________________________
> Neuroimaging mailing list
> Neuroimaging at python.org
> https://mail.python.org/mailman/listinfo/neuroimaging
>
--
Christopher J Markiewicz
Ph.D. Candidate, Quantitative Neuroscience Laboratory
Boston University
More information about the Neuroimaging
mailing list