def rotate(data, axis=(1., 0, 0), angle=0., center=None, mode="constant", interpolation="linear"):
    """
    rotates data around axis by a given angle

    Parameters
    ----------
    data: ndarray
        3d array
    axis: tuple
        axis to rotate by angle about
        axis = (x,y,z)
    angle: float
    center: tuple or None
        origin of rotation (cz,cy,cx) in pixels
        if None, center is the middle of data
    
    mode: string 
        boundary mode, one of the following:        
        'constant'
            pads with zeros 
        'edge'
            pads with edge values
        'wrap'
            pads with the repeated version of the input 
    interpolation, string
        interpolation mode, one of the following      
        'linear'
        'nearest'
        
    Returns
    -------
    res: ndarray
        rotated array (same shape as input)

    """
    if center is None:
        center = tuple([s // 2 for s in data.shape])

    cx, cy, cz = center
    m = np.dot(mat4_translate(cx, cy, cz),
               np.dot(mat4_rotate(angle, *axis),
                      mat4_translate(-cx, -cy, -cz)))
    m = np.linalg.inv(m)
    return affine(data, m, mode=mode, interpolation=interpolation)
def rotate ( data , axis = ( 1. , 0 , 0 ) , angle = 0. , center = None , mode = "constant" , interpolation = "linear" ) : if center is None : center = tuple ( [ s // 2 for s in data . shape ] ) cx , cy , cz = center m = np . dot ( mat4_translate ( cx , cy , cz ) , np . dot ( mat4_rotate ( angle , * axis ) , mat4_translate ( - cx , - cy , - cz ) ) ) m = np . linalg . inv ( m ) return affine ( data , m , mode = mode , interpolation = interpolation )
rotates data around axis by a given angle

    Parameters
    ----------
    data: ndarray
        3d array
    axis: tuple
        axis to rotate by angle about
        axis = (x,y,z)
    angle: float
    center: tuple or None
        origin of rotation (cz,cy,cx) in pixels
        if None, center is the middle of data
    
    mode: string 
        boundary mode, one of the following:        
        'constant'
            pads with zeros 
        'edge'
            pads with edge values
        'wrap'
            pads with the repeated version of the input 
    interpolation, string
        interpolation mode, one of the following      
        'linear'
        'nearest'
        
    Returns
    -------
    res: ndarray
        rotated array (same shape as input)