def _restrict_gain_matrix(G, info):
 if (not (len(info['chs']) == G.shape[0])):
  raise ValueError(("G.shape[0] and length of info['chs'] do not match: %d != %d" % (G.shape[0], len(info['chs']))))
 sel = pick_types(info, meg='grad', ref_meg=False, exclude=[])
 if (len(sel) > 0):
  G = G[sel]
  logger.info(('    %d planar channels' % len(sel)))
 else:
  sel = pick_types(info, meg='mag', ref_meg=False, exclude=[])
  if (len(sel) > 0):
   G = G[sel]
   logger.info(('    %d magnetometer or axial gradiometer channels' % len(sel)))
  else:
   sel = pick_types(info, meg=False, eeg=True, exclude=[])
   if (len(sel) > 0):
    G = G[sel]
    logger.info(('    %d EEG channels' % len(sel)))
   else:
    warn('Could not find MEG or EEG channels')
 return G

def _restrict_gain_matrix ( G , info ) : if ( not ( len ( info [ 'chs' ] ) == G . shape [ 0 ] ) ) : raise ValueError ( ( "G.shape[0] and length of info['chs'] do not match: %d != %d" % ( G . shape [ 0 ] , len ( info [ 'chs' ] ) ) ) ) sel = pick_types ( info , meg = 'grad' , ref_meg = False , exclude = [ ] ) if ( len ( sel ) > 0 ) : G = G [ sel ] logger . info ( ( '    %d planar channels' % len ( sel ) ) ) else : sel = pick_types ( info , meg = 'mag' , ref_meg = False , exclude = [ ] ) if ( len ( sel ) > 0 ) : G = G [ sel ] logger . info ( ( '    %d magnetometer or axial gradiometer channels' % len ( sel ) ) ) else : sel = pick_types ( info , meg = False , eeg = True , exclude = [ ] ) if ( len ( sel ) > 0 ) : G = G [ sel ] logger . info ( ( '    %d EEG channels' % len ( sel ) ) ) else : warn ( 'Could not find MEG or EEG channels' ) return G
restrict gain matrix entries for optimal depth weighting .