[vtk-developers] vtkNIFTIImageReader coordinates

David Gobbi david.gobbi at gmail.com
Sat Nov 12 09:10:51 EST 2016


Hi Padraig,

Can you show us the raw qform and sform fields from the NIFTI header
itself? In VTK, you can do this as follows:

>>> print(reader.GetNIFTIHeader())

The difference you see between nibabel, ITK, and VTK has to do with
differences in the way these packages deal with the pixdim and the qfac of
the nifti file.  If you print the Direction from the ITK image you might
find that it differs from nibabel, too.

For VTK, you can read all the gory details here:

http://gitlab.kitware.com/vtk/vtk/blob/v7.0.0/IO/Image/vtkNIFTIImageReader.cxx#L738

 - David


On Sat, Nov 12, 2016 at 6:10 AM, padraig <padraig.looney at gmail.com> wrote:

> I have noticed some inconsistencies in how NIFTI images are handled in
> VTK, ITK, and NiBabel. ITK and NiBabel are in agreement with each other and
> differ with VTK on the position of the volume. The VTK output for a file is
> below.
>
> vtkNIFTIImageReader (0x1de67d0)
>   Debug: Off
>   Modified Time: 91
>   Reference Count: 2
>   Registered Events: (none)
>   Executive: 0x1de7720
>   ErrorCode: Success
>   Information: 0x1de6ad0
>   AbortExecute: Off
>   Progress: 1
>   Progress Text: (None)
>   FileName: /home/padraig/Desktop/59674/Seeding/I0000003_59674_sn.nii
>   FileNames: 0
>   FilePrefix: (none)
>   FilePattern: %s.%d
>   FileNameSliceOffset: 0
>   FileNameSliceSpacing: 1
>   DataScalarType: unsigned char
>   NumberOfScalarComponents: 1
>   File Dimensionality: 3
>   File Lower Left: On
>   Swap Bytes: Off
>   DataIncrements: (1, 1)
>   DataExtent: (0, 223, 0, 152, 0, 51)
>   DataSpacing: (0.9195, 1.40018, 2.89048)
>   DataOrigin: (0, 0, 0)
>   HeaderSize: 352
>   Internal File Name: (none)
>   TimeAsVector: Off
>   TimeDimension: 1
>   TimeSpacing: 1
>   RescaleSlope: 1
>   RescaleIntercept: 0
>   QFac: -1
>   QFormMatrix: -1 0 0 102.536 0 -1 0 106.413 0 0 1 -117.265 0 0 0 1
>   SFormMatrix: -1 0 -0 102.536 0 -1 -0 106.413 0 0 1 -117.265 0 0 0 1
>   NIFTIHeader:
>   PlanarRGB: Off
>
> the qform given by nibabel is
>
> >>> ni_ob.get_qform()
> array([[  -0.91949999,    0.        ,    0.        ,  102.53600311],
>        [   0.        ,   -1.40017998,    0.        ,  106.41300201],
>        [   0.        ,    0.        ,    2.89048004,   30.14909935],
>        [   0.        ,    0.        ,    0.        ,    1. ]])
>
>
> ITK has the origin at
>
> [-102.536, -106.413, 30.1491]
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20161112/6bdb0538/attachment.html>


More information about the vtk-developers mailing list