#NEWLINE# def _plot_traces( params ) : #NEWLINE# #INDENT# ' Helper for plotting concatenated epochs ' #NEWLINE# params [ 'text' ] . set_visible ( False ) #NEWLINE# ax = params [ 'ax' ] #NEWLINE# butterfly = params [ 'butterfly' ] #NEWLINE# if butterfly : #NEWLINE# #INDENT# ch_start = 0 #NEWLINE# n_channels = len ( params [ 'picks' ] ) #NEWLINE# data = ( params [ 'data' ] * params [ 'butterfly_scale' ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ch_start = params [ 'ch_start' ] #NEWLINE# n_channels = params [ 'n_channels' ] #NEWLINE# data = ( params [ 'data' ] * params [ 'scale_factor' ] ) #NEWLINE# #UNINDENT# offsets = params [ 'offsets' ] #NEWLINE# lines = params [ 'lines' ] #NEWLINE# epochs = params [ 'epochs' ] #NEWLINE# n_times = len ( epochs . times ) #NEWLINE# tick_list = list ( ) #NEWLINE# start_idx = int ( ( params [ 't_start' ] / n_times ) ) #NEWLINE# end = ( params [ 't_start' ] + params [ 'duration' ] ) #NEWLINE# end_idx = int ( ( end / n_times ) ) #NEWLINE# xlabels = params [ 'labels' ] [ start_idx : ] #NEWLINE# event_ids = params [ 'epochs' ] . events [ : , 2 ] #NEWLINE# params [ 'ax2' ] . set_xticklabels ( event_ids [ start_idx : ] ) #NEWLINE# ax . set_xticklabels ( xlabels ) #NEWLINE# ylabels = ax . yaxis . get_ticklabels ( ) #NEWLINE# for line_idx in range ( n_channels ) : #NEWLINE# #INDENT# ch_idx = ( line_idx + ch_start ) #NEWLINE# if ( line_idx >= len ( lines ) ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ch_idx < len ( params [ 'ch_names' ] ) ) : #NEWLINE# #INDENT# if butterfly : #NEWLINE# #INDENT# ch_type = params [ 'types' ] [ ch_idx ] #NEWLINE# if ( ch_type == 'grad' ) : #NEWLINE# #INDENT# offset = offsets [ 0 ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ch_type == 'mag' ) : #NEWLINE# #INDENT# offset = offsets [ 1 ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( n_channels == 'eeg' ) : #NEWLINE# #INDENT# offset = offsets [ 2 ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ch_type == 'eog' ) : #NEWLINE# #INDENT# offset = offsets [ 3 ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ch_type == 'ecg' ) : #NEWLINE# #INDENT# offset = offsets [ 4 ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# lines [ line_idx ] . set_segments ( list ( ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# tick_list += [ params [ 'ch_names' ] [ ch_idx ] ] #NEWLINE# offset = offsets [ line_idx ] #NEWLINE# #UNINDENT# this_data = data [ ch_idx ] #NEWLINE# ydata = ( offset - this_data ) #NEWLINE# xdata = params [ 'times' ] [ : params [ 'duration' ] ] #NEWLINE# num_epochs = np . min ( [ params [ 'n_epochs' ] , len ( epochs . events ) ] ) #NEWLINE# segments = np . split ( np . array ( ( xdata , ydata ) ) . T , num_epochs ) #NEWLINE# ch_name = params [ 'ch_names' ] [ ch_idx ] #NEWLINE# if ( ch_name in params [ 'info' ] [ 'bads' ] ) : #NEWLINE# #INDENT# if ( not butterfly ) : #NEWLINE# #INDENT# this_color = params [ 'bad_color' ] #NEWLINE# ylabels [ line_idx ] . set_color ( this_color ) #NEWLINE# #UNINDENT# this_color = np . tile ( params [ 'bad_color' ] , ( num_epochs , 1 ) ) #NEWLINE# for bad_idx in params [ 'bads' ] : #NEWLINE# #INDENT# if ( ( bad_idx < start_idx ) or ( bad_idx > end_idx ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# this_color [ ( bad_idx - start_idx ) ] = ( 1.0 , 0.0 , 0.0 ) #NEWLINE# #UNINDENT# lines [ line_idx ] . set_zorder ( 2 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# this_color = params [ 'colors' ] [ ch_idx ] [ start_idx : end_idx ] #NEWLINE# lines [ line_idx ] . set_zorder ( 3 ) #NEWLINE# if ( not butterfly ) : #NEWLINE# #INDENT# ylabels [ line_idx ] . set_color ( 'black' ) #NEWLINE# #UNINDENT# #UNINDENT# lines [ line_idx ] . set_segments ( segments ) #NEWLINE# lines [ line_idx ] . set_color ( this_color ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# lines [ line_idx ] . set_segments ( list ( ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# ax . set_xlim ( params [ 'times' ] [ 0 ] , ( params [ 'times' ] [ 0 ] + params [ 'duration' ] ) , False ) #NEWLINE# params [ 'ax2' ] . set_xlim ( params [ 'times' ] [ 0 ] , ( params [ 'times' ] [ 0 ] + params [ 'duration' ] ) , False ) #NEWLINE# if butterfly : #NEWLINE# #INDENT# factor = ( ( - 1.0 ) / params [ 'butterfly_scale' ] ) #NEWLINE# labels = np . empty ( 20 , dtype = 'S15' ) #NEWLINE# labels . fill ( '' ) #NEWLINE# ticks = ax . get_yticks ( ) #NEWLINE# idx_offset = 1 #NEWLINE# if ( 'grad' in params [ 'types' ] ) : #NEWLINE# #INDENT# labels [ ( idx_offset + 1 ) ] = '0.00' #NEWLINE# for idx in [ idx_offset , ( idx_offset + 2 ) ] : #NEWLINE# #INDENT# labels [ idx ] = '{0:.2f}' . format ( ( ( ( ( ticks [ idx ] - offsets [ 0 ] ) * params [ 'scalings' ] [ 'grad' ] ) * 10000000000000.0 ) * factor ) ) #NEWLINE# #UNINDENT# idx_offset += 4 #NEWLINE# #UNINDENT# if ( 'mag' in params [ 'types' ] ) : #NEWLINE# #INDENT# labels [ ( idx_offset + 1 ) ] = '0.00' #NEWLINE# for idx in [ idx_offset , ( idx_offset + 2 ) ] : #NEWLINE# #INDENT# labels [ idx ] = '{0:.2f}' . format ( ( ( ( ( ticks [ idx ] - offsets [ 1 ] ) * params [ 'scalings' ] [ 'mag' ] ) * 1000000000000000.0 ) * factor ) ) #NEWLINE# #UNINDENT# idx_offset += 4 #NEWLINE# #UNINDENT# if ( 'eeg' in params [ 'types' ] ) : #NEWLINE# #INDENT# labels [ ( idx_offset + 1 ) ] = '0.00' #NEWLINE# for idx in [ idx_offset , ( idx_offset + 2 ) ] : #NEWLINE# #INDENT# labels [ idx ] = '{0:.2f}' . format ( ( ( ( ( ticks [ idx ] - offsets [ 2 ] ) * params [ 'scalings' ] [ 'eeg' ] ) * 1000000.0 ) * factor ) ) #NEWLINE# #UNINDENT# idx_offset += 4 #NEWLINE# #UNINDENT# if ( 'eog' in params [ 'types' ] ) : #NEWLINE# #INDENT# labels [ ( idx_offset + 1 ) ] = '0.00' #NEWLINE# for idx in [ idx_offset , ( idx_offset + 2 ) ] : #NEWLINE# #INDENT# labels [ idx ] = '{0:.2f}' . format ( ( ( ( ( ticks [ idx ] - offsets [ 3 ] ) * params [ 'scalings' ] [ 'eog' ] ) * 1000000.0 ) * factor ) ) #NEWLINE# #UNINDENT# idx_offset += 4 #NEWLINE# #UNINDENT# if ( 'ecg' in params [ 'types' ] ) : #NEWLINE# #INDENT# labels [ ( idx_offset + 1 ) ] = '0.00' #NEWLINE# for idx in [ idx_offset , ( idx_offset + 2 ) ] : #NEWLINE# #INDENT# labels [ idx ] = '{0:.2f}' . format ( ( ( ( ( ticks [ idx ] - offsets [ 4 ] ) * params [ 'scalings' ] [ 'ecg' ] ) * 1000000.0 ) * factor ) ) #NEWLINE# #UNINDENT# #UNINDENT# ax . set_yticklabels ( labels , fontsize = 12 , color = 'black' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ax . set_yticklabels ( tick_list , fontsize = 12 ) #NEWLINE# #UNINDENT# params [ 'vsel_patch' ] . set_y ( ch_start ) #NEWLINE# params [ 'fig' ] . canvas . draw ( ) #NEWLINE# if ( params [ 'fig_proj' ] is not None ) : #NEWLINE# #INDENT# params [ 'fig_proj' ] . canvas . draw ( )