Ejemplo n.º 1
0
def main():
    gid  = 0
    model = 'kr'
    cell_size = 120
    N = 20
    neurons = [KhaliqRaman(gid,
                           {'diameter':cell_size,'length':cell_size,
                            'nSynapses':0,'channelNoise':False})
               for gid in range(N)]
    baseline = []
    pulse = []
    for n,current in zip(neurons,np.linspace(0.04,0.07,N)):
        baseline.append(h.IClamp(n.soma(0.5)))
        baseline[-1].amp = -0.17
        baseline[-1].dur = 2000
        baseline[-1].delay = 0
        pulse.append(h.IClamp(n.soma(0.5)))
        pulse[-1].amp = current
        pulse[-1].dur = 1000
        pulse[-1].delay = 500
 
    for i,n in enumerate(neurons):
        n.addSomaticVoltageRecorder()
    time = h.Vector()
    time.record(h._ref_t)

    h.load_file('stdrun.hoc')
    h.tstop = 2000
    h.run()
    
    import pylab as plt
    fig = plt.figure()
    for i,n in enumerate(neurons):
#        fig.add_subplot(len(neurons),1,i)
        plt.plot(time,n.somaticVoltage()+(i-1)*5)
    plt.show()
    ipdb.set_trace()

    h.quit()
Ejemplo n.º 2
0
def makeStimulus(neuron, simTime):
    VecAxon = h.Vector()
    VecAxon.record(neuron(0.5)._ref_v)
    stim = h.IClamp(neuron(0))
    stim.dur = simTime
    vecCurrent = h.Vector()
    vecCurrent.record(stim._ref_i)
    time = h.Vector()
    time.record(h._ref_t)
    listOfSines = []
    listOfTimes = []
    for i in range(0, simTime):
        a = random.randint(1, 100)
        if a > 95:
            listOfSines.append(15)
        else:
            listOfSines.append(0)
        listOfTimes.append(i)
    print listOfSines
    VecT = h.Vector(listOfTimes)
    VecStim = h.Vector(listOfSines)
    VecStim.play(stim._ref_amp, VecT, 1)
    return (VecStim, VecT, stim)
Ejemplo n.º 3
0
Archivo: prc.py Proyecto: jcouto/neuron
       # iPID = []
        iPulse = []
        #estimatedFreq = []
#       gaussCurrent = []
        for i,n in enumerate(neurons):
            n.addSomaticVoltageRecorder()
 #           iPID.append(h.Vector())
            iPulse.append(h.Vector())
#            estimatedFreq.append(h.Vector())
#           gaussCurrent.append(h.Vector())
#            iPID[-1].record(n._prc_sobol._ref_iPI)
            iPulse[i].record(n._prc_sobol._ref_iPulse)
#           gaussCurrent[-1].record(n._IClampNoise._ref_i)
#            estimatedFreq[-1].record(n._prc_sobol._ref_estimatedFreq)
        time = h.Vector()
        time.record(h._ref_t)

    h.load_file('stdrun.hoc')
    print('Going to run for %dms'%duration)
    h.tstop = duration
    h.run()
#    print neurons[0].perturbationTimes()
    print('Computed prc for frequency %3.0fHz.'%(frequency))
    downsampleFactor=4
    for ii,n in enumerate(neurons):
        saveNeuron(filename, n, saveVoltage=False, simulationName='PRC %s'%(model))
        fid = h5.File(filename, 'a')
        groupName = '/Neurons/ID_' + str(n.ID)
        group = fid[groupName]
        ds = group.create_dataset('Perturbation',data= np.array(iPulse[ii])[::downsampleFactor])
        dt = np.unique(np.round(np.diff(np.array(time)[::downsampleFactor]),3))[0]