@verbose
def _merge_meg_eeg_fwds(megfwd, eegfwd, verbose=None):
 if ((megfwd is not None) and (eegfwd is not None)):
  if ((megfwd['sol']['data'].shape[1] != eegfwd['sol']['data'].shape[1]) or (megfwd['source_ori'] != eegfwd['source_ori']) or (megfwd['nsource'] != eegfwd['nsource']) or (megfwd['coord_frame'] != eegfwd['coord_frame'])):
   raise ValueError('The MEG and EEG forward solutions do not match')
  fwd = megfwd
  fwd['sol']['data'] = np.r_[(fwd['sol']['data'], eegfwd['sol']['data'])]
  fwd['_orig_sol'] = np.r_[(fwd['_orig_sol'], eegfwd['_orig_sol'])]
  fwd['sol']['nrow'] = (fwd['sol']['nrow'] + eegfwd['sol']['nrow'])
  fwd['sol']['row_names'] = (fwd['sol']['row_names'] + eegfwd['sol']['row_names'])
  if (fwd['sol_grad'] is not None):
   fwd['sol_grad']['data'] = np.r_[(fwd['sol_grad']['data'], eegfwd['sol_grad']['data'])]
   fwd['_orig_sol_grad'] = np.r_[(fwd['_orig_sol_grad'], eegfwd['_orig_sol_grad'])]
   fwd['sol_grad']['nrow'] = (fwd['sol_grad']['nrow'] + eegfwd['sol_grad']['nrow'])
   fwd['sol_grad']['row_names'] = (fwd['sol_grad']['row_names'] + eegfwd['sol_grad']['row_names'])
  fwd['nchan'] = (fwd['nchan'] + eegfwd['nchan'])
  logger.info('    MEG and EEG forward solutions combined')
 elif (megfwd is not None):
  fwd = megfwd
 else:
  fwd = eegfwd
 return fwd

@ verbose def _merge_meg_eeg_fwds ( megfwd , eegfwd , verbose = None ) : if ( ( megfwd is not None ) and ( eegfwd is not None ) ) : if ( ( megfwd [ 'sol' ] [ 'data' ] . shape [ 1 ] != eegfwd [ 'sol' ] [ 'data' ] . shape [ 1 ] ) or ( megfwd [ 'source_ori' ] != eegfwd [ 'source_ori' ] ) or ( megfwd [ 'nsource' ] != eegfwd [ 'nsource' ] ) or ( megfwd [ 'coord_frame' ] != eegfwd [ 'coord_frame' ] ) ) : raise ValueError ( 'The MEG and EEG forward solutions do not match' ) fwd = megfwd fwd [ 'sol' ] [ 'data' ] = np . r_ [ ( fwd [ 'sol' ] [ 'data' ] , eegfwd [ 'sol' ] [ 'data' ] ) ] fwd [ '_orig_sol' ] = np . r_ [ ( fwd [ '_orig_sol' ] , eegfwd [ '_orig_sol' ] ) ] fwd [ 'sol' ] [ 'nrow' ] = ( fwd [ 'sol' ] [ 'nrow' ] + eegfwd [ 'sol' ] [ 'nrow' ] ) fwd [ 'sol' ] [ 'row_names' ] = ( fwd [ 'sol' ] [ 'row_names' ] + eegfwd [ 'sol' ] [ 'row_names' ] ) if ( fwd [ 'sol_grad' ] is not None ) : fwd [ 'sol_grad' ] [ 'data' ] = np . r_ [ ( fwd [ 'sol_grad' ] [ 'data' ] , eegfwd [ 'sol_grad' ] [ 'data' ] ) ] fwd [ '_orig_sol_grad' ] = np . r_ [ ( fwd [ '_orig_sol_grad' ] , eegfwd [ '_orig_sol_grad' ] ) ] fwd [ 'sol_grad' ] [ 'nrow' ] = ( fwd [ 'sol_grad' ] [ 'nrow' ] + eegfwd [ 'sol_grad' ] [ 'nrow' ] ) fwd [ 'sol_grad' ] [ 'row_names' ] = ( fwd [ 'sol_grad' ] [ 'row_names' ] + eegfwd [ 'sol_grad' ] [ 'row_names' ] ) fwd [ 'nchan' ] = ( fwd [ 'nchan' ] + eegfwd [ 'nchan' ] ) logger . info ( '    MEG and EEG forward solutions combined' ) elif ( megfwd is not None ) : fwd = megfwd else : fwd = eegfwd return fwd
merge loaded meg and eeg forward dicts into one dict .