def make_time_frequency_plot(dtup, event_names, Tpre, Tpost, freqs, baseline_interval, thresh): # get lfp data print "Fetching data: " + str(dtup) lfp = dbio.fetch_all_such_LFP(dbname, *dtup).censor() # get events evt = dbio.fetch(dbname, 'events', *dtup[:2]) times0 = evt[event_names[0]].dropna() times1 = evt[event_names[1]].dropna() nf = physutils.norm_by_mean(baseline_interval) contr_tf, fig1 = lfp.contrast_time_frequency(dtup[2], [times0, times1], Tpre, Tpost, method='wav', normfun=nf, doplot=True, freqs=freqs) mcontr, fig2 = lfp.significant_time_frequency(dtup[2], [times0, times1], Tpre, Tpost, thresh=thresh, niter=1000, method='wav', doplot=True, normfun=nf, freqs=freqs) return fig1, fig2
import numpy as np import pandas as pd import physutils as phys lfp = phys.LFPset(pd.DataFrame.from_csv("sample_lfp.csv")) evt = pd.DataFrame.from_csv('sample_events.csv') stops = evt['stop inflating'].dropna() pops = evt['popped'].dropna() Tpre = -1.5 Tpost = 0.5 baseline_interval = (-1.5, -1.35) lothresh = -2.56 hithresh = 2.56 thresh = (lothresh, hithresh) freqs = np.exp(np.linspace(np.log(2.5), np.log(50))) series = lfp.dataframe['17'] nf = phys.norm_by_mean(baseline_interval) lfp.significant_time_frequency('17', [stops, pops], Tpre, Tpost, thresh, niter=100, method='wav', doplot=False, normfun=nf, freqs=freqs)
def make_time_frequency_plot(dbname, dtup, event_name, Tpre, Tpost, freqs, baseline_interval): # get lfp data print "Fetching data: " + str(dtup) lfp = dbio.fetch_all_such_LFP(dbname, *dtup).censor() # get events evt = dbio.fetch(dbname, 'events', *dtup[:2]) times = evt[event_name].dropna() wav_normed, fig = lfp.avg_time_frequency(dtup[2], times, Tpre, Tpost, method='wav', normfun=physutils.norm_by_mean(baseline_interval)) return fig