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

 Download zip file 
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]
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;
""" - establishes FeedExt(), ParFeedAll()
    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 <>.

from neuron import h as nrn
import numpy as np

class ParFeedAll():
    # p_ext has a different structure for the extinput
    def __init__(self, type, celltype, p_ext, gid):
        """ usually, p_ext is a dict of cell types
        # VecStim setup
        self.eventvec = nrn.Vector()
        self.vs = nrn.VecStim()

        # self.p_unique = p_unique[type]
        self.p_ext = p_ext
        self.celltype = celltype

        # random generator for this instance
        # qnd hack to make the seeds the same across all gids
        # for just evoked
        if type.startswith(('evprox', 'evdist')):
            self.seed = gid
            self.prng = np.random.RandomState(self.seed)

            self.seed = 1001 + gid
            self.prng = np.random.RandomState(self.seed)

        # each of these methods creates self.eventvec for playback
        if type == 'extpois':

        elif type.startswith(('evprox', 'evdist')):

        elif type == 'extgauss':

        elif type == 'extinput':

        # load eventvec into VecStim object

    # for parallel, maybe be that postsyn for this is just nil (None)
    def connect_to_target(self):
        nc = nrn.NetCon(self.vs, None)
        nc.threshold = 0

        return nc

    # mu and sigma vals come from p
    def __create_evoked(self):
        if self.celltype in self.p_ext.keys():
            # assign the params
            mu = self.p_ext['t0']
            sigma = self.p_ext[self.celltype][2]

            # if a non-zero sigma is specified
            if sigma:
                val_evoked = self.prng.normal(mu, sigma, 1)

                # if sigma is specified at 0
                val_evoked = np.array([mu])

            val_evoked = val_evoked[val_evoked > 0]

            # vals must be sorted


            # return an empty eventvec list

    # create external Gaussian distributed input events
    def __create_extgauss(self):
        # assign the params
        mu = self.p_ext[self.celltype][2]
        sigma = self.p_ext[self.celltype][3]

        # mu and sigma values come from p
        # one single value from Gaussian dist.
        # values MUST be sorted for VecStim()!
        val_gauss = self.prng.normal(mu, sigma, 50)

        # remove non-zero values brute force-ly
        val_gauss = val_gauss[val_gauss > 0]

        # sort values - critical for nrn

        # Convert array into nrn vector

    # generic external input function
    def __create_extinput(self):
        # store f_input as self variable for later use if it exists in p
        # t0 is always defined
        t0 = self.p_ext['t0']

        # If t0 is -1, randomize start time of inputs
        if t0 == -1:
            t0 = self.prng.uniform(25., 125.)

        f_input = self.p_ext['f_input']
        stdev = self.p_ext['stdev']
        events_per_cycle = self.p_ext['events_per_cycle']
        distribution = self.p_ext['distribution']

        # events_per_cycle = 1
        if events_per_cycle > 2 or events_per_cycle <= 0:
            print("events_per_cycle should be either 1 or 2, trying 2")
            events_per_cycle = 2

        # If frequency is 0, create empty vector if input times
        if not f_input:
            t_input = []

        elif distribution == 'normal':
            # array of mean stimulus times, starts at t0
            isi_array = np.arange(t0, self.p_ext['tstop'], 1000./f_input)

            # array of single stimulus times -- no doublets
            if stdev:
                t_array = self.prng.normal(np.repeat(isi_array, 10), stdev)

                t_array = isi_array

            if events_per_cycle == 2:
                # Two arrays store doublet times
                t_array_low = t_array - 5
                t_array_high = t_array + 5

                # Array with ALL stimulus times for input
                # np.append concatenates two np arrays
                t_input = np.append(t_array_low, t_array_high)

            elif events_per_cycle == 1:
                t_input = t_array

            # brute force remove non-zero times. Might result in fewer vals than desired
            t_input = t_input[t_input > 0]

        # Uniform Distribution
        elif distribution == 'uniform':
            n_inputs = 10. * f_input * (self.p_ext['tstop'] - t0) / 1000.
            t_array = self.prng.uniform(t0, self.p_ext['tstop'], n_inputs)

            if events_per_cycle == 2:
                # Two arrays store doublet times
                t_input_low = t_array - 5
                t_input_high = t_array + 5

                # Array with ALL stimulus times for input
                # np.append concatenates two np arrays
                t_input = np.append(t_input_low, t_input_high)

            elif events_per_cycle == 1:
                t_input = t_array

            # brute force remove non-zero times. Might result in fewer vals than desired
            t_input = t_input[t_input > 0]

            print("Indicated distribution not recognized. Not making any alpha feeds.")
            t_input = []

        # Convert array into nrn vector

    # new external pois designation
    def __create_extpois(self):
        # check the t interval
        t0 = self.p_ext['t_interval'][0]
        T = self.p_ext['t_interval'][1]
        lamtha = self.p_ext[self.celltype][2]

        # values MUST be sorted for VecStim()!
        # start the initial value
        if lamtha > 0.:
            t_gen = t0 + self.__t_wait(lamtha)
            val_pois = np.array([])

            if t_gen < T:
                np.append(val_pois, t_gen)

            # vals are guaranteed to be monotonically increasing, no need to sort
            while t_gen < T:
                # so as to not clobber confusingly base off of t_gen ...
                t_gen += self.__t_wait(lamtha)
                if t_gen < T:
                    val_pois = np.append(val_pois, t_gen)

            val_pois = np.array([])

        # Convert array into nrn vector

    # based on cdf for exp wait time distribution from unif [0, 1)
    def __t_wait(self, lamtha):
        """ returns in ms based on lamtha in Hz
        return -1000. * np.log(1. - self.prng.rand()) / lamtha

Loading data, please wait...