def make_compensator(info, from_, to, exclude_comp_chs=False):
 if (from_ == to):
  return None
 if (from_ != 0):
  C1 = _make_compensator(info, from_)
  comp_from_0 = linalg.inv((np.eye(info['nchan']) - C1))
 if (to != 0):
  C2 = _make_compensator(info, to)
  comp_0_to = (np.eye(info['nchan']) - C2)
 if (from_ != 0):
  if (to != 0):
   comp = np.dot(comp_0_to, comp_from_0)
  else:
   comp = comp_from_0
 else:
  comp = comp_0_to
 if exclude_comp_chs:
  pick = [k for (k, c) in enumerate(info['chs']) if (c['kind'] != FIFF.FIFFV_REF_MEG_CH)]
  if (len(pick) == 0):
   raise ValueError('Nothing remains after excluding the compensation channels')
  comp = comp[pick, :]
 return comp

def make_compensator ( info , from_ , to , exclude_comp_chs = False ) : if ( from_ == to ) : return None if ( from_ != 0 ) : C1 = _make_compensator ( info , from_ ) comp_from_0 = linalg . inv ( ( np . eye ( info [ 'nchan' ] ) - C1 ) ) if ( to != 0 ) : C2 = _make_compensator ( info , to ) comp_0_to = ( np . eye ( info [ 'nchan' ] ) - C2 ) if ( from_ != 0 ) : if ( to != 0 ) : comp = np . dot ( comp_0_to , comp_from_0 ) else : comp = comp_from_0 else : comp = comp_0_to if exclude_comp_chs : pick = [ k for ( k , c ) in enumerate ( info [ 'chs' ] ) if ( c [ 'kind' ] != FIFF . FIFFV_REF_MEG_CH ) ] if ( len ( pick ) == 0 ) : raise ValueError ( 'Nothing remains after excluding the compensation channels' ) comp = comp [ pick , : ] return comp
return compensation matrix eg .