io.nibcompat

Module: io.nibcompat

Compatibility functions for older versions of nibabel

Nibabel <= 1.3.0 do not have these attributes:

  • header
  • affine
  • dataobj

The equivalents for these older versions of nibabel are:

  • obj.get_header()
  • obj.get_affine()
  • obj._data

With old nibabel, getting unscaled data used read_img_data(img, prefer=”unscaled”). Newer nibabel should prefer the `get_unscaled method on the image proxy object

Functions

nipy.io.nibcompat.get_affine(img)

Return affine from nibabel image

Parameters:

img : SpatialImage instance

Instance of nibabel SpatialImage class

Returns:

affine : object

affine object from img

nipy.io.nibcompat.get_dataobj(img)

Return data object for nibabel image

Parameters:

img : SpatialImage instance

Instance of nibabel SpatialImage class

Returns:

dataobj : object

ArrayProxy or ndarray object containing data for img

nipy.io.nibcompat.get_header(img)

Return header from nibabel image

Parameters:

img : SpatialImage instance

Instance of nibabel SpatialImage class

Returns:

header : object

header object from img

nipy.io.nibcompat.get_unscaled_data(img)

Get the data from a nibabel image, maybe without applying scaling

Parameters:

img : SpatialImage instance

Instance of nibabel SpatialImage class

Returns:

data : ndarray

Data as loaded from image, not applying scaling if this can be avoided