#NEWLINE# @ verbose #NEWLINE# def _make_surface_mapping( info , surf , ch_type = 'meg' , trans = None , mode = 'fast' , n_jobs = 1 , origin = ( 0.0 , 0.0 , 0.04 ) , verbose = None ) : #NEWLINE# #INDENT# "Re-map M/EEG data to a surface\n\n    Parameters\n    ----------\n    info : instance of Info\n        Measurement info.\n    surf : dict\n        The surface to map the data to. The required fields are `'rr'`,\n        `'nn'`, and `'coord_frame'`. Must be in head coordinates.\n    ch_type : str\n        Must be either `'meg'` or `'eeg'`, determines the type of field.\n    trans : None | dict\n        If None, no transformation applied. Should be a Head<->MRI\n        transformation.\n    mode : str\n        Either `'accurate'` or `'fast'`, determines the quality of the\n        Legendre polynomial expansion used. `'fast'` should be sufficient\n        for most applications.\n    n_jobs : int\n        Number of permutations to run in parallel (requires joblib package).\n    origin : array-like, shape (3,) | str\n        Origin of internal and external multipolar moment space in head\n        coords and in meters. The default is ``'auto'``, which means\n        a head-digitization-based origin fit.\n    verbose : bool, str, int, or None\n        If not None, override default verbose level (see mne.verbose).\n\n    Returns\n    -------\n    mapping : array\n        A n_vertices x n_sensors array that remaps the MEG or EEG data,\n        as `new_data = np.dot(mapping, data)`.\n    " #NEWLINE# if ( not all ( ( ( key in surf ) for key in [ 'rr' , 'nn' ] ) ) ) : #NEWLINE# #INDENT# raise KeyError ( 'surf must have both "rr" and "nn"' ) #NEWLINE# #UNINDENT# if ( 'coord_frame' not in surf ) : #NEWLINE# #INDENT# raise KeyError ( 'The surface coordinate frame must be specified in surf["coord_frame"]' ) #NEWLINE# #UNINDENT# if ( mode not in [ 'accurate' , 'fast' ] ) : #NEWLINE# #INDENT# raise ValueError ( ( 'mode must be "accurate" or "fast", not "%s"' % mode ) ) #NEWLINE# #UNINDENT# orig_surf = surf #NEWLINE# surf = transform_surface_to ( deepcopy ( surf ) , 'head' , trans ) #NEWLINE# n_jobs = check_n_jobs ( n_jobs ) #NEWLINE# origin = _check_origin ( origin , info ) #NEWLINE# if ( ch_type not in ( 'meg' , 'eeg' ) ) : #NEWLINE# #INDENT# raise ValueError ( ( 'unknown coil type "%s"' % ch_type ) ) #NEWLINE# #UNINDENT# if ( ch_type == 'meg' ) : #NEWLINE# #INDENT# picks = pick_types ( info , meg = True , eeg = False , ref_meg = False ) #NEWLINE# logger . info ( 'Prepare MEG mapping...' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# picks = pick_types ( info , meg = False , eeg = True , ref_meg = False ) #NEWLINE# logger . info ( 'Prepare EEG mapping...' ) #NEWLINE# #UNINDENT# if ( len ( picks ) == 0 ) : #NEWLINE# #INDENT# raise RuntimeError ( 'cannot map, no channels found' ) #NEWLINE# #UNINDENT# chs = pick_info ( info , picks ) [ 'chs' ] #NEWLINE# if ( ch_type == 'meg' ) : #NEWLINE# #INDENT# coils = _create_meg_coils ( chs , 'normal' , info [ 'dev_head_t' ] ) #NEWLINE# type_str = 'coils' #NEWLINE# miss = 0.0001 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# coils = _create_eeg_els ( chs ) #NEWLINE# type_str = 'electrodes' #NEWLINE# miss = 0.001 #NEWLINE# #UNINDENT# ( int_rad , noise , lut_fun , n_fact ) = _setup_dots ( mode , coils , ch_type ) #NEWLINE# logger . info ( ( 'Computing dot products for %i %s...' % ( len ( coils ) , type_str ) ) ) #NEWLINE# self_dots = _do_self_dots ( int_rad , False , coils , origin , ch_type , lut_fun , n_fact , n_jobs ) #NEWLINE# sel = np . arange ( len ( surf [ 'rr' ] ) ) #NEWLINE# logger . info ( ( 'Computing dot products for %i surface locations...' % len ( sel ) ) ) #NEWLINE# surface_dots = _do_surface_dots ( int_rad , False , coils , surf , sel , origin , ch_type , lut_fun , surface_dots , n_jobs ) #NEWLINE# ch_names = [ c [ 'ch_name' ] for c in chs ] #NEWLINE# fmd = dict ( kind = ch_type , surf = surf , ch_names = ch_names , coils = coils , origin = origin , noise = noise , self_dots = self_dots , surface_dots = surface_dots , int_rad = int_rad , miss = miss ) #NEWLINE# logger . info ( 'Field mapping data ready' ) #NEWLINE# fmd [ 'data' ] = _compute_mapping_matrix ( fmd , info ) #NEWLINE# fmd [ 'surf' ] = orig_surf #NEWLINE# del fmd [ 'self_dots' ] #NEWLINE# del fmd [ 'surface_dots' ] #NEWLINE# del fmd [ 'int_rad' ] #NEWLINE# del fmd [ 'miss' ] #NEWLINE# return fmd