def _as_meg_type_evoked(evoked, ch_type='grad', mode='fast'):
 evoked = evoked.copy()
 if (ch_type not in ['mag', 'grad']):
  raise ValueError(('to_type must be "mag" or "grad", not "%s"' % ch_type))
 pick_from = pick_types(evoked.info, meg=True, eeg=False, ref_meg=False)
 pick_to = pick_types(evoked.info, meg=ch_type, eeg=False, ref_meg=False)
 if (len(pick_to) == 0):
  raise ValueError('No channels matching the destination channel type found in info. Please pass an evoked containingboth the original and destination channels. Only the locations of the destination channels will be used for interpolation.')
 info_from = pick_info(evoked.info, pick_from)
 info_to = pick_info(evoked.info, pick_to)
 mapping = _map_meg_channels(info_from, info_to, mode=mode)
 data = np.dot(mapping, evoked.data[pick_from])
 evoked.pick_types(meg=ch_type, eeg=False, ref_meg=False)
 evoked.data = data
 for ch in evoked.info['chs']:
  ch['ch_name'] += '_virtual'
 evoked.info._update_redundant()
 evoked.info._check_consistency()
 return evoked

def _as_meg_type_evoked ( evoked , ch_type = 'grad' , mode = 'fast' ) : evoked = evoked . copy ( ) if ( ch_type not in [ 'mag' , 'grad' ] ) : raise ValueError ( ( 'to_type must be "mag" or "grad", not "%s"' % ch_type ) ) pick_from = pick_types ( evoked . info , meg = True , eeg = False , ref_meg = False ) pick_to = pick_types ( evoked . info , meg = ch_type , eeg = False , ref_meg = False ) if ( len ( pick_to ) == 0 ) : raise ValueError ( 'No channels matching the destination channel type found in info. Please pass an evoked containingboth the original and destination channels. Only the locations of the destination channels will be used for interpolation.' ) info_from = pick_info ( evoked . info , pick_from ) info_to = pick_info ( evoked . info , pick_to ) mapping = _map_meg_channels ( info_from , info_to , mode = mode ) data = np . dot ( mapping , evoked . data [ pick_from ] ) evoked . pick_types ( meg = ch_type , eeg = False , ref_meg = False ) evoked . data = data for ch in evoked . info [ 'chs' ] : ch [ 'ch_name' ] += '_virtual' evoked . info . _update_redundant ( ) evoked . info . _check_consistency ( ) return evoked
compute virtual evoked using interpolated fields in mag/grad channels .