Neuron and Python stim-response error

When Python is the interpreter, what is a good
design for the interface to the basic NEURON
concepts.

Moderator: hines

Post Reply
tmczhangtielin
Posts: 4
Joined: Fri Aug 01, 2014 12:14 pm

Neuron and Python stim-response error

Post by tmczhangtielin » Wed Nov 19, 2014 10:42 am

Hello, everyone. It is really so difficult to describe my problem. I create 10 neurons and make them connect each other as a line. For example neuron 1 has a NetCon to neuron 2, and neuron 2 connects to neuron 3,... like this. I didn't find some compiling error here but it seems that the result is not true. Signals from stim didn't arrive at the next neuron. It takes me 2 days to find the reason. I am not good at debug error in neuron. Thanks for any advice.

Code: Select all

# -*- coding: utf-8 -*-
'''
A small network around 10 neurons
Thomas
2014-11-18
'''

import neuron
import numpy as np
from pylab import *

class SmallNetwork:
    neuronList = []
    synapseList = []
    def __init__(self, neuron_number):
        self.neuron_number = neuron_number
        
    def createNeurons(self):
        for i in range(self.neuron_number):
            name = "py_"+str(i)
            neu = neuron.h.Section(name=name)
            neu.insert('hh')
            self.neuronList.insert(i, neu)
    def createSynapse(self):
        for i in range(self.neuron_number):
            synapse = neuron.h.Exp2Syn(self.neuronList[i](0.5)  ) # set a synapse on perticular cell
            synapse.tau1=0.1 # rise
            synapse.tau2=1.0 # decay
            self.synapseList.insert(i, synapse)
    
    def createConnections(self):    
        for i in range(self.neuron_number-1):
            nc = neuron.h.NetCon(self.neuronList[i](0.5)._ref_v,self.synapseList[i+1],0,1,0.5,sec=self.neuronList[i]) #[threshold, delay, weight] [10,1,0]

    def setRecorder(self):
       self.trec = neuron.h.Vector()
       self.trec.record(neuron.h._ref_t) # record time
       self.vrec1 = neuron.h.Vector()
       self.vrec1.record(self.neuronList[0](0.5)._ref_v) # record first input neuron voltage
       self.vrec2 = neuron.h.Vector()
       self.vrec2.record(self.neuronList[1](0.5)._ref_v)# record second input neuron voltage
       
    def insertStims(self):
        # drive cell1 with a current stim
        #ic = neuron.h.IClamp(self.neuronList[0](0.5))
        #ic.delay = 5 #ms
        #ic.dur = 50 #ms
        #ic.amp = 10 #nA, 5 -> 1 spike, 10 -> regular firing
        
        ns = neuron.h.NetStim()
        ns.interval = 1
        ns.number  = 10
        ns.start  = 40
        ns.noise  = 0.5
        nc1 = neuron.h.NetCon(ns,self.synapseList[0])
        
        
    def running(self):
        self.createNeurons()
        self.createSynapse()
        self.createConnections()
        self.setRecorder()
        self.insertStims()
        neuron.h.finitialize(-60)
        neuron.init()
        neuron.run(100)
        
    def plotImages(self):
        # plot output
        plot(np.array(self.trec),np.array(self.vrec1),'k',linewidth=2)
        plot(np.array(self.trec),np.array(self.vrec2),'r',linewidth=2)
        xlim([0,neuron.h.tstop])
        xlabel('Time (ms)')
        ylabel('Vm (mV)')
        tight_layout()
        show()

smallnet = SmallNetwork(10)
smallnet.running()
smallnet.plotImages()



ted
Site Admin
Posts: 5514
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Neuron and Python stim-response error

Post by ted » Wed Nov 19, 2014 10:21 pm

Start small--one cell with one synaptic mechanism attached to it, driven by a single NetStim.
Learn about your model cell and how it responds to synaptic input. See what happens to membrane potential for the particular synaptic weight and time constant(s) you chose.
Use what you learned to fix your problem.

This is a special case of the "learn to walk before trying to dance" strategy for achieving mastery.

Post Reply