Exemplo n.º 1
0
    def createTree(self, reinitialize=1, v_eq=-75.):
        """
        Create simple NET structure

        2     3
        |     |
        |     |
        ---1---
           |
           |
           0
           |
        """
        self.v_eq = v_eq
        loc_ind = np.array([0, 1, 2])

        # kernel constants
        alphas = 1. / np.array([.5, 8.])
        gammas = np.array([-1., 1.])
        alphas_ = 1. / np.array([1.])
        gammas_ = np.array([1.])
        # nodes
        node_0 = NETNode(0, [0, 1, 2], [], z_kernel=(alphas, gammas))
        node_1 = NETNode(1, [0, 1, 2], [0], z_kernel=(alphas_, gammas_))
        node_2 = NETNode(2, [1], [1], z_kernel=(alphas_, gammas_))
        node_3 = NETNode(3, [2], [2], z_kernel=(alphas_, gammas_))
        # add nodes to tree
        net_py = NET()
        net_py.setRoot(node_0)
        net_py.addNodeWithParent(node_1, node_0)
        net_py.addNodeWithParent(node_2, node_1)
        net_py.addNodeWithParent(node_3, node_1)
        # store
        self.net_py = net_py
        self.cnet = netsim.NETSim(net_py, v_eq=self.v_eq)
Exemplo n.º 2
0
    def createPointNeurons(self, v_eq=-75.):
        self.v_eq = v_eq
        self.dt = .025
        gh, eh = 50., -43.
        h_chan = channelcollection.h()

        self.greens_tree = GreensTree(
            file_n=os.path.join(MORPHOLOGIES_PATH_PREFIX, 'ball.swc'))
        self.greens_tree.setPhysiology(1., 100. / 1e6)
        self.greens_tree.addCurrent(h_chan, gh, eh)
        self.greens_tree.fitLeakCurrent(v_eq, 10.)
        self.greens_tree.setEEq(v_eq)
        self.greens_tree_pas = self.greens_tree.__copy__(new_tree=GreensTree())
        self.greens_tree_pas.asPassiveMembrane()
        self.sim_tree = self.greens_tree.__copy__(new_tree=NeuronSimTree())
        # set the impedances
        self.greens_tree_pas.setCompTree()
        self.freqs = np.array([0.])
        self.greens_tree_pas.setImpedance(self.freqs)
        # create sov tree
        self.sov_tree = self.greens_tree_pas.__copy__(new_tree=SOVTree())
        self.sov_tree.calcSOVEquations(maxspace_freq=50.)

        z_inp = self.greens_tree_pas.calcZF((1, .5), (1, .5))[0]
        alphas, gammas = self.sov_tree.getSOVMatrices(locarg=[(1., .5)])
        # create NET
        node_0 = NETNode(0, [0], [0], z_kernel=(alphas, gammas[:, 0]**2))
        net_py = NET()
        net_py.setRoot(node_0)
        # check if correct
        assert np.abs(gammas[0, 0]**2 / np.abs(alphas[0]) - z_inp) < 1e-10
        assert np.abs(node_0.z_bar - z_inp) < 1e-10

        # to initialize neuron tree
        self.sim_tree.initModel(dt=self.dt)
        # add ion channel to NET simulator
        a_soma = 4. * np.pi * (self.sim_tree[1].R * 1e-4)**2
        self.cnet = netsim.NETSim(net_py, v_eq=self.v_eq)

        hchan = channelcollection.h()
        self.cnet.addChannel(hchan, 0, gh * a_soma, eh)

        # add the synapse
        # to neuron tree
        self.sim_tree.addDoubleExpSynapse((1, .5), .2, 3., 0.)
        self.sim_tree.setSpikeTrain(0, 0.001, [5.])
        # to net sim
        self.cnet.addSynapse(0, {
            'tau_r': .2,
            'tau_d': 3.,
            'e_r': 0.
        },
                             g_max=0.001)
        self.cnet.setSpikeTimes(0, [5. + self.dt])
Exemplo n.º 3
0
    def createTree3(self, reinitialize=1, add_lin=True, v_eq=-75.):
        """
        Create simple NET structure

                         6
                4     5  |
                |     |  |
                |     |  |
             2  ---3---  |
             |     |     |
             ---1---     |
                   |     |
                   0------
                   |
        """
        self.v_eq = v_eq

        # kernel constants
        alphas = 1. / np.array([1.])
        gammas = np.array([1.])
        # nodes
        node_0 = NETNode(0, [0, 1, 2, 3], [], z_kernel=(alphas, gammas))
        node_1 = NETNode(1, [0, 1, 2], [], z_kernel=(alphas, gammas))
        node_2 = NETNode(2, [0], [0], z_kernel=(alphas, gammas))
        node_3 = NETNode(3, [1, 2], [], z_kernel=(alphas, gammas))
        node_4 = NETNode(4, [1], [1], z_kernel=(alphas, gammas))
        node_5 = NETNode(5, [2], [2], z_kernel=(alphas, gammas))
        node_6 = NETNode(6, [3], [3], z_kernel=(alphas, gammas))
        # add nodes to tree
        net_py = NET()
        net_py.setRoot(node_0)
        net_py.addNodeWithParent(node_1, node_0)
        net_py.addNodeWithParent(node_2, node_1)
        net_py.addNodeWithParent(node_3, node_1)
        net_py.addNodeWithParent(node_4, node_3)
        net_py.addNodeWithParent(node_5, node_3)
        net_py.addNodeWithParent(node_6, node_0)
        # linear terms
        alphas = 1. / np.array([1.])
        gammas = np.array([1.])
        self.lin_terms = {
            1: Kernel((alphas, gammas)),
            2: Kernel((alphas, gammas)),
            3: Kernel((alphas, gammas))
        } if add_lin else {}
        # store
        self.net_py = net_py
        self.cnet = netsim.NETSim(net_py, lin_terms=self.lin_terms)
Exemplo n.º 4
0
    # set the spike times
    sim_tree.setSpikeTrain(0, w_exc,
                           spktms_exc1)  # spike times for nmda synapse 1
    sim_tree.setSpikeTrain(1, w_exc,
                           spktms_exc2)  # spike times for nmda synapse 2
    sim_tree.setSpikeTrain(2, w_inh,
                           spktms_inh)  # spike times for inhibitory synapse
    # set recording locs
    sim_tree.storeLocs(locs, name='rec locs')
    # run the simulation
    res_neuron = sim_tree.run(t_max)
    ############################################################################

    ## simulate the NET ########################################################
    print '> Simulating the NET model'
    cnet = netsim.NETSim(net, v_eq=v_eq)
    # add synapses
    cnet.addSynapse(1, 'AMPA+NMDA', g_max=w_exc, nmda_ratio=nmda_ratio)
    cnet.addSynapse(2, 'AMPA+NMDA', g_max=w_exc, nmda_ratio=nmda_ratio)
    cnet.addSynapse(3, 'GABA', g_max=w_inh)
    # set the spike times
    cnet.setSpikeTimes(0, spktms_exc1)  # spike times for nmda synapse 1
    cnet.setSpikeTimes(1, spktms_exc2)  # spike times for nmda synapse 2
    cnet.setSpikeTimes(2, spktms_inh)  # spike times for inhibitory synapse
    # run the simulation
    res_net = cnet.runSim(t_max, dt, rec_v_node=True)
    ############################################################################

    ## compute correlations and Iz #############################################
    v_corr = np.corrcoef(res_net['v_loc'][1:3])[0, 1]
    # compute average conductance GABA synapse
Exemplo n.º 5
0
for ii, loc_ind in enumerate(net_loc_inds):
    sim_tree.setSpikeTrain(ii, weight, spiketimes[ii])
n_exc = len(net_loc_inds)
for ii, loc_ind in enumerate(net_loc_inds):
    sim_tree.setSpikeTrain(ii+n_exc, weight_inh, spiketimes[ii+n_exc])
# set recording locs
rec_locs = [locs[ind] for ind in net_loc_inds]
sim_tree.storeLocs(rec_locs, name='rec locs')
# run the simulation
res_neuron = sim_tree.run(t_max, downsample=8, pprint=True)
################################################################################


## defining the simulation parameters ##########################################
print '> Simulating the NET model'
cnet = netsim.NETSim(net, lin_terms=lin_terms, v_eq=v_eq)
# cnet = netsim.NETSim(net, v_eq=v_eq)
# add the ion channels at the soma
for channel_name, (g_bar, e_rev) in currents.iteritems():
    cnet.addChannel(channel_name, 0, g_bar, e_rev=e_rev)
# # add the synapses
for loc_ind in range(len(net_loc_inds)):
    cnet.addSynapse(loc_ind, 'AMPA+NMDA', g_max=weight, nmda_ratio=nmda_ratio)
for loc_ind in range(len(net_loc_inds)):
    cnet.addSynapse(loc_ind, 'GABA', g_max=weight_inh, nmda_ratio=nmda_ratio)
# set the spike times
for ii, spktm in enumerate(spiketimes):
    cnet.setSpikeTimes(ii, spktm)
# run the simulation
res_net = cnet.runSim(t_max, dt, step_skip=8, pprint=True)
################################################################################
Exemplo n.º 6
0
    def createTree(self, reinitialize=1, v_eq=-75.):
        '''
        Create simple NET structure

        2     3
        |     |
        |     |
        ---1---
           |
           |
           0
           |
        '''
        self.v_eq = v_eq
        loc_ind = np.array([0, 1, 2])

        # import btstructs
        # import morphologyReader as morphR
        # net_py = btstructs.STree()
        # # node 0
        # alphas = -1. / np.array([.5, 8.])
        # gammas = np.array([-1.,1.])
        # self.z_0 = - np.sum(gammas / alphas)
        # node_0 = btstructs.SNode(0)
        # node_0.set_content({'layerdata': morphR.layerData(loc_ind, alphas, gammas)})
        # dat = node_0.get_content()['layerdata']
        # dat.set_ninds(np.array([]))
        # net_py.set_root(node_0)
        # # node 1
        # alphas = -1. / np.array([1.])
        # gammas = np.array([1.])
        # self.z_1 = - np.sum(gammas / alphas)
        # node_1 = btstructs.SNode(1)
        # node_1.set_content({'layerdata': morphR.layerData(loc_ind, alphas, gammas)})
        # dat = node_1.get_content()['layerdata']
        # dat.set_ninds(np.array([0]))
        # net_py.add_node_with_parent(node_1, node_0)
        # # node 2
        # alphas = -1. / np.array([1.])
        # gammas = np.array([1.])
        # self.z_2 = - np.sum(gammas / alphas)
        # node_2 = btstructs.SNode(2)
        # node_2.set_content({'layerdata': morphR.layerData(loc_ind[1:2], alphas, gammas)})
        # dat = node_2.get_content()['layerdata']
        # dat.set_ninds(np.array([loc_ind[1]]))
        # net_py.add_node_with_parent(node_2, node_1)
        # # node 3
        # alphas = -1. / np.array([1.])
        # gammas = np.array([1.])
        # node_3 = btstructs.SNode(3)
        # self.z_3 = - np.sum(gammas / alphas)
        # node_3.set_content({'layerdata': morphR.layerData(loc_ind[2:], alphas, gammas)})
        # dat = node_3.get_content()['layerdata']
        # dat.set_ninds(np.array([loc_ind[2]]))
        # net_py.add_node_with_parent(node_3, node_1)

        # kernel constants
        alphas = 1. / np.array([.5, 8.])
        gammas = np.array([-1., 1.])
        alphas_ = 1. / np.array([1.])
        gammas_ = np.array([1.])
        # nodes
        node_0 = NETNode(0, [0, 1, 2], [], z_kernel=(alphas, gammas))
        node_1 = NETNode(1, [0, 1, 2], [0], z_kernel=(alphas_, gammas_))
        node_2 = NETNode(2, [1], [1], z_kernel=(alphas_, gammas_))
        node_3 = NETNode(3, [2], [2], z_kernel=(alphas_, gammas_))
        # add nodes to tree
        net_py = NET()
        net_py.setRoot(node_0)
        net_py.addNodeWithParent(node_1, node_0)
        net_py.addNodeWithParent(node_2, node_1)
        net_py.addNodeWithParent(node_3, node_1)
        # store
        self.net_py = net_py
        self.cnet = netsim.NETSim(net_py, v_eq=self.v_eq)
Exemplo n.º 7
0
    def createTree2(self, reinitialize=1, add_lin=True, v_eq=-75.):
        '''
        Create simple NET structure

                3     4
                |     |
                |     |
                ---2---
             1     |
             |     |
             ---0---
                |
        '''
        self.v_eq = v_eq
        loc_ind = np.array([0, 1, 2])

        # import btstructs
        # import morphologyReader as morphR
        # net_py = btstructs.STree()
        # # node 0
        # alphas = -1. / np.array([1.])
        # gammas = np.array([1.])
        # self.z_0 = - np.sum(gammas / alphas)
        # node_0 = btstructs.SNode(0)
        # node_0.set_content({'layerdata': morphR.layerData(loc_ind, alphas, gammas)})
        # dat = node_0.get_content()['layerdata']
        # dat.set_ninds(np.array([]))
        # net_py.set_root(node_0)
        # # node 1
        # alphas = -1. / np.array([1.])
        # gammas = np.array([1.])
        # self.z_1 = - np.sum(gammas / alphas)
        # node_1 = btstructs.SNode(1)
        # node_1.set_content({'layerdata': morphR.layerData(loc_ind[0:1], alphas, gammas)})
        # dat = node_1.get_content()['layerdata']
        # dat.set_ninds(np.array([0]))
        # net_py.add_node_with_parent(node_1, node_0)
        # # node 2
        # alphas = -1. / np.array([1.])
        # gammas = np.array([1.])
        # self.z_2 = - np.sum(gammas / alphas)
        # node_2 = btstructs.SNode(2)
        # node_2.set_content({'layerdata': morphR.layerData(loc_ind[1:], alphas, gammas)})
        # dat = node_2.get_content()['layerdata']
        # dat.set_ninds(np.array([]))
        # net_py.add_node_with_parent(node_2, node_0)
        # # node 3
        # alphas = -1. / np.array([1.])
        # gammas = np.array([1.])
        # self.z_3 = - np.sum(gammas / alphas)
        # node_3 = btstructs.SNode(3)
        # node_3.set_content({'layerdata': morphR.layerData(loc_ind[1:2], alphas, gammas)})
        # dat = node_3.get_content()['layerdata']
        # dat.set_ninds(np.array([loc_ind[1]]))
        # net_py.add_node_with_parent(node_3, node_2)
        # # node 4
        # alphas = -1. / np.array([1.])
        # gammas = np.array([1.])
        # node_4 = btstructs.SNode(4)
        # self.z_4 = - np.sum(gammas / alphas)
        # node_4.set_content({'layerdata': morphR.layerData(loc_ind[2:], alphas, gammas)})
        # dat = node_4.get_content()['layerdata']
        # dat.set_ninds(np.array([loc_ind[2]]))
        # net_py.add_node_with_parent(node_4, node_2)
        # # linear terms
        # alphas = -1. / np.array([1.])
        # gammas = np.array([1.])
        # lin3 = morphR.linearLayerData([1], alphas, gammas)
        # alphas = -1. / np.array([1.])
        # gammas = np.array([1.])
        # lin4 = morphR.linearLayerData([2], alphas, gammas)
        # self.lin_terms = [lin3, lin4] if add_lin else []

        # kernel constants
        alphas = 1. / np.array([1.])
        gammas = np.array([1.])
        # nodes
        node_0 = NETNode(0, [0, 1, 2], [], z_kernel=(alphas, gammas))
        node_1 = NETNode(1, [0], [0], z_kernel=(alphas, gammas))
        node_2 = NETNode(2, [1, 2], [], z_kernel=(alphas, gammas))
        node_3 = NETNode(3, [1], [1], z_kernel=(alphas, gammas))
        node_4 = NETNode(4, [2], [2], z_kernel=(alphas, gammas))
        # add nodes to tree
        net_py = NET()
        net_py.setRoot(node_0)
        net_py.addNodeWithParent(node_1, node_0)
        net_py.addNodeWithParent(node_2, node_0)
        net_py.addNodeWithParent(node_3, node_2)
        net_py.addNodeWithParent(node_4, node_2)
        # linear terms
        alphas = 1. / np.array([1.])
        gammas = np.array([1.])
        self.lin_terms = {
            1: Kernel((alphas, gammas)),
            2: Kernel((alphas, gammas))
        } if add_lin else {}
        # store
        self.net_py = net_py
        self.cnet = netsim.NETSim(net_py,
                                  lin_terms=self.lin_terms,
                                  v_eq=self.v_eq)