#NEWLINE# def _plot_histogram( params ) : #NEWLINE# #INDENT# 'Function for plotting histogram of peak-to-peak values.' #NEWLINE# import matplotlib.pyplot as plt #NEWLINE# epochs = params [ 'epochs' ] #NEWLINE# p2p = np . ptp ( epochs . get_data ( ) , axis = 2 ) #NEWLINE# types = list ( ) #NEWLINE# data = list ( ) #NEWLINE# if ( 'eeg' in params [ 'types' ] ) : #NEWLINE# #INDENT# eegs = np . array ( [ p2p . T [ i ] for ( i , x ) in enumerate ( params [ 'types' ] ) if ( x == 'eeg' ) ] ) #NEWLINE# data . append ( eegs . ravel ( ) ) #NEWLINE# types . append ( 'eeg' ) #NEWLINE# #UNINDENT# if ( 'mag' in params [ 'types' ] ) : #NEWLINE# #INDENT# mags = np . array ( [ p2p . T [ i ] for ( i , x ) in enumerate ( params [ 'types' ] ) if ( x == 'mag' ) ] ) #NEWLINE# data . append ( mags . ravel ( ) ) #NEWLINE# types . append ( 'mag' ) #NEWLINE# #UNINDENT# if ( 'grad' in params [ 'types' ] ) : #NEWLINE# #INDENT# grads = np . array ( [ p2p . T [ i ] for ( i , x ) in enumerate ( params [ 'types' ] ) if ( x == 'grad' ) ] ) #NEWLINE# data . append ( grads . ravel ( ) ) #NEWLINE# types . append ( 'grad' ) #NEWLINE# #UNINDENT# params [ 'histogram' ] = plt . figure ( ) #NEWLINE# scalings = _handle_default ( 'scalings' ) #NEWLINE# units = _handle_default ( 'units' ) #NEWLINE# titles = _handle_default ( 'titles' ) #NEWLINE# colors = _handle_default ( 'color' ) #NEWLINE# for idx in range ( len ( types ) ) : #NEWLINE# #INDENT# ax = plt . subplot ( len ( types ) , 1 , ( idx + 1 ) ) #NEWLINE# plt . xlabel ( units [ types [ idx ] ] ) #NEWLINE# plt . ylabel ( 'count' ) #NEWLINE# color = colors [ types [ idx ] ] #NEWLINE# rej = None #NEWLINE# if ( ( epochs . reject is not None ) and ( types [ idx ] in epochs . reject . keys ( ) ) ) : #NEWLINE# #INDENT# rej = ( epochs . reject [ types [ idx ] ] * scalings [ types [ idx ] ] ) #NEWLINE# rng = [ 0.0 , ( rej * 1.1 ) ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# rng = None #NEWLINE# #UNINDENT# plt . hist ( ( data [ idx ] * scalings [ types [ idx ] ] ) , bins = 100 , color = color , range = rng ) #NEWLINE# if ( rej is not None ) : #NEWLINE# #INDENT# ax . plot ( ( rej , rej ) , ( 0 , ax . get_ylim ( ) [ 1 ] ) , color = 'r' ) #NEWLINE# #UNINDENT# plt . title ( titles [ types [ idx ] ] ) #NEWLINE# #UNINDENT# params [ 'histogram' ] . suptitle ( 'Peak-to-peak histogram' , y = 0.99 ) #NEWLINE# params [ 'histogram' ] . subplots_adjust ( hspace = 0.6 ) #NEWLINE# try : #NEWLINE# #INDENT# params [ 'histogram' ] . show ( warn = False ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# if ( params [ 'fig_proj' ] is not None ) : #NEWLINE# #INDENT# params [ 'fig_proj' ] . canvas . draw ( )