<s> """<STR_LIT>""" <EOL> import os <EOL> import numpy as np <EOL> import nitime <EOL> import nitime . timeseries as ts <EOL> import nitime . analysis as tsa <EOL> import nitime . viz as viz <EOL> from matplotlib import pyplot as plt <EOL> """<STR_LIT>""" <EOL> data_path = os . path . join ( nitime . __path__ [ <NUM_LIT:0> ] , '<STR_LIT:data>' ) <EOL> spike_times = np . loadtxt ( os . path . join ( data_path , '<STR_LIT>' ) ) <EOL> spike_ev = ts . Events ( spike_times , time_unit = '<STR_LIT>' ) <EOL> """<STR_LIT>""" <EOL> stim = np . loadtxt ( os . path . join ( data_path , '<STR_LIT>' ) ) <EOL> """<STR_LIT>""" <EOL> def volt2dB ( stim , maxdB = <NUM_LIT:100> ) : <EOL> stim = ( <NUM_LIT:20> * <NUM_LIT:1> / np . log ( <NUM_LIT:10> ) ) * ( np . log ( stim [ : , <NUM_LIT:1> ] / <NUM_LIT> ) ) <EOL> return maxdB - stim . max ( ) + stim <EOL> stim = volt2dB ( stim , maxdB = <NUM_LIT> ) <EOL> """<STR_LIT>""" <EOL> stim_time_series = ts . TimeSeries ( t0 = <NUM_LIT:0> , <EOL> data = stim , <EOL> sampling_interval = <NUM_LIT:50> , <EOL> time_unit = '<STR_LIT>' ) <EOL> """<STR_LIT>""" <EOL> stim_time_series . time_unit = '<STR_LIT>' <EOL> """<STR_LIT>""" <EOL> event_related = tsa . EventRelatedAnalyzer ( stim_time_series , <EOL> spike_ev , <EOL> len_et = <NUM_LIT:200> , <EOL> offset = - <NUM_LIT:200> ) <EOL> """<STR_LIT>""" <EOL> fig01 = viz . plot_tseries ( event_related . eta , ylabel = '<STR_LIT>' ) <EOL> """<STR_LIT>""" <EOL> ax = fig01 . get_axes ( ) [ <NUM_LIT:0> ] <EOL> xlim = ax . get_xlim ( ) <EOL> ylim = ax . get_ylim ( ) <EOL> mean_stim = np . mean ( stim_time_series . data ) <EOL> ax . plot ( [ xlim [ <NUM_LIT:0> ] , xlim [ <NUM_LIT:1> ] ] , [ mean_stim , mean_stim ] , '<STR_LIT>' ) <EOL> """<STR_LIT>""" <EOL> stim2 = np . loadtxt ( os . path . join ( data_path , '<STR_LIT>' ) ) <EOL> stim2 = volt2dB ( stim2 , maxdB = <NUM_LIT> ) <EOL> spike_times2 = np . loadtxt ( os . path . join ( data_path , '<STR_LIT>' ) ) <EOL> """<STR_LIT>""" <EOL> et = [ ] <EOL> means = [ ] <EOL> for stim , spike in zip ( [ stim , stim2 ] , [ spike_times , spike_times2 ] ) : <EOL> stim_time_series = ts . TimeSeries ( t0 = <NUM_LIT:0> , data = stim , sampling_interval = <NUM_LIT:50> , <EOL> time_unit = '<STR_LIT>' ) <EOL> stim_time_series . time_unit = '<STR_LIT>' <EOL> spike_ev = ts . Events ( spike , time_unit = '<STR_LIT>' ) <EOL> event_related = tsa . EventRelatedAnalyzer ( stim_time_series , <EOL> spike_ev , <EOL> len_et = <NUM_LIT:200> , <EOL> offset = - <NUM_LIT:200> ) <EOL> """<STR_LIT>""" <EOL> et . append ( event_related . eta ) <EOL> means . append ( np . mean ( stim_time_series . data ) ) <EOL> """<STR_LIT>""" <EOL> fig02 = viz . plot_tseries ( <EOL> ts . TimeSeries ( data = np . vstack ( [ et [ <NUM_LIT:0> ] . data , et [ <NUM_LIT:1> ] . data ] ) , <EOL> sampling_rate = et [ <NUM_LIT:0> ] . sampling_rate , time_unit = '<STR_LIT>' ) ) <EOL> ax = fig02 . get_axes ( ) [ <NUM_LIT:0> ] <EOL> xlim = ax . get_xlim ( ) <EOL> ax . plot ( [ xlim [ <NUM_LIT:0> ] , xlim [ <NUM_LIT:1> ] ] , [ means [ <NUM_LIT:0> ] , means [ <NUM_LIT:0> ] ] , '<STR_LIT>' ) <EOL> ax . plot ( [ xlim [ <NUM_LIT:0> ] , xlim [ <NUM_LIT:1> ] ] , [ means [ <NUM_LIT:1> ] , means [ <NUM_LIT:1> ] ] , '<STR_LIT>' ) <EOL> """<STR_LIT>""" <EOL> plt . show ( ) <EOL> """<STR_LIT>""" </s>
