def _pair_grad_sensors_from_ch_names(ch_names):
 pairs = defaultdict(list)
 for (i, name) in enumerate(ch_names):
  if name.startswith('MEG'):
   if name.endswith(('2', '3')):
    key = name[(-4):(-1)]
    pairs[key].append(i)
 pairs = [p for p in pairs.values() if (len(p) == 2)]
 grad_chs = sum(pairs, [])
 return grad_chs

def _pair_grad_sensors_from_ch_names ( ch_names ) : pairs = defaultdict ( list ) for ( i , name ) in enumerate ( ch_names ) : if name . startswith ( 'MEG' ) : if name . endswith ( ( '2' , '3' ) ) : key = name [ ( - 4 ) : ( - 1 ) ] pairs [ key ] . append ( i ) pairs = [ p for p in pairs . values ( ) if ( len ( p ) == 2 ) ] grad_chs = sum ( pairs , [ ] ) return grad_chs
find the indexes for pairing grad channels .