code: def read_transform(filename, dimension=2, precision='float'):
      
      filename = os.path.expanduser(filename)
      if not os.path.exists(filename):
          raise ValueError('filename does not exist!')
  
      libfn1 = utils.get_lib_fn('getTransformDimensionFromFile')
      dimension = libfn1(filename)
  
      libfn2 = utils.get_lib_fn('getTransformNameFromFile')
      transform_type = libfn2(filename)
  
      libfn3 = utils.get_lib_fn('readTransform%s%i' % (utils.short_ptype(precision), dimension))
      itk_tx = libfn3(filename, dimension, precision)
  
      return tio.ANTsTransform(precision=precision, dimension=dimension, 
                              transform_type=transform_type, pointer=itk_tx)
docs: Read a transform from file
  
      ANTsR function: `readAntsrTransform`
  
      Arguments
      ---------
      filename : string
          filename of transform
  
      dimension : integer
          spatial dimension of transform
  
      precision : string
          numerical precision of transform
      
      Returns
      -------
      ANTsTransform
  
      Example
      -------
      >>> import ants
      >>> tx = ants.new_ants_transform(dimension=2)
      >>> tx.set_parameters((0.9,0,0,1.1,10,11))
      >>> ants.write_transform(tx, '~/desktop/tx.mat')
      >>> tx2 = ants.read_transform('~/desktop/tx.mat')