NiBabel

Access a cacophony of neuro-imaging file formats

Previous topic

nibabel.orientations.io_orientation

Next topic

nibabel.quaternions

This Page

Reggie -- the one

nibabel.orientations.ornt2axcodes

nibabel.orientations.ornt2axcodes(ornt, labels=None)

Convert orientation ornt to labels for axis directions

Parameters :

ornt : (N,2) array-like

orientation array - see io_orientation docstring

labels : optional, None or sequence of (2,) sequences

(2,) sequences are labels for (beginning, end) of output axis. That is, if the first row in ornt is [1, 1], and the second (2,) sequence in labels is (‘back’, ‘front’) then the first returned axis code will be 'front'. If the first row in ornt had been [1, -1] then the first returned value would have been 'back'. If None, equivalent to (('L','R'),('P','A'),('I','S')) - that is - RAS axes.

Returns :

axcodes : (N,) tuple

labels for positive end of voxel axes. Dropped axes get a label of None.

Examples

>>> ornt2axcodes([[1, 1],[0,-1],[2,1]], (('L','R'),('B','F'),('D','U')))
('F', 'L', 'U')