#NEWLINE# @ verbose #NEWLINE# def pick_channels_forward( orig , include = [ ] , exclude = [ ] , verbose = None ) : #NEWLINE# #INDENT# "Pick channels from forward operator\n\n    Parameters\n    ----------\n    orig : dict\n        A forward solution.\n    include : list of string\n        List of channels to include (if empty, include all available).\n        Defaults to [].\n    exclude : list of string | 'bads'\n        Channels to exclude (if empty, do not exclude any). Defaults to [].\n        If 'bads', then exclude bad channels in orig.\n    verbose : bool, str, int, or None\n        If not None, override default verbose level (see mne.verbose).\n\n    Returns\n    -------\n    res : dict\n        Forward solution restricted to selected channels. If include and\n        exclude are empty it returns orig without copy.\n    " #NEWLINE# orig [ 'info' ] . _check_consistency ( ) #NEWLINE# if ( ( len ( include ) == 0 ) and ( len ( exclude ) == 0 ) ) : #NEWLINE# #INDENT# return orig #NEWLINE# #UNINDENT# exclude = _check_excludes_includes ( exclude , info = orig [ 'info' ] , allow_bads = True ) #NEWLINE# sel_sol = pick_channels ( orig [ 'sol' ] [ 'row_names' ] , include = include , exclude = exclude ) #NEWLINE# sel_info = pick_channels ( orig [ 'info' ] [ 'ch_names' ] , include = include , exclude = exclude ) #NEWLINE# fwd = deepcopy ( orig ) #NEWLINE# if ( len ( sel_sol ) != len ( sel_info ) ) : #NEWLINE# #INDENT# raise ValueError ( 'Forward solution and functional data appear to have different channel names, please check.' ) #NEWLINE# #UNINDENT# nuse = len ( sel_sol ) #NEWLINE# if ( nuse == 0 ) : #NEWLINE# #INDENT# raise ValueError ( 'Nothing remains after picking' ) #NEWLINE# #UNINDENT# logger . info ( ( '    %d out of %d channels remain after picking' % ( nuse , fwd [ 'nchan' ] ) ) ) #NEWLINE# fwd [ 'sol' ] [ 'data' ] = fwd [ 'sol' ] [ 'data' ] [ sel_sol , : ] #NEWLINE# fwd [ '_orig_sol' ] = fwd [ '_orig_sol' ] [ sel_sol , : ] #NEWLINE# fwd [ 'sol' ] [ 'nrow' ] = nuse #NEWLINE# ch_names = [ fwd [ 'sol' ] [ 'row_names' ] [ k ] for k in sel_sol ] #NEWLINE# fwd [ 'nchan' ] = nuse #NEWLINE# fwd [ 'sol' ] [ 'row_names' ] = ch_names #NEWLINE# fwd [ 'info' ] [ 'chs' ] = [ fwd [ 'info' ] [ 'chs' ] [ k ] for k in sel_info ] #NEWLINE# fwd [ 'info' ] . _update_redundant ( ) #NEWLINE# fwd [ 'info' ] [ 'bads' ] = [ b for b in fwd [ 'info' ] [ 'bads' ] if ( b in ch_names ) ] #NEWLINE# if ( fwd [ 'sol_grad' ] is not None ) : #NEWLINE# #INDENT# fwd [ 'sol_grad' ] [ 'data' ] = fwd [ 'sol_grad' ] [ 'data' ] [ sel_sol , : ] #NEWLINE# fwd [ '_orig_sol_grad' ] = fwd [ '_orig_sol_grad' ] [ sel_sol , : ] #NEWLINE# fwd [ 'sol_grad' ] [ 'nrow' ] = nuse #NEWLINE# fwd [ 'sol_grad' ] [ 'row_names' ] = [ fwd [ 'sol_grad' ] [ 'row_names' ] [ k ] for k in sel_sol ] #NEWLINE# #UNINDENT# return fwd