NiBabel

Access a cacophony of neuro-imaging file formats

Previous topic

nibabel.orientations.io_orientation

Next topic

nibabel.quaternions

Reggie -- the one

nibabel.orientations.orientation_affine

nibabel.orientations.orientation_affine(ornt, shape)

Affine transform resulting from transforms implied in ornt

Imagine you have an array arr of shape shape, and you apply the transforms implied by ornt (more below), to get tarr. tarr may have a different shape shape_prime. This routine returns the affine that will take a array coordinate for tarr and give you the corresponding array coordinate in arr.

Parameters :

ornt : (n,2) ndarray

orientation transform. ornt[N,1]` is flip of axis N of the array implied by `shape`, where 1 means no flip and -1 means flip.  For example, if ``N==0 and ornt[0,1] == -1, and there’s an array arr of shape shape, the flip would correspond to the effect of np.flipud(arr). ornt[:,0] is the transpose that needs to be done to the implied array, as in arr.transpose(ornt[:,0])

shape : length n sequence

shape of array you may transform with ornt

Returns :

transformed_affine : (n+1,n+1) ndarray

An array arr (shape shape) might be transformed according to ornt, resulting in a transformed array tarr. transformed_affine is the transform that takes you from array coordinates in tarr to array coordinates in arr.