def _bem_specify_els(bem, els, mults):
 sol = np.zeros((len(els), bem['solution'].shape[1]))
 scalp = bem['surfs'][0]
 rrs = np.concatenate([apply_trans(bem['head_mri_t']['trans'], el['rmag']) for el in els], axis=0)
 ws = np.concatenate([el['w'] for el in els])
 (tri_weights, tri_idx) = _project_onto_surface(rrs, scalp)
 tri_weights *= ws
 weights = np.einsum('ij,jik->jk', tri_weights, bem['solution'][scalp['tris'][tri_idx]])
 edges = np.concatenate([[0], np.cumsum([len(el['w']) for el in els])])
 for (ii, (start, stop)) in enumerate(zip(edges[:(-1)], edges[1:])):
  sol[ii] = weights[start:stop].sum(0)
 sol *= mults
 return sol

def _bem_specify_els ( bem , els , mults ) : sol = np . zeros ( ( len ( els ) , bem [ 'solution' ] . shape [ 1 ] ) ) scalp = bem [ 'surfs' ] [ 0 ] rrs = np . concatenate ( [ apply_trans ( bem [ 'head_mri_t' ] [ 'trans' ] , el [ 'rmag' ] ) for el in els ] , axis = 0 ) ws = np . concatenate ( [ el [ 'w' ] for el in els ] ) ( tri_weights , tri_idx ) = _project_onto_surface ( rrs , scalp ) tri_weights *= ws weights = np . einsum ( 'ij,jik->jk' , tri_weights , bem [ 'solution' ] [ scalp [ 'tris' ] [ tri_idx ] ] ) edges = np . concatenate ( [ [ 0 ] , np . cumsum ( [ len ( el [ 'w' ] ) for el in els ] ) ] ) for ( ii , ( start , stop ) ) in enumerate ( zip ( edges [ : ( - 1 ) ] , edges [ 1 : ] ) ) : sol [ ii ] = weights [ start : stop ] . sum ( 0 ) sol *= mults return sol
set up for computing the solution at a set of eeg electrodes .