#NEWLINE# def _plot_ica_sources_evoked( evoked , picks , exclude , title , show , labels = None ) : #NEWLINE# #INDENT# 'Plot average over epochs in ICA space\n\n    Parameters\n    ----------\n    evoked : instance of mne.Evoked\n        The Evoked to be used.\n    picks : int | array_like of int | None.\n        The components to be displayed. If None, plot will show the\n        sources in the order as fitted.\n    exclude : array_like of int\n        The components marked for exclusion. If None (default), ICA.exclude\n        will be used.\n    title : str\n        The figure title.\n    show : bool\n        Show figure if True.\n    labels : None | dict\n        The ICA labels attribute.\n    ' #NEWLINE# import matplotlib.pyplot as plt #NEWLINE# if ( title is None ) : #NEWLINE# #INDENT# title = 'Reconstructed latent sources, time-locked' #NEWLINE# #UNINDENT# ( fig , axes ) = plt . subplots ( 1 ) #NEWLINE# ax = axes #NEWLINE# axes = [ axes ] #NEWLINE# idxs = [ 0 ] #NEWLINE# times = ( evoked . times * 1000.0 ) #NEWLINE# lines = list ( ) #NEWLINE# texts = list ( ) #NEWLINE# if ( picks is None ) : #NEWLINE# #INDENT# picks = np . arange ( evoked . data . shape [ 0 ] ) #NEWLINE# #UNINDENT# picks = np . sort ( picks ) #NEWLINE# idxs = [ picks ] #NEWLINE# color = 'r' #NEWLINE# if ( labels is not None ) : #NEWLINE# #INDENT# labels_used = [ k for k in labels if ( '/' not in k ) ] #NEWLINE# #UNINDENT# exclude_labels = list ( ) #NEWLINE# for ii in picks : #NEWLINE# #INDENT# if ( ii in exclude ) : #NEWLINE# #INDENT# line_label = ( 'ICA %03d' % ( ii + 1 ) ) #NEWLINE# if ( labels is not None ) : #NEWLINE# #INDENT# annot = list ( ) #NEWLINE# for this_label in labels_used : #NEWLINE# #INDENT# indices = labels [ this_label ] #NEWLINE# if ( ii in indices ) : #NEWLINE# #INDENT# annot . append ( this_label ) #NEWLINE# #UNINDENT# #UNINDENT# line_label += ( ' - ' + ', ' . join ( annot ) ) #NEWLINE# #UNINDENT# exclude_labels . append ( line_label ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# exclude_labels . append ( None ) #NEWLINE# #UNINDENT# #UNINDENT# if ( labels is not None ) : #NEWLINE# #INDENT# unique_labels = set ( [ k . split ( ' - ' ) [ 1 ] for k in exclude_labels if k ] ) #NEWLINE# label_colors = plt . cm . rainbow ( np . linspace ( 0 , 1 , len ( unique_labels ) ) ) #NEWLINE# label_colors = dict ( zip ( unique_labels , label_colors ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# label_colors = dict ( ( ( k , 'red' ) for k in exclude_labels ) ) #NEWLINE# #UNINDENT# for ( exc_label , ii ) in zip ( exclude_labels , picks ) : #NEWLINE# #INDENT# if ( exc_label is not None ) : #NEWLINE# #INDENT# if ( ' - ' in exc_label ) : #NEWLINE# #INDENT# key = exc_label . split ( ' - ' ) [ 1 ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# key = exc_label #NEWLINE# #UNINDENT# color = label_colors [ key ] #NEWLINE# lines . extend ( ax . plot ( times , evoked . data [ ii ] . T , picker = 3.0 , zorder = 2 , color = color , label = exc_label ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# lines . extend ( ax . plot ( times , evoked . data [ ii ] . T , picker = 3.0 , color = 'k' , zorder = 1 ) ) #NEWLINE# #UNINDENT# #UNINDENT# ax . set_title ( title ) #NEWLINE# ax . set_xlim ( times [ [ 0 , ( - 1 ) ] ] ) #NEWLINE# ax . set_xlabel ( 'Time (ms)' ) #NEWLINE# ax . set_ylabel ( '(NA)' ) #NEWLINE# if ( len ( exclude ) > 0 ) : #NEWLINE# #INDENT# plt . legend ( loc = 'best' ) #NEWLINE# #UNINDENT# tight_layout ( fig = fig ) #NEWLINE# texts . append ( ax . text ( 0 , 0 , 'blank' , zorder = 3 , verticalalignment = 'baseline' , horizontalalignment = 'left' , fontweight = 'bold' , alpha = 0 ) ) #NEWLINE# lines = [ lines ] #NEWLINE# ch_names = evoked . ch_names #NEWLINE# from matplotlib import patheffects #NEWLINE# path_effects = [ patheffects . withStroke ( linewidth = 2 , foreground = 'w' , alpha = 0.75 ) ] #NEWLINE# params = dict ( axes = axes , texts = texts , lines = lines , idxs = idxs , ch_names = ch_names , need_draw = False , path_effects = path_effects ) #NEWLINE# fig . canvas . mpl_connect ( 'pick_event' , partial ( _butterfly_onpick , params = params ) ) #NEWLINE# fig . canvas . mpl_connect ( 'button_press_event' , partial ( _butterfly_on_button_press , params = params ) ) #NEWLINE# plt_show ( show ) #NEWLINE# return fig