Goal: choose parameters for a random current injected into the PKJ every time step such that the model exhibits ISI distribution statistics that match those described in Hausser and Clark (1997) in the presence of GABA blockers.
In [1]:
%load_ext autoreload
%autoreload 2
import time
import sys
sys.path.append('../../')
from brian import *
from MLI_PKJ_net import *
from statsmodels.tsa.stattools import acf
from pandas import *
set_global_preferences(useweave=True, usenewpropagate=True, usecodegen=True, usecodegenweave=True)
defaultclock.dt = .25*ms
In [ ]:
# this file is the output of the parameter sweep python script
data_file = '~/data/neuron_models/molecular_layer/PKJ_gamma_current_param_sweep/2013-10-17T13:14:33.097397/results.txt'
In [5]:
with open(data_file) as f:
results = read_csv(f,delimiter='\t')
target = array([40.,.18])
results['error'] = ((results.ix[:,-2:] - target).abs()/target).sum(axis=1)
results['mean'] = results.ix[:,0] + results.ix[:,1]
results.sort(columns='error')[:5]
Out[5]:
In [12]:
def run_net(T,N_PKJ,k,theta):
'''
This function runs a network of N_PKJ PKJs and monitors the results
'''
reinit()
reinit_default_clock()
clear(True)
PKJ = PurkinjeCellGroup(N_PKJ)
@network_operation(Clock(dt=defaultclock.dt))
def random_current():
PKJ.I = gamma(k,theta,size=len(PKJ)) * nA
# Monitors
MS_PKJ = SpikeMonitor(PKJ)
MR_PKJ = PopulationRateMonitor(PKJ,bin=1*ms)
MISI_PKJ = ISIHistogramMonitor(PKJ,bins=arange(0,162,2)*ms)
MV_PKJ = StateMonitor(PKJ,'V',record=0)
run(T*msecond)
return MS_PKJ, MR_PKJ, MISI_PKJ, MV_PKJ
In [13]:
T = 300000
N_PKJ = 1
# choice of parameters
k, theta = 0.430303,0.195962
# run simulation
MS_PKJ, MR_PKJ, MISI_PKJ, MV_PKJ = run_net(T,N_PKJ,k,theta)
In [21]:
# save monitors for reproducibility
monitors = {'MS_PKJ_iso':MS_PKJ, 'MR_PKJ_iso':MR_PKJ, 'MISI_PKJ_iso':MISI_PKJ, 'MV_PKJ_iso':MV_PKJ}
out_dir = '~/'
for name, mon in monitors.iteritems():
cPickle.dump(mon, open(out_dir+'%s.pkl'%name,'w'))
In [2]:
load_monitors = False
if load_monitors:
in_dir = '~/'
MS_PKJ = cPickle.load(open(in_dir+'MS_PKJ_iso.pkl'))
MV_PKJ = cPickle.load(open(in_dir+'MV_PKJ_iso.pkl'))
MISI_PKJ = cPickle.load(open(in_dir+'MISI_PKJ_iso.pkl'))
MR_PKJ = cPickle.load(open(in_dir+'MR_PKJ_iso.pkl'))
In [3]:
fig = figure(figsize=(25,5), dpi=600)
# Plot trace
ax = fig.add_subplot(131)
MV_PKJ.insert_spikes(MS_PKJ)
ax.plot(MV_PKJ.times[:4000],(MV_PKJ.values[0,:4000]), color='#0B486B')
xlim([-.1,1.])
add_scalebar(ax)
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.spines['left'].set_visible(False)
ax.spines['bottom'].set_visible(False)
# Plot ISI
ax = fig.add_subplot(132)
plot_ISI_histogram(MISI_PKJ, MS_PKJ, MR_PKJ, (20,0),(75,MISI_PKJ.count.max()*.7),color='#0B486B',edgecolor='w')
simpleaxis(ax)
xlim([0,150])
tick_params(labelsize=18)
# Plot spike autocorrelation
ax = fig.add_subplot(133)
plot_spike_correlogram(MS_PKJ.spiketimes[0],MS_PKJ.spiketimes[0], bin=1*ms, width=200*ms, ax=ax,color='#0B486B')
simpleaxis(ax)
tick_params(labelsize=18)
tight_layout()
fig.subplots_adjust(wspace=.3)
fig.savefig('PKJ_iso_color.tiff',dpi=600*6.93/25)
fig.savefig('PKJ_iso_color.png',dpi=600*6.93/25)
In [34]:
# statistical tests
from scipy.stats import normaltest, shapiro
isis = diff(MS_PKJ.spiketimes[0])
shapiro(isis[:5000])
Out[34]:
In [ ]: