[Neuroimaging] 2D NIFTI images in nibabel

paul mccarthy pauldmccarthy at gmail.com
Thu Sep 1 12:20:55 EDT 2016


Hi Chris,

Aah there's my problem - dim0 was set to 2. It's probably `fslroi` that is
the culprit here.

@Robert - I agree with you - this was a 2D slice of a 3D volume, which was
being presented as 2D (due to the dim0 issue). I feel that it should be
presented as 3D volumetric (which it turns out that nibabel correctly does,
if the image header is valid).

Sorry for the noise and thanks,

Paul

On 1 September 2016 at 16:56, Christopher J Markiewicz <effigies at bu.edu>
wrote:

> 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
> _______________________________________________
> 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/20160901/4c670b22/attachment.html>


More information about the Neuroimaging mailing list