def transpose_axes(data, axes, asaxes='CTZYX'):
 for ax in axes:
  if (ax not in asaxes):
   raise ValueError(('unknown axis %s' % ax))
 shape = data.shape
 for ax in reversed(asaxes):
  if (ax not in axes):
   axes = (ax + axes)
   shape = ((1,) + shape)
 data = data.reshape(shape)
 data = data.transpose([axes.index(ax) for ax in asaxes])
 return data

def transpose_axes ( data , axes , asaxes = 'CTZYX' ) : for ax in axes : if ( ax not in asaxes ) : raise ValueError ( ( 'unknown axis %s' % ax ) ) shape = data . shape for ax in reversed ( asaxes ) : if ( ax not in axes ) : axes = ( ax + axes ) shape = ( ( 1 , ) + shape ) data = data . reshape ( shape ) data = data . transpose ( [ axes . index ( ax ) for ax in asaxes ] ) return data
return data with its axes permuted to match specified axes .