#NEWLINE# def pick_channels( ch_names , include , exclude = [ ] ) : #NEWLINE# #INDENT# 'Pick channels by names\n\n    Returns the indices of the good channels in ch_names.\n\n    Parameters\n    ----------\n    ch_names : list of string\n        List of channels.\n    include : list of string\n        List of channels to include (if empty include all available).\n    exclude : list of string\n        List of channels to exclude (if empty do not exclude any channel).\n        Defaults to [].\n\n    See Also\n    --------\n    pick_channels_regexp, pick_types\n\n    Returns\n    -------\n    sel : array of int\n        Indices of good channels.\n    ' #NEWLINE# if ( len ( np . unique ( ch_names ) ) != len ( ch_names ) ) : #NEWLINE# #INDENT# raise RuntimeError ( 'ch_names is not a unique list, picking is unsafe' ) #NEWLINE# #UNINDENT# _check_excludes_includes ( include ) #NEWLINE# _check_excludes_includes ( exclude ) #NEWLINE# if ( not isinstance ( include , set ) ) : #NEWLINE# #INDENT# include = set ( include ) #NEWLINE# #UNINDENT# if ( not isinstance ( exclude , set ) ) : #NEWLINE# #INDENT# exclude = set ( exclude ) #NEWLINE# #UNINDENT# sel = [ ] #NEWLINE# for ( k , name ) in enumerate ( ch_names ) : #NEWLINE# #INDENT# if ( ( ( len ( include ) == 0 ) or ( name in include ) ) and ( name not in exclude ) ) : #NEWLINE# #INDENT# sel . append ( k ) #NEWLINE# #UNINDENT# #UNINDENT# return np . array ( sel , int )