def _ch_neighbor_connectivity(ch_names, neighbors):
 if (len(ch_names) != len(neighbors)):
  raise ValueError('`ch_names` and `neighbors` must have the same length')
 set_neighbors = set([c for d in neighbors for c in d])
 rest = (set(ch_names) - set_neighbors)
 if (len(rest) > 0):
  raise ValueError('Some of your neighbors are not present in the list of channel names')
 for neigh in neighbors:
  if ((not isinstance(neigh, list)) and (not all((isinstance(c, string_types) for c in neigh)))):
   raise ValueError('`neighbors` must be a list of lists of str')
 ch_connectivity = np.eye(len(ch_names), dtype=bool)
 for (ii, neigbs) in enumerate(neighbors):
  ch_connectivity[(ii, [ch_names.index(i) for i in neigbs])] = True
 ch_connectivity = sparse.csr_matrix(ch_connectivity)
 return ch_connectivity

def _ch_neighbor_connectivity ( ch_names , neighbors ) : if ( len ( ch_names ) != len ( neighbors ) ) : raise ValueError ( '`ch_names` and `neighbors` must have the same length' ) set_neighbors = set ( [ c for d in neighbors for c in d ] ) rest = ( set ( ch_names ) - set_neighbors ) if ( len ( rest ) > 0 ) : raise ValueError ( 'Some of your neighbors are not present in the list of channel names' ) for neigh in neighbors : if ( ( not isinstance ( neigh , list ) ) and ( not all ( ( isinstance ( c , string_types ) for c in neigh ) ) ) ) : raise ValueError ( '`neighbors` must be a list of lists of str' ) ch_connectivity = np . eye ( len ( ch_names ) , dtype = bool ) for ( ii , neigbs ) in enumerate ( neighbors ) : ch_connectivity [ ( ii , [ ch_names . index ( i ) for i in neigbs ] ) ] = True ch_connectivity = sparse . csr_matrix ( ch_connectivity ) return ch_connectivity
compute sensor connectivity matrix .