Current Dipole in Laminar Neocortex (Lee et al. 2013)

 Download zip file   Auto-launch 
Help downloading and running models
Laminar neocortical model in NEURON/Python, adapted from Jones et al 2009.
1 . Lee S, Jones SR (2013) Distinguishing mechanisms of gamma frequency oscillations in human current source signals using a computational model of a laminar neocortical network. Front Hum Neurosci 7:869 [PubMed]
Citations  Citation Browser
Model Information (Click on a link to find other models with that property)
Model Type: Realistic Network;
Brain Region(s)/Organism: Neocortex;
Cell Type(s):
Channel(s): I Na,t; I K; I M; I Calcium; I h; I T low threshold; I K,Ca;
Gap Junctions:
Receptor(s): GabaA; GabaB; AMPA; NMDA;
Simulation Environment: NEURON (web link to model); Python (web link to model); NEURON; Python;
Model Concept(s): Magnetoencephalography; Temporal Pattern Generation; Activity Patterns; Gamma oscillations; Oscillations; Current Dipole; Touch;
Implementer(s): Lee, Shane [shane_lee at];
Search NeuronDB for information about:  GabaA; GabaB; AMPA; NMDA; I Na,t; I T low threshold; I K; I M; I h; I K,Ca; I Calcium;
#!/usr/bin/env python
""" - plotting routines for the basic figures
    Copyright (C) 2013 Shane Lee and Stephanie Jones

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <>.

import matplotlib as mpl
import matplotlib.pyplot as plt
import matplotlib.gridspec as gs
import numpy as np
import os
import fileio
import specfn
import spikefn

class FigTemplate():
    """ Figure template class for basic figure
    def __init__(self):
        mpl.rc('font', size=8)
        self.f = plt.figure(figsize=(7.5, 10)) = {
            'all': gs.GridSpec(8, 100, left=0.15, right=0.95, bottom=0.1, top=0.95),
        } = {
            'raster_L2': self.f.add_subplot(['all'][:2, :80]),
            'raster_L5': self.f.add_subplot(['all'][2:4, :80]),
            'dipole_L2': self.f.add_subplot(['all'][4:5, :80]),
            'dipole_L5': self.f.add_subplot(['all'][5:6, :80]),
            'spec_dipole': self.f.add_subplot(['all'][6:, :]),

    def labels(self):['raster_L2'].set_ylabel('L2 pyramidal (black), fs (red)')['raster_L2'].set_xticklabels([])['raster_L5'].set_ylabel('L5 pyramidal (black), fs (red)')['raster_L5'].set_xticklabels([])['dipole_L2'].set_ylabel('L2 dipole (nAm)')['dipole_L2'].set_xticklabels([])['dipole_L5'].set_ylabel('L5 dipole (nAm)')['dipole_L5'].set_xticklabels([])['spec_dipole'].set_ylabel('Frequency (Hz)')['spec_dipole'].set_xlabel('Time (ms)')

    def close(self):

    def save(self, fpng):
        self.f.savefig(fpng, dpi=250)

def plot_simulation(dsub):
    d = os.path.join(os.getcwd(), 'data', dsub)
    f = os.path.join(d, "data.pkl")
    fspikes = os.path.join(d, "spikes.txt")
    fpng = os.path.join(d, "spec.png")

    x = fileio.pkl_load(f)

    # dt is given here in ms
    fs = 1000. / x['p']['dt']

    spikes = spikefn.spikes_from_file(fspikes, x['gid_dict'])

    n = dict.fromkeys(spikes)
    for celltype in spikes:
        n[celltype] = len(spikes[celltype])

    # get total counts
    N_L2 = n['L2_basket'] + n['L2_pyramidal']
    N_L5 = n['L5_basket'] + n['L5_pyramidal']

    yticks = {
        'L2': np.linspace(0, 1, N_L2 + 2),
        'L5': np.linspace(0, 1, N_L5 + 2),

    ind_L2_pyr = np.arange(0, N_L2, 1)[:n['L2_pyramidal']]
    ind_L2_inh = np.arange(0, N_L2, 1)[n['L2_pyramidal']:]

    ind_L5_pyr = np.arange(0, N_L5, 1)[:n['L5_pyramidal']]
    ind_L5_inh = np.arange(0, N_L5, 1)[n['L5_pyramidal']:]

    fig = FigTemplate()

    # L2 spikes
    for i, spk_cell in zip(ind_L2_pyr, spikes['L2_pyramidal']):
        y = yticks['L2'][i] * np.ones(len(spk_cell))['raster_L2'].scatter(spk_cell, y, marker='|', s=2, color='k')

    for i, spk_cell in zip(ind_L2_inh, spikes['L2_basket']):
        y = yticks['L2'][i] * np.ones(len(spk_cell))['raster_L2'].scatter(spk_cell, y, marker='|', s=2, color='r')

    # L5 spikes
    for i, spk_cell in zip(ind_L5_pyr, spikes['L5_pyramidal']):
        y = yticks['L5'][i] * np.ones(len(spk_cell))['raster_L5'].scatter(spk_cell, y, marker='|', s=2, color='k')

    for i, spk_cell in zip(ind_L5_inh, spikes['L5_basket']):
        y = yticks['L5'][i] * np.ones(len(spk_cell))['raster_L5'].scatter(spk_cell, y, marker='|', s=2, color='r')['raster_L2'].set_ylim((yticks['L2'][0], yticks['L2'][-1]))['raster_L5'].set_ylim((yticks['L5'][0], yticks['L5'][-1]))

    # dipole['dipole_L2'].plot(x['t'], x['dipole_L2'])['dipole_L5'].plot(x['t'], x['dipole_L5'])

    ylims =['dipole_L5'].get_ylim()['dipole_L2'].set_ylim(ylims)

    pc = specfn.pspec_ax(['spec_dipole'], x['fspec'], x['spec'], (x['t'][0], x['t'][-1]))

    for axh in[axh].set_xlim((x['t'][0], x['t'][-1]))
    print("Saved file {}".format(fpng))

if __name__ == '__main__':
    # fig = FigTemplate()
    d = 'gamma_L5weak_L2weak'