Example #1
0
   def __init__(self, affine, axis_names, lps=True):

      """
      >>> xyz = XYZTransform(np.diag([3,4,5,1]), 'ijk')
      >>> xyz
      XYZTransform(
         function_domain=CoordinateSystem(coord_names=('i', 'j', 'k'), name='voxel', coord_dtype=float64),
         function_range=CoordinateSystem(coord_names=('x+LR', 'y+PA', 'z+SI'), name='world', coord_dtype=float64),
         affine=array([[ 3.,  0.,  0.,  0.],
                       [ 0.,  4.,  0.,  0.],
                       [ 0.,  0.,  5.,  0.],
                       [ 0.,  0.,  0.,  1.]])
      )
      >>> 
      """

      if affine.shape != (4,4):
          raise ValueError('affine must be a 4x4 matrix representing an affine transformation in homogeneous coordinates')
      if lps:
         xyz = lps_output_coordnames
      else:
         xyz = ras_output_coordnames
      AffineTransform.__init__(self, CS(axis_names, name='voxel'), 
                               CS(xyz, name='world'), affine)
Example #2
0
 def __init__(self, function_domain, function_range, matrix):
     ndim = matrix.shape[0]
     T = np.identity(ndim+1, dtype=matrix.dtype)
     T[:-1,:-1] = matrix
     AffineTransform.__init__(self, function_domain, function_range, T)
Example #3
0
 def __init__(self, function_domain, function_range, matrix):
     ndim = matrix.shape[0]
     T = np.identity(ndim + 1, dtype=matrix.dtype)
     T[:-1, :-1] = matrix
     AffineTransform.__init__(self, function_domain, function_range, T)