In [1]:
import numpy as np
import os
from invivoinfer.vc_infer_trace import VCAnalysis
import matplotlib.pylab as plt
import seaborn as sns
%matplotlib inline
import imp
import logging
import logging
logger = logging.getLogger()
logger.setLevel(logging.INFO)
from IPython.display import clear_output
In [2]:
DATA_DIR = os.path.join('/'.join(imp.find_module("invivoinfer")[1].split('/')[:-1]), 'data')
TEST_DATA_PATH = os.path.join(DATA_DIR, 'test_trace.csv')
FIGURES_DIR = os.path.join('/'.join(imp.find_module("invivoinfer")[1].split('/')[:-1]), 'notebooks', 'figures')
trace = np.genfromtxt(TEST_DATA_PATH, delimiter=',')
dt = 0.0001
In [3]:
# FOR A FASTER TESTING USE 'config_testing.json'
vcanalysis = VCAnalysis(trace, dt, figures_folder=FIGURES_DIR, config='config.json')
In [4]:
dt_trace = np.arange(0, dt*(len(trace)), dt)
plt.plot(dt_trace, vcanalysis.raw_trace)
plt.xlabel('Time (s)')
plt.ylabel('Current (pA)')
Out[4]:
In [5]:
vcanalysis.run_analysis(save_pdf=True, distType='LogNormal')
clear_output()
In [6]:
vcanalysis.plot_mean_offset(save_pdf=True)
In [7]:
vcanalysis.plot_tau_estimation(save_pdf=True)
In [8]:
tau1 = vcanalysis.param_priors['tau1'][0]
tau2 = vcanalysis.param_priors['tau2'][0]
print 'Tau1 = {} sec, Tau2 = {} msec'.format(tau1*1000, tau2*1000)
Map weights and frequency
In [9]:
vcanalysis.inference_results['map']['weights'].squeeze()
Out[9]:
In [10]:
vcanalysis.inference_results['map']['metrics']
Out[10]:
Posterior distribution of A, stdA and frequency, summary:
In [11]:
vcanalysis.inference_results['mh']['weights'].describe()
Out[11]:
In [12]:
vcanalysis.inference_results['mh']['dic']
Out[12]:
In [13]:
vcanalysis.plot_mc_results()
In [17]:
for el in ['A', 'stdA', 'freq']:
vcanalysis.inference_results['mh']['weights'][el].plot()
In [ ]: