Esempio n. 1
0
def simulate_ahp(**kw):

    n = len(kw.get('ahp_curr'))
    I_vec = numpy.array(kw.get('ahp_curr'))

    simTime = 3000.  # ms
    my_nest.ResetKernel({'local_num_threads': 1})

    sd = {'active': True, 'params': {'to_memory': True, 'to_file': False}}
    mm = {
        'active': True,
        'params': {
            'interval': 0.1,
            'to_memory': True,
            'to_file': False
        }
    }
    p = kw.get('rs_params')

    if 'type_id' in p.keys(): del p['type_id']
    mnn = MyNetworkNode('dummy',
                        model=kw.get('model'),
                        n=n,
                        params=p,
                        mm=mm,
                        sd=sd)

    my_nest.SetStatus(mnn[:], params={'I_e': kw.get('ahp_I_e')})  # Set I_e

    scg = my_nest.Create('step_current_generator', n=n)
    rec = my_nest.GetStatus(mnn[:])[0]['receptor_types']

    for source, target, I in zip(scg, mnn[:], I_vec):
        my_nest.SetStatus([source], {
            'amplitude_times': [500., 1000.],
            'amplitude_values': [float(I), 0.]
        })
        my_nest.Connect([source], [target],
                        params={'receptor_type': rec['CURR']})

    my_nest.MySimulate(simTime)

    signal = mnn.spike_signal.time_slice(700, 3000)

    delays = []
    for i in range(n):
        #         print signal.spiketrains[i+1.0].spike_times
        v = numpy.diff(signal.spiketrains[i + 1.0].spike_times)
        v = numpy.append(v, [0])
        delays.append(max(v))

    dg = Data_generic(**{
        'x': I_vec,
        'y': delays,
        'xlabel': 'Time (ms)',
        'ylabel': 'Voltage (mV)'
    })

    return {'ahp': dg}
Esempio n. 2
0
def simulate_IF(**kw):

    I_vec_in = kw.get('if_I_vec')

    tStim = 700 + 1300
    my_nest.ResetKernel({'local_num_threads': 1})

    sd = {
        'active': True,
        'params': {
            'to_memory': True,
            'to_file': False,
            'start': 500.0
        }
    }
    #     mm={'active':True,
    #         'params':{'interval':0.1,'to_memory':True,'to_file':False}}
    p = kw.get('if_params')
    if 'type_id' in p.keys(): del p['type_id']
    mnn = MyNetworkNode('dummy', model=kw.get('model'), n=1, params=p, sd=sd)

    I_e0 = my_nest.GetStatus(mnn[:])[0]['I_e']
    my_nest.SetStatus(mnn[:], params={'I_e': I_e0 + kw.get('I_E')})  # Set I_e

    I_vec_out, fIsi, mIsi, lIsi = mnn.run_IF(I_vec_in, tStim=tStim)

    d = {
        'x': I_vec_out,
        'first': 1000. / fIsi,
        'mean': 1000. / mIsi,
        'last': 1000. / lIsi,
    }

    return {'IF': Data_IF_curve(**d)}
Esempio n. 3
0
def simulate_rebound_spike(**kw):
    
    n=len(kw.get('rs_curr'))
    
    simTime  = 3000.  # ms
    my_nest.ResetKernel({'local_num_threads':1})

    sd={'active':True, 'params':{'to_memory':True,'to_file':False}}
    mm={'active':True,
        'params':{'interval':0.1,'to_memory':True,'to_file':False}}
    p=kw.get('rs_params')
    
    if 'type_id' in p.keys(): del p['type_id']
    mnn=MyNetworkNode('dummy',model=kw.get('model'), n=n, params=p, mm=mm, sd=sd)
    
    my_nest.SetStatus(mnn[:], params={'I_e':.5}) # Set I_e
    I_e = my_nest.GetStatus(mnn.ids,'I_e')[0]    
    
    scg = my_nest.Create( 'step_current_generator',n=n )  
    rec=my_nest.GetStatus(mnn[:])[0]['receptor_types']
    
    i=0
    for t, c in zip(kw.get('rs_time'), kw.get('rs_curr')):
        my_nest.SetStatus([scg[i]], {'amplitude_times':[500.,t+500.],
                                'amplitude_values':[float(c),0.]})
        my_nest.Connect( [scg[i]], [mnn[i]],  params = { 'receptor_type' : rec['CURR'] } )
        i+=1
    
    my_nest.MySimulate(simTime)
    mnn.voltage_signal.my_set_spike_peak( 21, spkSignal= mnn.spike_signal )
    
    d={}
    for i in range(n):
        voltage=mnn.voltage_signal.analog_signals[i+1].signal
        x=numpy.linspace(0,simTime, len(voltage))
        dg=Data_generic(**{'x':x, 'y':voltage, 'xlabel':'Time (ms)', 'ylabel':'Voltage (mV)'})
        misc.dict_update(d, {'rs_voltage_{0}'.format(i):dg})
    rd=mnn.spike_signal.raw_data()
    dg=Data_scatter(**{'x':rd[:,0], 'y':rd[:,1], 'xlabel':'Time (ms)', 'ylabel':'Voltage (mV)'})
    misc.dict_update(d, {'rs_scatter':dg})
    
    return d
Esempio n. 4
0
def simulate_IV(**kw):

    I_vec = kw.get('iv_I_vec')
    my_nest.ResetKernel({'local_num_threads': 1})

    sd = {
        'active': True,
        'params': {
            'to_memory': True,
            'to_file': False,
            'start': 500.0
        }
    }
    mm = {
        'active': True,
        'params': {
            'interval': 0.1,
            'to_memory': True,
            'to_file': False
        }
    }
    p = kw.get('iv_params')
    if 'type_id' in p.keys(): del p['type_id']
    mnn = MyNetworkNode('dummy',
                        model=kw.get('model'),
                        n=1,
                        params=p,
                        mm=mm,
                        sd=sd)

    I_e0 = my_nest.GetStatus(mnn[:])[0]['I_e']
    my_nest.SetStatus(mnn[:], params={'I_e': I_e0 + kw.get('I_E')})  # Set I_e

    x, y = mnn.run_IV_I_clamp(I_vec)
    print x, y
    dg = Data_generic(**{
        'x': x,
        'y': y,
        'xlabel': 'Current (pA)',
        'ylabel': 'Voltage (mV)'
    })

    return {'IV': dg}
Esempio n. 5
0
def simulate_irregular_firing(**kw):

    n = len(kw.get('irf_curr'))
    I_vec = numpy.array(kw.get('irf_curr'))

    simTime = 2000.  # ms
    my_nest.ResetKernel({'local_num_threads': 1})

    sd = {'active': True, 'params': {'to_memory': True, 'to_file': False}}
    mm = {
        'active': True,
        'params': {
            'interval': 0.1,
            'to_memory': True,
            'to_file': False
        }
    }
    p = kw.get('rs_params')

    if 'type_id' in p.keys(): del p['type_id']
    mnn = MyNetworkNode('dummy',
                        model=kw.get('model'),
                        n=n,
                        params=p,
                        mm=mm,
                        sd=sd)

    I_e0 = my_nest.GetStatus(mnn.ids, 'I_e')[0]

    for i, I_e in enumerate(I_vec):
        my_nest.SetStatus([mnn[i]], params={'I_e': I_e + I_e0})

    scg = my_nest.Create('step_current_generator', n=n)
    noise = my_nest.Create('noise_generator', params={'mean': 0., 'std': 10.})
    rec = my_nest.GetStatus(mnn[:])[0]['receptor_types']

    for source, target, I in zip(scg, mnn[:], I_vec):
        my_nest.SetStatus([source], {
            'amplitude_times': [1., simTime],
            'amplitude_values': [-5., float(I)]
        })
        my_nest.Connect([source], [target],
                        params={'receptor_type': rec['CURR']})
        my_nest.Connect(noise, [target], params={'receptor_type': rec['CURR']})

    my_nest.MySimulate(simTime)
    mnn.voltage_signal.my_set_spike_peak(21, spkSignal=mnn.spike_signal)

    d = {}
    for i in range(n):
        voltage = mnn.voltage_signal.analog_signals[i + 1].signal
        x = numpy.linspace(0, simTime, len(voltage))
        dg = Data_generic(**{
            'x': x,
            'y': voltage,
            'xlabel': 'Time (ms)',
            'ylabel': 'Voltage (mV)'
        })
        misc.dict_update(d, {'irf_voltage_{0}'.format(i): dg})


#     my_nest.MySimulate(simTime)
#     mnn.get_signal( 'v','V_m', stop=simTime ) # retrieve signal
#     mnn.get_signal( 's') # retrieve signal
#     mnn.signals['V_m'].my_set_spike_peak( 15, spkSignal= mnn.signals['spikes'] )

    return d