NiBabel

Access a cacophony of neuro-imaging file formats

Previous topic

nibabel.orientations.apply_orientation

Next topic

nibabel.orientations.io_orientation

This Page

Reggie -- the one

nibabel.orientations.flip_axis

nibabel.orientations.flip_axis(arr, axis=0)

Flip contents of axis in array arr

flip_axis is the same transform as np.flipud, but for any axis. For example flip_axis(arr, axis=0) is the same transform as np.flipud(arr), and flip_axis(arr, axis=1) is the same transform as np.fliplr(arr)

Parameters :

arr : array-like

axis : int, optional

axis to flip. Default axis == 0

Returns :

farr : array

Array with axis axis flipped

Examples

>>> a = np.arange(6).reshape((2,3))
>>> a
array([[0, 1, 2],
       [3, 4, 5]])
>>> flip_axis(a, axis=0)
array([[3, 4, 5],
       [0, 1, 2]])
>>> flip_axis(a, axis=1)
array([[2, 1, 0],
       [5, 4, 3]])