In [1]:
%%javascript
if($(IPython.toolbar.selector.concat(' > #kill-run-all')).length == 0){
IPython.toolbar.add_buttons_group([
{
'label' : 'kill and run-all',
'icon' : 'fa fa-angle-double-down',
'callback': function(){
IPython.notebook.kernel.restart();
$(IPython.events).one('kernel_ready.Kernel',
function(){IPython.notebook.execute_all_cells();});
}
}
], 'kill-run-all');
}
In [2]:
import seaborn as sns
from foof.util import create_psd
%matplotlib inline
In [3]:
# stim induced
%run ../bin/ping.py ../data/test/ -t 1 --stim 0.75 --rate 10 --I_e 0. 0. --I_i 0.8 0.8 --w_e 0.8 --w_ee 0.2 --w_ei 0.0 --w_ie 0.8
In [4]:
# Unpack
spikes_e = result['spikes_e']
spikes_stim = result['spikes_stim']
spikes_i = result['spikes_i']
pop_e = result['pop_e']
pop_stim = result['pop_stim']
voltages_e = result['voltages_e']
voltages_i = result['voltages_i']
t = 2000
# ------------------------------------------------------------
# Raster full
figure(figsize=(14, 12))
subplot(311)
plot(spikes_stim.t/ms, spikes_stim.i, 'o', label='', color='k')
xlim(0,1000)
ylabel("Neuron #")
legend()
subplot(312)
plot(spikes_e.t/ms, spikes_e.i, 'o', label='E', color='k')
plot(spikes_i.t/ms, spikes_i.i, 'o', label='I', color='r')
xlim(0,1000)
ylabel("Neuron #")
legend()
# Raster zoom
figure(figsize=(10, 4))
subplot(211)
plot(spikes_e.t/ms, spikes_e.i, 'o', label='E', color='k')
ylabel("Neuron #")
ylim(0,200)
xlim(600,700)
legend()
subplot(212)
plot(spikes_i.t/ms, spikes_i.i, 'o', label='I', color='r')
xlabel("Time (ms)")
ylim(0,40)
xlim(600,700)
# ------------------------------------------------------------
# V
tn = 2000
figure(figsize=(10,4))
subplot(211)
plot(voltages_e.t[tn:]/ms, voltages_e.V[:, tn:].T/mvolt, color='k')
# ylim(-90, -50)
ylabel("V")
legend()
subplot(212)
plot(voltages_i.t[tn:]/ms, voltages_i.V[:, tn:].T/mvolt, color='r')
xlabel("Time (ms)")
legend()
# V hist
figure(figsize=(6,6))
subplot(211)
hist(voltages_e.V[0][tn:]/mvolt, label='E (V)', color='k', bins=100, range=(-80, -50))
xlabel("V")
legend()
# ------------------------------------------------------------
# E rate
figure(figsize=(10,4))
plot(pop_e.t[tn:]/ms, pop_e.rate[tn:]/Hz, color='k', label='E rate')
ylabel('Rate (Hz)')
xlabel("Time (ms)")
legend()
figure(figsize=(10,4))
plot(pop_stim.t[tn:]/ms, pop_stim.rate[tn:]/Hz, color='k', label='Stim rate')
ylabel('Rate (Hz)')
xlabel("Time (ms)")
legend()
# ------------------------------------------------------------
figure(figsize=(12,10))
subplot(511)
plot(voltages_e.t[tn:]/ms, voltages_e.g_s.sum(0)[tn:], color='k', label='E (g_s)')
ylabel("g")
legend(loc='best')
subplot(512)
plot(voltages_e.t[tn:]/ms, voltages_e.g_e.sum(0)[tn:], color='k', label='E (g_e)')
legend(loc='best')
subplot(513)
plot(voltages_e.t[tn:]/ms, voltages_e.g_i.sum(0)[tn:], color='k', label='E (g_i)')
legend(loc='best')
subplot(514)
plot(voltages_i.t[tn:]/ms, voltages_i.g_i.sum(0)[tn:], color='k', label='I (g_i)')
legend(loc='best')
subplot(515)
plot(voltages_e.t[tn:]/ms, voltages_e.g_ee[1:20, tn:].T, label='E (g_ee)')
xlabel("Time (ms)")
# ------------------------------------------------------------
# Spectra
lfp = (np.abs(voltages_e.g_s.sum(0)) + np.abs(voltages_e.g_ee.sum(0)))
lfp = lfp[1000:] # Drop initial spike
figure(figsize=(6,6))
subplot(211)
plot(voltages_i.t[1000:]/ms, lfp, color='k', label='LFP')
xlabel("Time (ms)")
ylabel("Sim. LFP (msiemens)")
subplot(212)
fs, spec = create_psd(lfp, 10000)
plot(fs[:40], spec[:40], color='k')
xlabel("Freq (Hz)")
ylabel("PSD")
Out[4]:
In [ ]: