#NEWLINE# def _plot_sources_epochs( ica , epochs , picks , exclude , start , stop , show , title , block ) : #NEWLINE# #INDENT# 'Function for plotting the components as epochs.' #NEWLINE# data = ica . _transform_epochs ( epochs , concatenate = True ) #NEWLINE# eog_chs = pick_types ( epochs . info , meg = False , eog = True , ref_meg = False ) #NEWLINE# ecg_chs = pick_types ( epochs . info , meg = False , ecg = True , ref_meg = False ) #NEWLINE# c_names = [ ( 'ICA %03d' % x ) for x in range ( ica . n_components_ ) ] #NEWLINE# ch_types = np . repeat ( 'misc' , n_epochs . n_components_ ) #NEWLINE# for eog_idx in eog_chs : #NEWLINE# #INDENT# c_names . append ( epochs . ch_names [ eog_idx ] ) #NEWLINE# ch_types = np . append ( ch_types , 'eog' ) #NEWLINE# #UNINDENT# for ecg_idx in ecg_chs : #NEWLINE# #INDENT# c_names . append ( epochs . ch_names [ ecg_idx ] ) #NEWLINE# ch_types = np . append ( ch_types , 'ecg' ) #NEWLINE# #UNINDENT# extra_picks = np . append ( eog_chs , ecg_chs ) . astype ( int ) #NEWLINE# if ( len ( extra_picks ) > 0 ) : #NEWLINE# #INDENT# eog_ecg_data = np . concatenate ( epochs . get_data ( ) [ : , extra_picks ] , axis = 1 ) #NEWLINE# data = np . append ( data , eog_ecg_data , axis = 0 ) #NEWLINE# #UNINDENT# scalings = _handle_default ( 'scalings_plot_raw' ) #NEWLINE# scalings [ 'misc' ] = 5.0 #NEWLINE# info = create_info ( ch_names = c_names , sfreq = epochs . info [ 'sfreq' ] , ch_types = ch_types ) #NEWLINE# info [ 'projs' ] = list ( ) #NEWLINE# info [ 'bads' ] = [ c_names [ x ] for x in exclude ] #NEWLINE# if ( title is None ) : #NEWLINE# #INDENT# title = 'ICA components' #NEWLINE# #UNINDENT# if ( picks is None ) : #NEWLINE# #INDENT# picks = list ( range ( ica . n_components_ ) ) #NEWLINE# #UNINDENT# if ( start is None ) : #NEWLINE# #INDENT# start = 0 #NEWLINE# #UNINDENT# if ( stop is None ) : #NEWLINE# #INDENT# stop = ( start + 20 ) #NEWLINE# stop = min ( stop , len ( epochs . events ) ) #NEWLINE# #UNINDENT# for idx in range ( len ( extra_picks ) ) : #NEWLINE# #INDENT# picks = np . append ( picks , ( ica . n_components_ + idx ) ) #NEWLINE# #UNINDENT# n_epochs = ( stop - start ) #NEWLINE# if ( n_epochs <= 0 ) : #NEWLINE# #INDENT# raise RuntimeError ( 'Stop must be larger than start.' ) #NEWLINE# #UNINDENT# params = { #NEWLINE# #INDENT# 'ica' : ica , #NEWLINE# 'epochs' : epochs , #NEWLINE# 'info' : info , #NEWLINE# 'orig_data' : data , #NEWLINE# 'bads' : list ( ) , #NEWLINE# 'bad_color' : ( 1.0 , 0.0 , 0.0 ) , #NEWLINE# 't_start' : ( start * len ( epochs . times ) ) , #NEWLINE# #UNINDENT# } #NEWLINE# params [ 'label_click_fun' ] = partial ( _label_clicked , params = params ) #NEWLINE# _prepare_mne_browse_epochs ( params , projs = list ( ) , n_channels = 20 , n_epochs = n_epochs , scalings = scalings , title = title , picks = picks , order = [ 'misc' , 'eog' , 'ecg' ] ) #NEWLINE# params [ 'plot_update_proj_callback' ] = _update_epoch_data #NEWLINE# _update_epoch_data ( params ) #NEWLINE# params [ 'hsel_patch' ] . set_x ( params [ 't_start' ] ) #NEWLINE# callback_close = partial ( _close_epochs_event , params = params ) #NEWLINE# params [ 'fig' ] . canvas . mpl_connect ( 'close_event' , callback_close ) #NEWLINE# try : #NEWLINE# #INDENT# plt_show ( show , block = block ) #NEWLINE# #UNINDENT# except TypeError : #NEWLINE# #INDENT# plt_show ( show ) #NEWLINE# #UNINDENT# return params [ 'fig' ]