def _ensure_trans(trans, fro='mri', to='head'):
 if isinstance(fro, string_types):
  from_str = fro
  from_const = _str_to_frame[fro]
 else:
  from_str = _frame_to_str[fro]
  from_const = fro
 del fro
 if isinstance(to, string_types):
  to_str = to
  to_const = _str_to_frame[to]
 else:
  to_str = _frame_to_str[to]
  to_const = to
 del to
 err_str = ('trans must go %s<->%s, provided' % (from_str, to_str))
 if (trans is None):
  raise ValueError(('%s None' % err_str))
 if (set([trans['from'], trans['to']]) != set([from_const, to_const])):
  raise ValueError(('%s trans is %s->%s' % (err_str, _frame_to_str[trans['from']], _frame_to_str[trans['to']])))
 if (trans['from'] != from_const):
  trans = invert_transform(trans)
 return trans

def _ensure_trans ( trans , fro = 'mri' , to = 'head' ) : if isinstance ( fro , string_types ) : from_str = fro from_const = _str_to_frame [ fro ] else : from_str = _frame_to_str [ fro ] from_const = fro del fro if isinstance ( to , string_types ) : to_str = to to_const = _str_to_frame [ to ] else : to_str = _frame_to_str [ to ] to_const = to del to err_str = ( 'trans must go %s<->%s, provided' % ( from_str , to_str ) ) if ( trans is None ) : raise ValueError ( ( '%s None' % err_str ) ) if ( set ( [ trans [ 'from' ] , trans [ 'to' ] ] ) != set ( [ from_const , to_const ] ) ) : raise ValueError ( ( '%s trans is %s->%s' % ( err_str , _frame_to_str [ trans [ 'from' ] ] , _frame_to_str [ trans [ 'to' ] ] ) ) ) if ( trans [ 'from' ] != from_const ) : trans = invert_transform ( trans ) return trans
ensure we have the proper transform .