def _get_trans(trans, fro='mri', to='head'):
 if isinstance(trans, string_types):
  if (not op.isfile(trans)):
   raise IOError(('trans file "%s" not found' % trans))
  if (op.splitext(trans)[1] in ['.fif', '.gz']):
   fro_to_t = read_trans(trans)
  else:
   t = np.genfromtxt(trans)
   if ((t.ndim != 2) or (t.shape != (4, 4))):
    raise RuntimeError(('File "%s" did not have 4x4 entries' % trans))
   fro_to_t = Transform(to, fro, t)
 elif isinstance(trans, dict):
  fro_to_t = trans
  trans = 'dict'
 elif (trans is None):
  fro_to_t = Transform(fro, to)
  trans = 'identity'
 else:
  raise ValueError(('transform type %s not known, must be str, dict, or None' % type(trans)))
 fro_to_t = _ensure_trans(fro_to_t, fro, to)
 return (fro_to_t, trans)

def _get_trans ( trans , fro = 'mri' , to = 'head' ) : if isinstance ( trans , string_types ) : if ( not op . isfile ( trans ) ) : raise IOError ( ( 'trans file "%s" not found' % trans ) ) if ( op . splitext ( trans ) [ 1 ] in [ '.fif' , '.gz' ] ) : fro_to_t = read_trans ( trans ) else : t = np . genfromtxt ( trans ) if ( ( t . ndim != 2 ) or ( t . shape != ( 4 , 4 ) ) ) : raise RuntimeError ( ( 'File "%s" did not have 4x4 entries' % trans ) ) fro_to_t = Transform ( to , fro , t ) elif isinstance ( trans , dict ) : fro_to_t = trans trans = 'dict' elif ( trans is None ) : fro_to_t = Transform ( fro , to ) trans = 'identity' else : raise ValueError ( ( 'transform type %s not known, must be str, dict, or None' % type ( trans ) ) ) fro_to_t = _ensure_trans ( fro_to_t , fro , to ) return ( fro_to_t , trans )
get mri_head_t from mri filename .