def get():
    
    l=[];
    p={'equal':{},
          'mul':{}}#

    
    for w1, w2 in [
                    [1., .0],      
                    [.8, .2], 
                    [.6, .4],    
                    [.5, .5],    
                    [.4, .6],       
                    [.2, .8],      
                    [.0, 1.],
                   ]:
                     
        d={}
        
        d=misc.dict_update(p['mul'], d) 
        
        l+=[pl(d, '*', **{'name':''})]
        
        d={'nest':{
                   'GA_FS_gaba':{'weight':w1},
                   'GF_FS_gaba':{'weight':w2}
                  }}

        d=misc.dict_update(p['equal'], d) 

        s='GA_{0}_GF_{1}'.format( w1, w2 )
        
        l[-1]+=pl(d, '=', **{'name':s})     
    
    return l
def get():

    l = []
    solution, s_mul, s_equal = get_solution()

    # Decrease/increase C1,C2,CF,CS, EI and EA. Test idea that at
    # slow wave cortical and thalamic input is decreased.
    mod = numpy.arange(0.5, 1.5, 0.05)
    for x in mod:

        d = {}
        for keys in s_mul:
            update(solution, d, keys)
        misc.dict_update(d, {'node': {'CF': {'rate': x}}})
        misc.dict_update(d, {'node': {'CS': {'rate': x}}})

        l += [pl(d, '*', **{'name': ''})]

        d = {}
        for keys in s_equal:
            update(solution, d, keys)

        d['node']['C1']['rate'] *= x
        d['node']['C2']['rate'] *= x
        d['node']['EI']['rate'] *= x
        d['node']['EA']['rate'] *= x
        l[-1] += pl(d, '=', **{'name': 'mod_C1_C2_CF_CS_EI_EA_' + str(x)})

    return l
def get():
        
    l=[]
    solution, s_mul, s_equal=get_solution()
    
    # Decrease/increase C1,C2,CF,CS, EI and EA. Test idea that at
    # slow wave cortical and thalamic input is decreased. 
    mod=numpy.arange(0.5, 1.5, 0.05)
    for x in mod:

        
        d={}
        for keys in s_mul: update(solution, d, keys) 
        misc.dict_update(d, {'node':{'CF':{'rate':x}}} )
        misc.dict_update(d, {'node':{'CS':{'rate':x}}} )

        l+=[pl(d, '*', **{'name':''})]
          
        d={}
        for keys in s_equal: update(solution, d, keys)

        d['node']['C1']['rate']*=x
        d['node']['C2']['rate']*=x        
        d['node']['EI']['rate']*=x
        d['node']['EA']['rate']*=x
        l[-1]+=pl(d, '=', **{'name':'mod_C1_C2_CF_CS_EI_EA_'+str(x)}) 
              

    return l
def gather(path, **kw):
    tuning_key=kw.get('tuning_freq_amp_to')
             
    fs=os.listdir(path)
    d={}
    for name in sorted(fs):
        if name[-4:]!='.pkl':
            continue
        file_name=path+name[:-4]
        sd = Storage_dic.load(file_name)
        
        dd=sd.load_dic(*['Net_0', tuning_key,'mean_rate_slices'])
        d = misc.dict_update(d, {name[:-4]:dd['Net_0']})
    
#     ax=pylab.subplot(211)
    if d=={}:
        i=0
        for name in sorted(fs):
            if name[0:6]!='script':
                continue
#             i+=1
#             ax=pylab.subplot(5,6,i)
            file_name=path+name+'/'+'Net_0'
            sd = Storage_dic.load(file_name)
            dd=sd.load_dic(*['Net_0', tuning_key,'mean_rate_slices', 'firing_rate'])
            print file_name
            pp(dd)
#             ax.plot(dd['Net_0']['M1']['firing_rate'].y)
#             ax.text(0.1,0.1,name, transform=ax.transAxes, fontsize=7)
            d = misc.dict_update(d, {name:dd['Net_0']})
            
            
#     pylab.show()
    return d
示例#5
0
    def par(self):
        d={'simu':{
                   'print_time':False,
                   'start_rec':1000.0
                   },
#            'netw':{'rand_nodes':{'C_m':True, 
#                                  'V_th':True, 
#                                  'V_m':True}}
           }
        
        misc.dict_update(d,self.target_perturbations()[self.tp_name])
        return d
示例#6
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
def simulate(from_disk=0,
             kw={},
             net='Net_0',
             script_name=__file__.split('/')[-1][0:-3],
             setup=Setup(50,20) ):
    
    setup=Setup(50,20) 
    file_name = kw.get('file_name', dr.HOME_DATA+'/'+script_name)
    file_name_figs = kw.get('file_name_figs', dr.HOME_DATA+'/fig/'+script_name)
    
    sd=get_storage_list([net], file_name, '')[0]
    
    d={}
    if from_disk==0:
        print net
        dd={net:simulate_network(**kw)}
        dd=compute_attrs(dd, net, setup)
        save(sd, dd)
    
    if from_disk==1:
        filt= [net]+['gi','st', 'gi_st']+['spike_signal']
        dd = load(sd, *filt)
        pp(dd)
        dd=compute_attrs(dd, net, setup)
        save(sd, dd)
        
    elif from_disk==2:
        filt = [net]+['gi','st', 'gi_st']+['firing_rate', 'phases_diff_with_cohere'] 
        dd = load(sd, *filt)
    
    d = misc.dict_update(d, dd)

    return d, file_name_figs
示例#8
0
    def create_mm(self, name, d_add, **kw):
        model = name + '_multimeter'
        if model not in my_nest.Models():
            my_nest.CopyModel('multimeter', model)
        d = {
            'active': False,
            'id': [],
            'model': name + '_multimeter',
            'params': {
                'record_from': ['V_m'],
                'start': 0.0,
                'stop': numpy.inf,
                'interval': 1.,
                'to_file': False,
                'to_memory': True
            }
        }  # recodring interval (dt)
        d = misc.dict_update(d, d_add)
        if d['active']:
            _id = my_nest.Create(model, params=d['params'])
            if 'slice' in kw.keys():
                my_nest.DivergentConnect(_id, self.ids[kw['slice']])
            else:
                my_nest.DivergentConnect(_id, self.ids)

            d.update({'id': _id, 'model': model})
        return d
 def get_perturbation_dics(c, w_rel):
     d = {}
     for key in c.keys():
         for conn in c[key]:
             u = {key:{'nest':{conn:{'weight':w_rel}}}}
             d = misc.dict_update(d, u)
     return d
示例#10
0
def simulate(from_disk=0,
             kw={},
             net='Net_0',
             script_name=__file__.split('/')[-1][0:-3],
             setup=Setup(50, 20)):

    setup = Setup(50, 20)
    file_name = kw.get('file_name', dr.HOME_DATA + '/' + script_name)
    file_name_figs = kw.get('file_name_figs',
                            dr.HOME_DATA + '/fig/' + script_name)

    sd = get_storage_list([net], file_name, '')[0]

    d = {}
    if from_disk == 0:
        print net
        dd = {net: simulate_network(**kw)}
        dd = compute_attrs(dd, net, setup)
        save(sd, dd)

    if from_disk == 1:
        filt = [net] + ['gi', 'st', 'gi_st'] + ['spike_signal']
        dd = load(sd, *filt)
        pp(dd)
        dd = compute_attrs(dd, net, setup)
        save(sd, dd)

    elif from_disk == 2:
        filt = [net] + ['gi', 'st', 'gi_st'
                        ] + ['firing_rate', 'phases_diff_with_cohere']
        dd = load(sd, *filt)

    d = misc.dict_update(d, dd)

    return d, file_name_figs
 def get_perturbation_dics(c, w_rel):
     d = {}
     for key in c.keys():
         for conn in c[key]:
             u = {key: {'nest': {conn: {'weight': w_rel}}}}
             d = misc.dict_update(d, u)
     return d
def get():
    
    l=[]
    
    d={}
    for name in ['M1', 'CTX_M1', 'CTX_M2', 'MS_MS', 'FS_FS', 
                 'GP_FS', 'FS_M2', 'M2_GI', 'FS', 
                 'GA_MS', 'GA_FS', 'GI_FS']:

        d=misc.dict_update(d, get_change_to(name))
        
    l+=[pl(d,'*', **{'name':'no_ch_dop-striatum'})]
    

    d={}
    for name in ['CTX_ST', 'GP_ST', 'GP', 'ST_GP', 'GP_GP', 'SN', 'M1_SN']:
        d=misc.dict_update(d, get_change_to(name))
        
    l+=[pl(d,'*', **{'name':'no_ch_dop-GP_ST_SN'})]
    
    
    d={}
    for name in ['M1', 'CTX_M1', 'CTX_M2', 'MS_MS', 'FS_FS', 
                 'GP_FS', 'FS_M2', 'CTX_ST', 'GP_ST', 'GP',
                 'ST_GP', 'GP_GP', 'SN', 'M1_SN',
                     'M2_GI', 'FS', 
                 'GA_MS', 'GA_FS', 'GI_FS']:
        d=misc.dict_update(d, get_change_to(name))
        pp(d)
        
    l+=[pl(d,'*', **{'name':'no_ch_dop-all'})]

    for s in [ 'CTX_M1', 'CTX_M2', 'MS_MS', 'FS_FS', 
              'GP_FS', 'FS_M2', 'CTX_ST', 'GP_ST', 'GP',
              'ST_GP', 'GP_GP', 'SN', 'M1_SN', 'M2_GI',
              'FS','M1', 
              'GA_MS', 'GA_FS', 'GI_FS']:
        d={}
        for name in [s]:
            d=misc.dict_update(d, get_change_to(name))
            
        l+=[pl(d,'*', **{'name':'no_ch-'+s})]    
    
    d={}
    l+=[pl(d,'*', **{'name':'-Normal'})]   
        
    return l
示例#13
0
 def get_perturbation_dics(val, hz_mod, i):
     d = {}
     #         for key in c.keys():
     for neuron, hz_pA in val:
         hz = hz_mod[neuron][i]
         u = {key: {'node': {neuron: {'I_vivo': 1. / hz_pA * hz}}}}
         d = misc.dict_update(d, u)
     return d
    def get_perturbation_dics(val, hz_mod, i):
        d = {}
#         for key in c.keys():
        for neuron, hz_pA in val:
            hz=hz_mod[neuron][i]
            u = {key:{'node':{neuron:{'I_vivo':1./hz_pA*hz}}}}
            d = misc.dict_update(d, u)
        return d
def get():

    l = []

    d = {}
    for name in [
            'M1', 'CTX_M1', 'CTX_M2', 'MS_MS', 'FS_FS', 'GP_FS', 'FS_M2',
            'M2_GI', 'FS'
    ]:

        d = misc.dict_update(d, get_change_to(name))

    l += [pl(d, '*', **{'name': 'no_ch_dop-striatum'})]

    d = {}
    for name in ['CTX_ST', 'GP_ST', 'GP', 'ST_GP', 'GP_GP', 'SN', 'M1_SN']:
        d = misc.dict_update(d, get_change_to(name))

    l += [pl(d, '*', **{'name': 'no_ch_dop-GP_ST_SN'})]

    d = {}
    for name in [
            'M1', 'CTX_M1', 'CTX_M2', 'MS_MS', 'FS_FS', 'GP_FS', 'FS_M2',
            'CTX_ST', 'GP_ST', 'GP', 'ST_GP', 'GP_GP', 'SN', 'M1_SN', 'M2_GI',
            'FS'
    ]:
        d = misc.dict_update(d, get_change_to(name))
        pp(d)

    l += [pl(d, '*', **{'name': 'no_ch_dop-all'})]

    for s in [
            'M1', 'CTX_M1', 'CTX_M2', 'MS_MS', 'FS_FS', 'GP_FS', 'FS_M2',
            'CTX_ST', 'GP_ST', 'GP', 'ST_GP', 'GP_GP', 'SN', 'M1_SN', 'M2_GI',
            'FS'
    ]:
        d = {}
        for name in [s]:
            d = misc.dict_update(d, get_change_to(name))

        l += [pl(d, '*', **{'name': 'no_ch-' + s})]

    d = {}
    l += [pl(d, '*', **{'name': '-Normal'})]

    return l
示例#16
0
def simulate(builder, from_disk, perturbation_list, script_name, setup):
    home = expanduser("~")
    
#     file_name = get_file_name(script_name, home)
#     file_name_figs = get_file_name_figs(script_name, home)
#     
    d_firing_rate = setup.firing_rate()
    
    attr = ['firing_rate', 'mean_rate_slices']
    attr_conn=['conn_matrix']
    models=['M1', 'M2']
    models_conn=['M1_M1_gaba', 'M1_M2_gaba',
                 'M2_M1_gaba', 'M2_M2_gaba']
    sets = ['set_0']
    
    info, nets, intervals, rep, x = get_networks(builder, 
                                                  **setup.builder())
    
    key=nets.keys()[0]
    file_name = get_file_name(script_name, nets[key].par)
    file_name_figs = get_file_name_figs(script_name,  nets[key].par)   
    
    path_nest=get_path_nest(script_name, nets.keys(), nets[key].par)
    for net in nets.values():
        net.set_path_nest(path_nest)
    
    kwargs_dic = {'firing_rate':d_firing_rate, 
                  'mean_rate_slices': {'intervals':intervals[1], 
                                       'repetition':rep, 
                                       'set_0':{'x':x}, 
                                       'sets':[0]}}

#     add_perturbations(perturbation_list, nets)    
#     sd = get_storage(file_name, info)
# 
# #     _, d1 = main_loop_conn(from_disk, attr_conn, models_conn, 
# #                               sets, nets, kwargs_dic, sd)     
    d1={}
#     from_disks, d2 = main_loop(from_disk, attr, models, 
#                               sets, nets, kwargs_dic, sd)
#     
    add_perturbations(perturbation_list, nets)

    # Adding nets no file name
    sd_list=get_storage_list(nets, file_name, info)

    from_disks, d2 = main_loop(from_disk, attr, models, 
                              sets, nets, kwargs_dic, sd_list) 
    
    d=misc.dict_update(d1,d2)
    if from_disk==2:
        d=cmp_mean_rate_diff(d, models, [['Net_0', 'Net_5'],
                                         ['Net_1', 'Net_6'],
                                         ['Net_2', 'Net_7'],
                                         ['Net_3', 'Net_8'],
                                         ['Net_4', 'Net_9']], x)

    return file_name, file_name_figs, from_disks, d, models
示例#17
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':kw.get('rs_I_e')}) # Set I_e
    
#     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
示例#18
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
示例#19
0
def simulate(
        from_disk=0,
        kw={},
        net='Net_0',
        script_name=__file__.split('/')[-1][0:-3],
        setup=Setup(50, 20),
):

    file_name = kw.get('file_name', dr.HOME_DATA + '/' + script_name)
    file_name_figs = kw.get('file_name_figs',
                            dr.HOME_DATA + '/fig/' + script_name)

    sd = get_storage_list([net], file_name, '')[0]

    d = {}

    if from_disk == 0:
        print net
        dd = {}
        for call in kw.get('calls', [
                simulate_irregular_firing,
                simulate_ahp,
                simulate_IV,
                simulate_IF,
                get_nullcline,
                simulate_rebound_spike,
        ]):
            misc.dict_update(dd, {net: call(**kw)})

        save(sd, dd)

    elif from_disk == 1:
        filt = kw.get('filter', [net] + ['IV', 'IF', 'ahp', 'nullcline'] +
                      ['rs_scatter'] +
                      ['rs_voltage_{0}'.format(i) for i in range(6)] +
                      ['irf_voltage_{0}'.format(i) for i in range(3)])
        dd = load(sd, *filt)

    d = misc.dict_update(d, dd)

    return d, file_name_figs
示例#20
0
    def load_mpi(cls, file_name, nets):
        '''It makes perfect sense that you should use foo=Foo.load(), 
        and not foo=Foo();foo.load(). for example, if Foo has some 
        variables that MUST be passed in to the init, you would need 
        to make them up for foo=Foo(); or if the init does some heavy 
        calculations of variables stored in the instance, 
        it would be for nothing. '''

        if os.path.isfile(file_name + '.pkl'):

            #             cls.file_name=file_name
            #             cls.directory=file_name+'/'
            out = {}
            for net in nets:
                file_name = file_name + '/' + net
                d = pickle_load(file_name)
                d.force_update(file_name)
                misc.dict_update(out, d)
            return out
        else:
            return Storage_dic(file_name)
示例#21
0
def perturbations():
    sim_time = 10000.0
    size = 20000.0
    threads = 1

    freqs = [1., 2.0]

    path = ('/home/mikael/results/papers/inhibition' +
            '/network/simulate_inhibition_ZZZ4/')
    l = op.get()[-3:]

    for i in range(len(l)):
        l[i] += pl(
            {
                'simu': {
                    'sim_time': sim_time,
                    'sim_stop': sim_time,
                    'threads': threads
                },
                'netw': {
                    'size': size
                }
            }, '=')

    damp = process(path, freqs)
    for key in sorted(damp.keys()):
        val = damp[key]
        print numpy.round(val, 2), key

    ll = []
    for i, _l in enumerate(l):
        for j, _ in enumerate(freqs):

            amp = [numpy.round(damp[_l.name][j], 2), 1]
            d = {
                'type': 'oscillation2',
                'params': {
                    'p_amplitude_mod': amp[0],
                    'p_amplitude0': amp[1],
                    'freq': 20.
                }
            }
            _ll = deepcopy(_l)
            dd = {}
            for key in ['C1', 'C2', 'CF', 'CS']:
                dd = misc.dict_update(dd, {'netw': {'input': {key: d}}})

            _ll += pl(dd, '=', **{'name': 'amp_{0}-{1}'.format(*amp)})

            ll.append(_ll)

    return ll, threads
示例#22
0
def get():

    l = []
    p = {'equal': {}, 'mul': {}}  #

    for w1, w2 in [
        [1., .0],
        [.8, .2],
        [.6, .4],
        [.5, .5],
        [.4, .6],
        [.2, .8],
        [.0, 1.],
    ]:

        d = {}

        d = misc.dict_update(p['mul'], d)

        l += [pl(d, '*', **{'name': ''})]

        d = {
            'nest': {
                'GA_FS_gaba': {
                    'weight': w1
                },
                'GF_FS_gaba': {
                    'weight': w2
                }
            }
        }

        d = misc.dict_update(p['equal'], d)

        s = 'GA_{0}_GF_{1}'.format(w1, w2)

        l[-1] += pl(d, '=', **{'name': s})

    return l
示例#23
0
    def load_mpi(cls, file_name, nets):
        '''It makes perfect sense that you should use foo=Foo.load(), 
        and not foo=Foo();foo.load(). for example, if Foo has some 
        variables that MUST be passed in to the init, you would need 
        to make them up for foo=Foo(); or if the init does some heavy 
        calculations of variables stored in the instance, 
        it would be for nothing. '''
        
        if os.path.isfile(file_name+'.pkl'):   

                
#             cls.file_name=file_name
#             cls.directory=file_name+'/'
            out={}
            for net in nets:   
                file_name=file_name+'/'+net
                d= pickle_load(file_name) 
                d.force_update(file_name)
                misc.dict_update(out, d)
            return out
        else:
            return Storage_dic(file_name)
示例#24
0
def gather2(path, nets, models, attrs):

    fs = os.listdir(path)
    d = {}
    i = 0
    for name0 in fs:
        dd = {}
        for net in nets:
            name = name0 + '/' + net + '.pkl'

            if not os.path.isfile(path + name):
                print name
                continue
            file_name = path + name[:-4]
            sd = Storage_dic.load(file_name)
            args = nets + models + attrs
            misc.dict_update(dd, sd.load_dic(*args))

        if dd:
            d = misc.dict_update(d, {name0.split('-')[-1]: dd})
        i += 1
    return d
示例#25
0
def simulate(from_disk=0,
             kw={},
             net='Net_0',
             script_name=__file__.split('/')[-1][0:-3],
             setup=Setup(50,20),
            ):
    
    file_name = kw.get('file_name', dr.HOME_DATA+'/'+script_name)
    file_name_figs = kw.get('file_name_figs', dr.HOME_DATA+'/fig/'+script_name)
    
    sd=get_storage_list([net], file_name, '')[0]
    
    d={}
    
    if from_disk==0:
        print net
        dd={}
        for call in kw.get('calls',[simulate_irregular_firing, 
                                    simulate_ahp,
                                    simulate_IV, 
                                    simulate_IF,
                                    get_nullcline,
                                    simulate_rebound_spike,]):
            misc.dict_update(dd,{net:call(**kw)})
        
        save(sd, dd)        
        
    elif from_disk==1:
        filt = kw.get('filter', [net]+['IV', 'IF', 'ahp', 'nullcline'] 
                      +['rs_scatter']+['rs_voltage_{0}'.format(i) for i in range(6)]
                      +['irf_voltage_{0}'.format(i) for i in range(3)])
        dd = load(sd, *filt)
        
    d = misc.dict_update(d, dd)    
    
    return d, file_name_figs
示例#26
0
def gather2(path, nets, models, attrs): 
    

    fs=os.listdir(path)
    d={}
    i=0
    for name0 in fs:
        dd={}
        for net in nets:
            name=name0+'/'+net+'.pkl'
            
            
            if not os.path.isfile(path+name):
                print name
                continue
            file_name=path+name[:-4]
            sd = Storage_dic.load(file_name)
            args=nets+models+attrs
            misc.dict_update(dd, sd.load_dic(*args))

        if dd:  
            d = misc.dict_update(d, {name0.split('-')[-1]:dd})
        i+=1
    return d
示例#27
0
def main():
    k = get_kwargs_builder()

    from os.path import expanduser
    home = expanduser("~")

    attr = ['firing_rate', 'mean_rates', 'spike_statistic']

    kwargs_dic = {
        'mean_rates': {
            't_start': k['start_rec']
        },
        'spike_statistic': {
            't_start': k['start_rec']
        },
    }
    file_name = (home + '/results/papers/inhibition/network/' +
                 __file__.split('/')[-1][0:-3])

    models = ['M1', 'M2', 'FS', 'GI', 'GA', 'ST', 'SN']

    info, nets, _ = get_networks()

    sd = Storage_dic.load(file_name)
    sd.add_info(info)
    sd.garbage_collect()

    d = {}
    for net, from_disk in zip(nets, [1] * 2):
        if not from_disk:
            dd = run(net)
            dd = compute(dd, models, attr, **kwargs_dic)
            save(sd, dd)
        elif from_disk:
            filt = [net.get_name()] + models + attr
            dd = load(sd, *filt)
        d = misc.dict_update(d, dd)

    figs = []

    figs.append(show_fr(d, models))
    figs.append(show_hr(d, models))

    sd.save_figs(figs)

    if DISPLAY: pylab.show()

    pylab.show()
示例#28
0
def _run(storage_dic, d, net, from_disk, attr, **kwargs):
    model = net.get_single_unit()
    kwargs_dic = {attr: kwargs}
    if not from_disk:

        dd = {net.get_name(): net.simulation_loop()}
        dd = compute(dd, [model], [attr], **kwargs_dic)
        save(storage_dic, dd)
    elif from_disk:
        #         filt = [net.get_name()] + [model] + ['spike_signal']
        #         dd = load(storage_dic, *filt)
        #         dd = compute(dd, [model], [attr], **kwargs_dic)
        #         save(storage_dic, dd)
        filt = [net.get_name()] + [model] + [attr]
        dd = load(storage_dic, *filt)

    dd = reduce_levels(dd, [model] + [attr])
    d = misc.dict_update(d, dd)
    return d
示例#29
0
    def create_sd(self, name, d_add):
        model=name+'_spike_detector'
        if model not in my_nest.Models():
            my_nest.CopyModel('spike_detector', model )
            
        d={'active':False,
           'params': {"withgid": True, 
                      'to_file':False, 
                      'start':0.0, 
                      'stop':numpy.inf,
                      'to_memory':True }} 
        d=misc.dict_update(d, d_add) 
        if d['active']:
            _id=my_nest.Create(model, params=d['params'])

            my_nest.ConvergentConnect(self.ids, _id)

            d.update({'id':_id, 'model':model})
        
        return d 
示例#30
0
def main_loop(from_disk, attr, models, sets, nets, kwargs_dic, sd_list,
              **kwargs):

    run_method = kwargs.get('run', run)
    compute_method = kwargs.get('compute', compute)

    d = {}
    from_disks = [from_disk] * len(nets.keys())

    if type(sd_list) == list:
        iterator = [nets.values(), from_disks, sd_list]
    else:
        iterator = [nets.values(), from_disks]

    for vals in zip(*iterator):
        if type(sd_list) == list:
            net, fd, sd = vals
        else:
            net, fd = vals

        if fd == 0:
            dd = run_method(net)
            save(sd, dd)

        elif fd == 1:
            filt = [net.get_name()] + models + ['spike_signal']
            dd = load(sd, *filt)
            dd = compute_method(dd, models, attr, **kwargs_dic)
            save(sd, dd)

        elif fd == 2:
            print 'Loading data'
            filt = ([net.get_name()] + sets + models + attr +
                    kwargs.get('attrs_load', []))
            dd = load(sd, *filt)

        d = misc.dict_update(d, dd)

    return from_disks, d
示例#31
0
def _run_XX(flag, storage_dic, stim, d, net, from_disk):
    model = net.get_single_unit()
    inp = net.get_single_unit_input()

    if flag == 'IV':
        attr = 'IV_curve'
        stim_name = 'node.' + model + '.nest_params.I_e'
        call = getattr(net, 'sim_IV_curve')

    if flag == 'IF':
        attr = 'IF_curve'
        stim_name = 'node.' + model + '.nest_params.I_e'
        call = getattr(net, 'sim_IF_curve')

    if flag == 'FF':
        attr = 'FF_curve'
        stim_name = 'node.' + inp + '.rate'
        call = getattr(net, 'sim_FF_curve')

    if not from_disk:
        k = {
            'stim': stim,
            'stim_name': stim_name,
            'stim_time': net.get_sim_time(),
            'model': model
        }

        dd = {net.get_name(): call(**k)}
        dd = compute(dd, [model], [attr])
        save(storage_dic, dd)
    elif from_disk:
        filt = [net.get_name()] + [model] + [attr]
        dd = load(storage_dic, *filt)

    pp(dd)
    dd = reduce_levels(dd, [model] + [attr])
    d = misc.dict_update(d, dd)
    return d
示例#32
0
 def create_mm(self, name, d_add, **kw):
     model=name+'_multimeter'
     if model not in my_nest.Models():
         my_nest.CopyModel('multimeter', model )
     d={'active':False,
        'id':[],
        'model':name+'_multimeter', 
        'params': {'record_from':['V_m'], 
                   'start':0.0, 
                   'stop':numpy.inf,
                   'interval':1.,
                   'to_file':False,
                   'to_memory':True}} # recodring interval (dt) 
     d=misc.dict_update(d, d_add) 
     if d['active']:
         _id=my_nest.Create(model, params=d['params'])
         if 'slice' in kw.keys():
             my_nest.DivergentConnect(_id, self.ids[kw['slice']])
         else:
             my_nest.DivergentConnect(_id, self.ids)
         
         d.update({'id':_id, 'model':model})
     return d
示例#33
0
def _optimize(flag, net, storage_dic, d, from_disk, **kwargs):

    model = net.get_single_unit()
    inp = net.get_single_unit_input()
    attr = 'fmin'
    f = [model]
    if flag == 'opt_rate':
        x = ['node.' + inp + '.rate']
    if flag == 'opt_curr':
        x = ['node.' + model + '.nest_params.I_e']

    x0 = kwargs.get('x0', 900.)

    opt = {'netw': {'optimization': {'f': f, 'x': x, 'x0': x0}}}
    net.par.update_dic_rep(opt)

    kwargs_fmin = {
        'model': net,
        'call_get_x0': 'get_x0',
        'call_get_error': 'sim_optimization',
        'verbose': kwargs.get('verbose', True)
    }

    if not from_disk:
        f = Fmin(net.name, **kwargs_fmin)
        dd = {net.get_name(): {model: {attr: f.fmin()}}}
        print dd
        save(storage_dic, dd)
    elif from_disk:
        filt = [net.get_name()] + [model] + [attr]
        dd = load(storage_dic, *filt)

    dd = reduce_levels(dd, [model] + [attr])

    d = misc.dict_update(d, dd)

    return d
示例#34
0
    def create_sd(self, name, d_add):
        model = name + '_spike_detector'
        if model not in my_nest.Models():
            my_nest.CopyModel('spike_detector', model)

        d = {
            'active': False,
            'params': {
                "withgid": True,
                'to_file': False,
                'start': 0.0,
                'stop': numpy.inf,
                'to_memory': True
            }
        }
        d = misc.dict_update(d, d_add)
        if d['active']:
            _id = my_nest.Create(model, params=d['params'])

            my_nest.ConvergentConnect(self.ids, _id)

            d.update({'id': _id, 'model': model})

        return d
            dd = compute_attrs(dd, net)
            save(sd, dd)

        if from_disk == 1:
            filt = [net] + ['gi', 'st', 'gi_st'] + ['spike_signal']
            dd = load(sd, *filt)
            pp(dd)
            dd = compute_attrs(dd, net)
            save(sd, dd)

        elif from_disk == 2:
            filt = [net] + ['gi', 'st', 'gi_st'
                            ] + ['firing_rate', 'phases_diff_with_cohere']
            dd = load(sd, *filt)

        d = misc.dict_update(d, dd)

    pp(d)
    fig, axs = get_fig_axs()

    for i in range(len(nets)):
        d['Net_0{0}'.format(i)]['gi']['firing_rate'].plot(
            axs[i], **{'win': 1.})
        d['Net_0{0}'.format(i)]['st']['firing_rate'].plot(
            axs[i], **{'win': 1.})
        axs[i].set_xlim(0.0, 1500.0)

    colors = misc.make_N_colors('copper', len(kw_list))

    #     for net, c in zip(nets, colors):
    #         kw={ 'all':True,
示例#36
0
def get():

    l = []
    solution = get_solution()

    rEA = 200.0
    rES = 3200.0

    for rCS, rM2, rEI in [
        [250.0, 700.0, 1700.0],
        [200.0, 740.0, 1700.0],
        [250.0, 700.0, 1400.0],
    ]:
        d = {}
        misc.dict_update(d, solution['mul'])
        l += [pl(d, '*', **{'name': ''})]

        d = {}
        misc.dict_update(d, solution['equal'])
        d['node']['EI']['rate'] = rEI
        d['node']['EA']['rate'] = rEA
        d['node']['C2']['rate'] = rM2

        misc.dict_update(d, {'node': {'CS': {'rate': rCS}}})
        misc.dict_update(d, {'node': {'ES': {'rate': rES}}})
        s = 'rEI_{0}_rEA_{1}_rCS_{2}_rES_{3}_rM2_{4}'.format(
            rEI, rEA, rCS, rES, rM2)

        l[-1] += pl(d, '=', **{'name': s})

    rEI = 1700.0
    rEA = 200.0
    rCS = 250.0
    rES = 1800.0

    for wGISN in [0.8, 0.6, 0.4, 0.2]:
        d = {}
        misc.dict_update(d, solution['mul'])
        misc.dict_update(d, {'nest': {'GI_SN_gaba': {'weight': wGISN}}})
        l += [pl(d, '*', **{'name': ''})]

        d = {}
        misc.dict_update(d, solution['equal'])
        d['node']['EI']['rate'] = rEI
        d['node']['EA']['rate'] = rEA
        d['node']['C2']['rate'] = rM2

        misc.dict_update(d, {'node': {'CS': {'rate': rCS}}})
        misc.dict_update(d, {'node': {'ES': {'rate': rES}}})
        s = 'rEI_{0}_rEA_{1}_rCS_{2}_rES_{3}_rM2_{4}_wGISN_{5}'.format(
            rEI, rEA, rCS, rES, rM2, wGISN)

        l[-1] += pl(d, '=', **{'name': s})

    rEA = 200.0
    rES = 3200.0

    for rCS, rM2, rEI in [
        [250.0, 740.0, 1700.0],
    ]:
        d = {}
        misc.dict_update(d, solution['mul'])
        l += [pl(d, '*', **{'name': ''})]

        d = {}
        misc.dict_update(d, solution['equal'])
        d['node']['EI']['rate'] = rEI
        d['node']['EA']['rate'] = rEA
        d['node']['C2']['rate'] = rM2

        misc.dict_update(d, {'node': {'CS': {'rate': rCS}}})
        misc.dict_update(d, {'node': {'ES': {'rate': rES}}})
        s = 'rEI_{0}_rEA_{1}_rCS_{2}_rES_{3}_rM2_{4}'.format(
            rEI, rEA, rCS, rES, rM2)

        l[-1] += pl(d, '=', **{'name': s})

    return l
示例#37
0
    nets = ['Net_{0:0>2}'.format(i) for i in range(len(kw_list))]
    sd_list = get_storage_list(nets, path, '')

    d = {}
    for net, sd, kw in zip(nets, sd_list, kw_list):

        if from_disk == 0:  # and net=='Net_05':
            print net
            dd = {}
            for call in [
                    simulate_IV,
                    simulate_IF,
                    get_nullcline,
                    simulate_rebound_spike,
            ]:
                misc.dict_update(dd, {net: call(**kw)})

            save(sd, dd)

#         if from_disk==1:
#             filt= [net]+['gi','st', 'gi_st']+['spike_signal']
#             dd = load(sd, *filt)
#             pp(dd)
#             dd=compute_attrs(dd, net)
#             save(sd, dd)

        elif from_disk == 1:
            filt = [net] + ['IV', 'IF', 'nullcline'] + ['rs_scatter']
            dd = load(sd, *filt)

        d = misc.dict_update(d, dd)
def plot(file_name, figs, setup, flag,  **k):
    nets=['Net_0', 'Net_1']
    
    attr = [
        'firing_rate', 
        'mean_rates', 
        'spike_statistic'
        ]
    
    attr2=['psd',
           'activity_histogram',
           'activity_histogram_stat']
    
    attr_coher = [
                  'phase_diff', 
                  'phases_diff_with_cohere',
                  'mean_coherence'
                 ]
    
    models = ['M1', 'M2', 'FS', 'GI', 'GA', 'ST', 'SN', 'GP']
    models_coher = ['GI_GA', 'GI_GI', 'GA_GA', 'GA_ST', 'GI_ST', 'GP_GP',
                     'ST_ST', 'GP_ST',]
    
    # Adding nets no file name
    sd_list=get_storage_list(nets, file_name, '')
    
    d = {}
    
    for sd, net in zip(sd_list, nets):
        
    
        filt = ([net] 
                + models + models_coher 
                + attr + attr2 + attr_coher)
        dd = load(sd, *filt)
    
            #             cmp_statistical_test(models, dd)
        d = misc.dict_update(d, dd)
    
     
    kw=setup.plot_summed2()
    kw['alphas']=[1.,1.]
    kw['coherence_xcut']=[0,50]
    kw['coherence_color']=['grey', 'k']
    kw['coherence_p_conf95_linestyle']='--'
    kw['hatchs_ti_ti']=['','']
    kw['label_model']='Black=Model'
    kw['label_exp']='White=Exp., Mallet et al 2008'
    kw['linewidth']=1.
    kw['set_text_on_bars']=False
    kw['top_label']=False
    kw['phases_diff_with_cohere_colors']=['grey','k']
    kw['phases_diff_with_cohere_xcut']=[-numpy.pi*0.97, numpy.pi**0.97]
    kw['phases_diff_with_cohere_remove_peaks']=True
    kw['scale']=1
    kw['spk_stats_color_axis']=1
    kw['spk_stats_colors']=['k', 'w']
    kw['spk_stats_colors_ti_ta']=['k','w']
    kw['xlim_cohere']=[-1, 51]
    

    kw.update(k)
    figs.append(base_oscillation.show_summed2(d, **kw))
        
    kw=setup.plot_summed_STN()
    kw['alphas']=[1.,1.]
    kw['coherence_color']=['grey','k']
    kw['coherence_p_conf95_linestyle']='--'
    kw['hatchs_ti_ti']=['','']
    kw['label_model']='Black=Model'
    kw['label_exp']='White=Exp., Mallet et al 2008'
    kw['linewidth']=1.
    kw['phases_diff_with_cohere_xcut']=[-numpy.pi*0.97, numpy.pi**0.97]
    kw['phases_diff_with_cohere_remove_peaks']=True
    kw['phases_diff_with_cohere_colors']=['grey','k']
    kw['scale']=1
    kw['set_text_on_bars']=False
    kw['spk_stats_colors']=['k', 'w']
    kw['spk_stats_colors_ti_ta']=['k','w']
    kw['spk_stats_color_axis']=1
    kw['top_label']=False    
    kw['xlim_cohere']=[-1, 51]
    if flag=='slow_wave':
        kw['ylim_cohere']=[0, 1.0]
    elif flag=='beta':
        kw['ylim_cohere']=[0, 0.4]
        
    kw['coherence_xcut']=[0,50]
    kw.update(k)
    figs.append(base_oscillation.show_summed_STN(d, **kw))
    
    return figs
示例#39
0
def get_solution_eNeuro_rev():


    solution={'mul':{},
              'equal':{}}
    
    #Decreasing from 0.25 leads to ...
    #Increasing from 0.25 leads to ...
    d={'nest':{'M1_M1_gaba':{'weight':0.25},
               'M1_M2_gaba':{'weight':0.25},
               'M2_M1_gaba':{'weight':0.25},
               'M2_M2_gaba':{'weight':0.25}}}
    misc.dict_update(solution,{'mul':d})    
    
    # GA firing rate needs to be maintained, around 12 Hz for sw in 
    # dopamine depleted rats). When decreasing/increasing
    # ST-GA one need to either compensate by changing inhibition from 
    # GPe and/or EA external input (assume that synapses from TA and TI
    # are of equal strength. 
    
    # This script is first run where ST-GA GP-GA and EA individually are
    # perturbed to determine each relative influence to TA firing rate. 
    # From this data then combinations fo changes that should results in
    # 12 Hz TA firing rate are created.  
    d={'nest':{'ST_GA_ampa':{'weight':0.3},
               'GA_GA_gaba':{'weight':0.25},
               'GI_GA_gaba':{'weight':0.25},
               'GF_GA_gaba':{'weight':0.25},
               }}
    misc.dict_update(solution, {'mul':d})    

    # EA rate	    
    d={'node':{'EA':{'rate':200.0}}}
    misc.dict_update(solution,{'equal':d})
    

    
    
    # Lower GA IF curve.
    d={'nest':{'GA':{
                      'b':1.5,
                      'C_m':1.5,
                      'Delta_T':1.5
                      }}}
    misc.dict_update(solution,{'mul':d}) 
    
    # CF rate 
    d={'node':{'CF':{'rate':950.0}}}
    misc.dict_update(solution,{'equal':d})  
    
    
    d={'netw':{
               'GA_prop':0.25,
               'GI_prop':0.675, #<=0.9*0.75
               'GF_prop':0.075,     
               }}
    misc.dict_update(solution,{'equal':d})  
    
    
    # C1 and C2 have been set such that MSN D1 and MSN D2 fires at 
    # low firing rates (0.1-0,2 Hz). 
    d={'node':{'C1':{'rate':560.0},
               'C2':{'rate':700.}
               }}
    misc.dict_update(solution,{'equal':d})              
           
    # Set such that GPe TI fires in accordance with slow wave sleep
    # in dopamine depleted rats.
    d={'node':{
               'EI':{'rate':1400.0}, # Increase with 340, to get close to 24 Hz sw dopamine depleted rats TI
               'EF':{'rate':1400.0}, # Increase with 340, to get close to 24 Hz sw dopamine depleted rats TI
               }}
    misc.dict_update(solution,{'equal':d})           
    
    # Decrease weight since tau decay is 5 times stronger
    d={'nest':{'GA_M1_gaba':{'weight':0.04}, 
               'GA_M2_gaba':{'weight':0.08}}}
    misc.dict_update(solution,{'equal':d})            
     
    # GF connects stronger to GA. This accounts for Gage 2010 data.
#     d={'nest':{'GA_FS_gaba':{'weight':0.4},
#                'GF_FS_gaba':{'weight':0.6}}}
#     misc.dict_update(solution,{'mul':d})    
       

    # Long time constant from TA    
    d={'nest':{'M1_low':{'GABAA_3_Tau_decay':87.},  
               'M2_low':{'GABAA_3_Tau_decay':76.},
               'FS_low':{'GABAA_2_Tau_decay':66.},     
               }}
    misc.dict_update(solution,{'equal':d})           

    # Dopamine effect on TA and TI to striatum
    d={'nest':{
               'M1_low':{'beta_I_GABAA_3': f_beta_rm(2.6),
                         'beta_I_GABAA_2': f_beta_rm(0.25)},
               'M2_low':{'beta_I_GABAA_3': f_beta_rm(2.5),
                         'beta_I_GABAA_2': f_beta_rm(0.25)},
               'FS_low':{'beta_I_GABAA_2': f_beta_rm(1.6)},
              },
        'conn':{'M1_M1_gaba':{'beta_fan_in': f_beta_rm(0.25)},
                'M1_M2_gaba':{'beta_fan_in': f_beta_rm(0.25)},
                'M2_M1_gaba':{'beta_fan_in': f_beta_rm(0.25)},
                'M2_M2_gaba':{'beta_fan_in': f_beta_rm(0.25)}
               }}    
    misc.dict_update(solution,{'equal':d})
    
    
    # Weight TA M1/M2 1/2 
   # d={'nest':{
   #             'GA_M1_gaba':{'weight':0.01},
   #             'GA_M2_gaba':{'weight':0.01*2},
   #            }}

    misc.dict_update(solution,{'equal':d})

    #Dopamine such that STN increase above 50-100 %    
    x=2.5
    d={'nest':{'ST':{'beta_I_AMPA_1': f_beta_rm(x),
                     'beta_I_NMDA_1': f_beta_rm(x)}}}
    misc.dict_update(solution,{'equal':d})            

    # Delay ctx striatum and ctx stn set to 2.5 ms Jaeger 2011
    y=2.5
    misc.dict_update(solution,{'equal':{'nest':{'C1_M1_ampa':{'delay':y}}}})
    misc.dict_update(solution,{'equal':{'nest':{'C1_M1_nmda':{'delay':y}}}})            
    misc.dict_update(solution,{'equal':{'nest':{'C2_M2_ampa':{'delay':y}}}})
    misc.dict_update(solution,{'equal':{'nest':{'C2_M2_nmda':{'delay':y}}}})            
    misc.dict_update(solution,{'equal':{'nest':{'CF_FS_ampa':{'delay':y}}}})     
    

    # Set delay GP->STN 1 ms and STN->GP 2 ms as Jaeger 2011. Might need say something
    # that this is not rat data. With this the coherence in STN goes up. Total delay from cortex
    # to STN via striatum is 2.5+7+1 = 10.5.
    d={'nest':{'GI_ST_gaba':{'delay':1.},
               'GF_ST_gaba':{'delay':1.},
               
               'ST_GI_ampa':{'delay':2.},
               'ST_GF_ampa':{'delay':2.},
               'ST_GA_ampa':{'delay':2.} }
       }
                 
    misc.dict_update(solution,{'equal':d})
    
    # Dopamine effect on MS-GI
    d={'equal':{'nest':{
                        'GI':{'beta_I_GABAA_1': f_beta_rm(2)},
                        'GF':{'beta_I_GABAA_1': f_beta_rm(2)},
                        }}}
    misc.dict_update(solution,d)
    

    # Activate GF to FS connection
    d={ 'conn':{'GF_FS_gaba':{'lesion':False}}}

    misc.dict_update(solution,{'equal':d})

    # GI predominently connect to to GA 
#     d={'equal':{'conn': {
#                         'GA_GA_gaba':{'fan_in0': 5}, 
#                         'GI_GA_gaba':{'fan_in0': round(25*0.9) },
#                         'GF_GA_gaba':{'fan_in0': 25-round(25*0.9) },
#                         }}]
    
    misc.dict_update(solution,d) 
    
    return solution
def plot(file_name, figs, setup, flag, **k):
    nets = ['Net_0', 'Net_1']

    attr = ['firing_rate', 'mean_rates', 'spike_statistic']

    attr2 = ['psd', 'activity_histogram', 'activity_histogram_stat']

    attr_coher = ['phase_diff', 'phases_diff_with_cohere', 'mean_coherence']

    models = ['M1', 'M2', 'FS', 'GI', 'GA', 'ST', 'SN', 'GP']
    models_coher = [
        'GI_GA',
        'GI_GI',
        'GA_GA',
        'GA_ST',
        'GI_ST',
        'GP_GP',
        'ST_ST',
        'GP_ST',
    ]

    # Adding nets no file name
    sd_list = get_storage_list(nets, file_name, '')

    d = {}

    for sd, net in zip(sd_list, nets):

        filt = ([net] + models + models_coher + attr + attr2 + attr_coher)
        dd = load(sd, *filt)

        #             cmp_statistical_test(models, dd)
        d = misc.dict_update(d, dd)

    kw = setup.plot_summed2()
    kw['alphas'] = [1., 1.]
    kw['coherence_xcut'] = [0, 50]
    kw['coherence_color'] = ['grey', 'k']
    kw['coherence_p_conf95_linestyle'] = '--'
    kw['hatchs_ti_ti'] = ['', '']
    kw['label_model'] = 'Black=Model'
    kw['label_exp'] = 'White=Exp., Mallet et al 2008'
    kw['linewidth'] = 1.
    kw['set_text_on_bars'] = False
    kw['top_label'] = False
    kw['phases_diff_with_cohere_colors'] = ['grey', 'k']
    kw['phases_diff_with_cohere_xcut'] = [-numpy.pi * 0.97, numpy.pi**0.97]
    kw['phases_diff_with_cohere_remove_peaks'] = True
    kw['scale'] = 1
    kw['spk_stats_color_axis'] = 1
    kw['spk_stats_colors'] = ['k', 'w']
    kw['spk_stats_colors_ti_ta'] = ['k', 'w']
    kw['xlim_cohere'] = [-1, 51]

    kw.update(k)
    figs.append(base_oscillation.show_summed2(d, **kw))

    kw = setup.plot_summed_STN()
    kw['alphas'] = [1., 1.]
    kw['coherence_color'] = ['grey', 'k']
    kw['coherence_p_conf95_linestyle'] = '--'
    kw['hatchs_ti_ti'] = ['', '']
    kw['label_model'] = 'Black=Model'
    kw['label_exp'] = 'White=Exp., Mallet et al 2008'
    kw['linewidth'] = 1.
    kw['phases_diff_with_cohere_xcut'] = [-numpy.pi * 0.97, numpy.pi**0.97]
    kw['phases_diff_with_cohere_remove_peaks'] = True
    kw['phases_diff_with_cohere_colors'] = ['grey', 'k']
    kw['scale'] = 1
    kw['set_text_on_bars'] = False
    kw['spk_stats_colors'] = ['k', 'w']
    kw['spk_stats_colors_ti_ta'] = ['k', 'w']
    kw['spk_stats_color_axis'] = 1
    kw['top_label'] = False
    kw['xlim_cohere'] = [-1, 51]
    if flag == 'slow_wave':
        kw['ylim_cohere'] = [0, 1.0]
    elif flag == 'beta':
        kw['ylim_cohere'] = [0, 0.4]

    kw['coherence_xcut'] = [0, 50]
    kw.update(k)
    figs.append(base_oscillation.show_summed_STN(d, **kw))

    return figs
示例#41
0
    nets=['Net_{0:0>2}'.format(i) for i in range(len(kw_list))]
    sd_list=get_storage_list(nets, path, '')
    
    d={}
    for net, sd, kw in zip(nets, sd_list, kw_list):
    
        if from_disk==0:# and net=='Net_05':
            print net
            dd={}
            for call in [
                        simulate_IV, 
                        simulate_IF,
                            get_nullcline,
                           simulate_rebound_spike,
                         ]:
                misc.dict_update(dd,{net:call(**kw)})

            save(sd, dd)
        
#         if from_disk==1:
#             filt= [net]+['gi','st', 'gi_st']+['spike_signal']
#             dd = load(sd, *filt)
#             pp(dd)
#             dd=compute_attrs(dd, net)
#             save(sd, dd)
            
        elif from_disk==1:
            filt = [net]+['IV', 'IF', 'nullcline'] +['rs_scatter']
            dd = load(sd, *filt)
        
        d = misc.dict_update(d, dd)
示例#42
0
 def sim_group(self, **kwargs):
     kwargs = misc.dict_update(self.kwargs, kwargs)
     return sim_group(self.sim_time, *self.args, **self.kwargs)
示例#43
0
def get():

    l = []
    solution = {'equal': {}, 'mul': {}}  #get_solution_final_beta()

    d = {}
    misc.dict_update(d, solution['mul'])
    l += [pl(d, '*', **{'name': ''})]

    d = {}
    misc.dict_update(d, solution['equal'])
    l[-1] += pl(d, '=', **{'name': 'control_sim'})

    # Decreasing delay TA-striatum increases oscillations in MSN and FSN
    for y in [12] + list(numpy.arange(5, 105, 10)):

        d = {}
        misc.dict_update(d, solution['mul'])
        l += [pl(d, '*', **{'name': ''})]

        d = {}
        misc.dict_update(d, solution['equal'])

        ratio = 100. / y

        dd = {
            'nest': {
                'GA_M1_gaba': {
                    'weight': 0.4 * ratio
                },
                'GA_M2_gaba': {
                    'weight': 0.8 * ratio
                }
            }
        }
        misc.dict_update(d, dd)

        # Decreasing from 2 leads to ...
        # Increasing from 2 leads to ...
        dd = {
            'nest': {
                'GA_FS_gaba': {
                    'weight': 2. / 0.29 * (17. / 66.) * ratio
                }
            }
        }
        misc.dict_update(d, dd)

        # Just assumed to be 12 ms
        dd = {
            'nest': {
                'M1_low': {
                    'GABAA_3_Tau_decay': 87. / ratio
                },
                'M2_low': {
                    'GABAA_3_Tau_decay': 76. / ratio
                },
                'FS_low': {
                    'GABAA_2_Tau_decay': 66. / ratio
                },
            }
        }

        misc.dict_update(d, dd)

        l[-1] += pl(d, '=', **{'name': 'mod_GAtau_' + str(y)})

    # Phase synch in GP and ST effected by delay from cortex
    for y in numpy.arange(2.5, 21., 2.5):

        d = {}
        misc.dict_update(d, solution['mul'])

        l += [pl(d, '*', **{'name': ''})]

        d = {}
        misc.dict_update(d, solution['equal'])
        misc.dict_update(d, {'nest': {'CS_ST_ampa': {'delay': y}}})
        misc.dict_update(d, {'nest': {'CS_ST_nmda': {'delay': y}}})

        l[-1] += pl(d, '=', **{'name': 'CSSTdelay_' + str(y)})

    # Effect on phase TI-TA when having MSN connect to TA
    for y, EA_rate in zip(numpy.arange(25, 130, 25),
                          numpy.arange(1, 1.8, 0.15)):
        d = {}
        misc.dict_update(d, solution['mul'])
        misc.dict_update(d, {'node': {'EA': {'rate': EA_rate}}})

        l += [pl(d, '*', **{'name': ''})]

        d = {}
        misc.dict_update(d, solution['equal'])

        misc.dict_update(d, {'conn': {'M2_GA_gaba': {'lesion': False}}})
        misc.dict_update(d, {'conn': {'M2_GA_gaba': {'fan_in0': y}}})

        l[-1] += pl(d, '=',
                    **{'name': 'M2GA_' + str(y) + '_EArate_' + str(EA_rate)})

    # Effect of TI  back to str
    for y in numpy.arange(1, 6, 1):

        d = {}
        misc.dict_update(d, solution['mul'])
        l += [pl(d, '*', **{'name': ''})]

        d = {}
        misc.dict_update(d, solution['equal'])

        misc.dict_update(d, {'conn': {'GI_FS_gaba': {'lesion': False}}})
        misc.dict_update(d, {'conn': {'GI_FS_gaba': {'fan_in0': y}}})
        misc.dict_update(d, {'conn': {'GI_M1_gaba': {'lesion': False}}})
        misc.dict_update(d, {'conn': {'GI_M1_gaba': {'fan_in0': y}}})
        misc.dict_update(d, {'conn': {'GI_M2_gaba': {'lesion': False}}})
        misc.dict_update(d, {'conn': {'GI_M2_gaba': {'fan_in0': y}}})

        l[-1] += pl(d, '=', **{'name': 'mod_GI_M2_' + str(y)})

    # Connectivity GPe-STN
    v = STN_ampa_gaba_input_magnitude()
    for _, x, y in v:

        d = {}
        misc.dict_update(d, solution['mul'])
        l += [pl(d, '*', **{'name': ''})]

        d = {}
        misc.dict_update(d, solution['equal'])

        misc.dict_update(d, {'node': {'CS': {'rate': x}}})
        misc.dict_update(d, {'nest': {'GI_ST_gaba': {'weight': y}}})

        l[-1] += pl(d, '=', **{'name': 'mod_ST_inp_' + str(x) + '_' + str(y)})

    # Effect of connectiviity onto TA from TI and TA
    for y in numpy.arange(5., 29., 5.):

        d = {}
        misc.dict_update(d, solution['mul'])
        l += [pl(d, '*', **{'name': ''})]

        d = {}
        misc.dict_update(d, solution['equal'])

        dd = {
            'conn': {
                'GA_GA_gaba': {
                    'fan_in0': y,
                    'rule': 'all-all'
                },
                'GF_GA_gaba': {
                    'fan_in0': int((30 - y) * 0.1),
                    'rule': 'all-all'
                },
                'GI_GA_gaba': {
                    'fan_in0': (30 - y) - int((30 - y) * 0.1),
                    'rule': 'all-all'
                },
            }
        }

        misc.dict_update(d, dd)

        l[-1] += pl(d, '=',
                    **{'name': 'GAGA_' + str(y) + '_GIGA_' + str(30 - y)})

    # Effect of MSN-MSN strength
    for y in [0.125, 0.25, 0.5, 1, 2, 4, 8]:

        d = {}
        misc.dict_update(d, solution['mul'])
        l += [pl(d, '*', **{'name': ''})]

        d = {}
        misc.dict_update(d, solution['equal'])

        dd = {
            'nest': {
                'M1_M1_gaba': {
                    'weight': y
                },
                'M1_M2_gaba': {
                    'weight': y
                },
                'M2_M1_gaba': {
                    'weight': y
                },
                'M2_M2_gaba': {
                    'weight': y
                }
            }
        }

        misc.dict_update(d, dd)
        l[-1] += pl(d, '=', **{'name': 'MSMS_' + str(y)})

    # Phase synch in GP and ST effected by delay from cortex to STR
    for y in numpy.arange(20., 1.5, -2.5):

        d = {}
        misc.dict_update(d, solution['mul'])
        l += [pl(d, '*', **{'name': ''})]

        d = {}
        misc.dict_update(d, solution['equal'])
        dd = {
            'nest': {
                'C1_M1_ampa': {
                    'delay': y
                },
                'C1_M1_nmda': {
                    'delay': y
                },
                'C2_M2_ampa': {
                    'delay': y
                },
                'C2_M2_nmda': {
                    'delay': y
                },
                'CF_FS_ampa': {
                    'delay': y
                },
                'CF_FS_nmda': {
                    'delay': y
                }
            }
        }

        misc.dict_update(d, dd)
        l[-1] += pl(d, '=', **{'name': 'CXSTRdelay_' + str(y)})

    # Delay STGP and GPST delay
    for y, z in zip(*[numpy.arange(1., 9.)] * 2):

        d = {}
        misc.dict_update(d, solution['mul'])
        l += [pl(d, '*', **{'name': ''})]

        d = {}
        misc.dict_update(d, solution['equal'])

        dd = {
            'nest': {
                'ST_GA_ampa': {
                    'delay': y
                },
                'ST_GI_ampa': {
                    'delay': y
                },
                'GI_ST_gaba': {
                    'delay': z
                }
            }
        }
        misc.dict_update(d, dd)
        l[-1] += pl(d, '=',
                    **{'name': 'STGPdelay_' + str(y) + '_GPSTdelay_' + str(z)})

    return l

    # Strength STN-GP
    r = numpy.array([0., 200., 400., 600., 800., 1000.0]) + 200.
    w = numpy.array([304., 0.259, 0.225, 0.18, 0.134, 0.09]) + 0.46
    for y, z in zip(*[r, w]):

        d = {}
        misc.dict_update(d, solution['mul'])
        l += [pl(d, '*', **{'name': ''})]

        d = {}
        misc.dict_update(d, solution['equal'])

        dd = {
            'nest': {
                'ST_GA_ampa': {
                    'weight': z
                }
            },
            'node': {
                'GA': {
                    'rate': y
                }
            }
        }
        misc.dict_update(d, dd)
        l[-1] += pl(d, '=', **{'name': 'GAr_' + str(y) + '_STGAw_' + str(z)})

    return l
示例#44
0
 def sim_group(self, **kwargs):
     kwargs=misc.dict_update(self.kwargs, kwargs)
     return sim_group(self.sim_time, *self.args, **self.kwargs)  
def get(flag='perturbations'):

    l = []
    ld = []
    solution = get_solution_eNeuro_rev()
    #
    #     for s in solution:
    #         print s

    #     pp(solution)

    fEA = 3.
    fEI = 0.9  #*1.6 working solution
    fCF = .85

    rEI = 1700.0 * fEI - 100.
    rEA = 200.0 + 100.  #*fEA
    rCS = 250.0
    rES = 2000.0
    rM2 = 740.0
    rCF = 950.0 * fCF

    d = {}
    ld.append({'mul': d})
    misc.dict_update(d, solution['mul'])
    l += [pl(d, '*', **{'name': ''})]

    d = {}
    ld[-1].update({'equal': d})
    misc.dict_update(d, solution['equal'])
    d['node']['EF']['rate'] = rEI
    d['node']['EI']['rate'] = rEI
    d['node']['EA']['rate'] = rEA
    d['node']['C2']['rate'] = rM2
    d['node']['CF']['rate'] = rCF

    misc.dict_update(d, {'node': {'CS': {'rate': rCS}}})
    misc.dict_update(d, {'node': {'ES': {'rate': rES}}})
    s = 'rEI_{0}_rEA_{1}_rCS_{2}_rES_{3}_rM2_{4}'.format(
        rEI, rEA, rCS, rES, rM2)

    l[-1] += pl(d, '=', **{'name': s})

    rEI = 800.0 * fEI - 100.
    rEA = 100.0 + 100.  #*fEA
    rCS = 170.0
    rES = 2000.0
    rM2 = 740.0
    rCF = 950.0 * fCF

    d = {}
    misc.dict_update(d, solution['mul'])
    l += [pl(d, '*', **{'name': ''})]
    ld.append({'mul': d})

    d = {}
    misc.dict_update(d, solution['equal'])
    d['node']['EF']['rate'] = rEI
    d['node']['EI']['rate'] = rEI
    d['node']['EA']['rate'] = rEA
    d['node']['C2']['rate'] = rM2
    d['node']['CF']['rate'] = rCF

    misc.dict_update(d, {'node': {'CS': {'rate': rCS}}})
    misc.dict_update(d, {'node': {'ES': {'rate': rES}}})
    s = 'rEI_{0}_rEA_{1}_rCS_{2}_rES_{3}_rM2_{4}'.format(
        rEI, rEA, rCS, rES, rM2)
    l[-1] += pl(d, '=', **{'name': s})
    ld[-1].update({'equal': d})

    if flag == 'perturbations': return l
    if flag == 'dictionary': return ld
示例#46
0
paths=[]
paths.append('/home/mikael/results/papers/inhibition/network/'
             +'milner/simulate_beta_new_beginning_slow4/')
paths.append('/home/mikael/results/papers/inhibition/network/'
             +'milner/simulate_slow_wave_new_beginning_slow4/')

script_name=(__file__.split('/')[-1][0:-3]+'/data')
file_name = get_file_name(script_name)

sd = Storage_dic.load(file_name, **{'force_update':False})

if from_disk==0:
    d={}
    for path, create_name in zip(paths, [ create_name_beta,create_name_sw]):
        d_tmp=effect_conns.gather(path, nets, models, attrs, **{'name_maker':create_name})
        misc.dict_update(d, d_tmp)
    
    save(sd, d)
    pp(d)
elif from_disk==1:
    d = sd.load_dic(*(nets+models+['spike_statistic']),
                    **{'star':[0]})
    pp(d)
    pp(sorted(d.keys()))
    
    dd=postprocess(d)
    misc.dict_update(d, dd)
    save(sd, d)
    
elif from_disk==2:
    keys_iterator=[]
def get_change_to(flag, E_rev='low'):
    x=0.
    #1 *
    if flag=='M1':
        if E_rev=='low':
            d={'nest':{'M1_low':{'beta_d':x,
                                 'beta_E_L':x,
                                 'beta_V_b':x,
                             }}}
    #2 *
    if flag=='CTX_M1':
        if E_rev=='low':
            d={'nest':{'M1_low':{
                             'beta_I_NMDA_1':x,
                                }}}
    #3 *
    if flag=='CTX_M2':
        if E_rev=='low':
            d={'nest':{'M2_low':{'beta_I_AMPA_1':x,
                         }}}    

    #4 *
    if flag=='FS_FS':
        if E_rev=='low':
            d={'nest':{'FS_low':{'beta_I_GABAA_1':x,
                                }},
               }

    #5 * //not used (shoudl also be GA not GP
    if flag=='GP_FS':
        if E_rev=='low':
            d={'nest':{'FS_low':{'beta_I_GABAA_2':x,
                                 }},
                }

    #6 * 
    if flag=='FS_M2':
        if E_rev=='low':
            d={
               'conn':{'FS_M2_gaba':{'beta_fan_in':x}}}
    
    #7 *
    if flag=='CTX_ST':
        d={'nest':{'ST':{'beta_I_AMPA_1':x,
                         'beta_I_NMDA_1':x,
                         }}}
    
    #8 *
    if flag=='GP_ST':
        d={'nest':{'ST':{'beta_I_GABAA_1':x,
                         }}}

    #9 *
    if flag=='GP':
        d={'nest':{'GI':{'beta_E_L':x,
                         'beta_V_a':x},
                   'GF':{'beta_E_L':x,
                         'beta_V_a':x},
                   'GA':{'beta_E_L':x,
                         'beta_V_a':x},
           }}
    
    #10 *
    if flag=='ST_GP':
            d={'nest':{'GI':{'beta_I_AMPA_1':x},
                       'GF':{'beta_I_AMPA_1':x},
                       'GA':{'beta_I_AMPA_1':x}
                       }}
    
    #11 *
    if flag=='GP_GP':
        d={'nest':{'GI':{'beta_I_GABAA_2':x},
                   'GF':{'beta_I_GABAA_2':x},
                   'GA':{'beta_I_GABAA_2':x}
                   }}

    #12 *
    if flag=='SN':
        d={'nest':{'SN':{'beta_E_L':x,
                         'beta_V_a':x,
                         }}}
    
    #13 *
    if flag=='M1_SN':
        d={'nest':{'SN':{'beta_I_GABAA_1':x,
                         }}}
        
    #14 *
    if flag=='MS_MS':
        if E_rev=='low':
            d={'nest':{'M1_low':{'beta_I_GABAA_2':x},
                       'M2_low':{'beta_I_GABAA_2':x}}}
        
        for conn in ['M1_M1_gaba', 'M1_M2_gaba','M2_M1_gaba','M2_M2_gaba']:
            misc.dict_update(d,{'conn':{conn:{'beta_fan_in': x}}})         
    
    #15 *
    if flag=='M2_GI':
        d={'nest':{'GI':{'beta_I_GABAA_1':x,
                         }}}



    #16 *
    if flag=='FS':
        d={'nest':{'FS_low':{'beta_E_L':x,
                         }}}
        

    #17 *
    if flag=='GA_MS':
        d={'nest':{'M1_low':{'beta_I_GABAA_3':x},
                   'M2_low':{'beta_I_GABAA_3':x}}}


    #18 *
    if flag=='GA_FS':
        d={'nest':{'FS_low':{'beta_I_GABAA_2':x}}}


    #19 *
    if flag=='GI_FS':
        d={'nest':{'FS_low':{'beta_I_GABAA_3':x}}}    
        
    return d
示例#48
0
def get_solution():


    solution={'mul':{},
              'equal':{}}
    
    #Decreasing from 0.25 leads to ...
    #Increasing from 0.25 leads to ...
    d={'nest':{'M1_M1_gaba':{'weight':0.25},
               'M1_M2_gaba':{'weight':0.25},
               'M2_M1_gaba':{'weight':0.25},
               'M2_M2_gaba':{'weight':0.25}}}
    misc.dict_update(solution,{'mul':d})    
    
    # GA firing rate needs to be maintained, around 12 Hz for sw in 
    # dopamine depleted rats). When decreasing/increasing
    # ST-GA one need to either compensate by changing inhibition from 
    # GPe and/or EA external input (assume that synapses from TA and TI
    # are of equal strength. 
    
    # This script is first run where ST-GA GP-GA and EA individually are
    # perturbed to determine each relative influence to TA firing rate. 
    # From this data then combinations fo changes that should results in
    # 12 Hz TA firing rate are created.  
    d={'nest':{'ST_GA_ampa':{'weight':0.25},
               'GA_GA_gaba':{'weight':0.25},
               'GI_GA_gaba':{'weight':0.25},
               'GF_GA_gaba':{'weight':0.25},
               }}
    misc.dict_update(solution, {'mul':d})    
    
    d={'node':{'EA':{'rate':200.0}}}
    misc.dict_update(solution,{'equal':d})              
    
    # C1 and C2 have been set such that MSN D1 and MSN D2 fires at 
    # low firing rates (0.1-0,2 Hz). 
    d={'node':{'C1':{'rate':560.0},
               'C2':{'rate':700.}}}
    misc.dict_update(solution,{'equal':d})              
           
    # Set such that GPe TI fires in accordance with slow wave sleep
    # in dopamine depleted rats.
    d={'node':{
               'EI':{'rate':1400.0}, # Increase with 340, to get close to 24 Hz sw dopamine depleted rats TI
               'EF':{'rate':1400.0}, # Increase with 340, to get close to 24 Hz sw dopamine depleted rats TI
               }}
    misc.dict_update(solution,{'equal':d})           
    
    # Decrease weight since tau decay is 5 times stronger
    d={'nest':{'GA_M1_gaba':{'weight':0.8/5}, 
               'GA_M2_gaba':{'weight':0.8/5}}}
    misc.dict_update(solution,{'equal':d})            
     
    # Decrease weight since tau decay is 5 times stronger
    d={'nest':{'GA_FS_gaba':{'weight':2./5}}}
    misc.dict_update(solution,{'equal':d})           
    
    # Just assumed to be 12*5 ms    
    d={'nest':{'M1_low':{'GABAA_3_Tau_decay':12.*5},  
               'M2_low':{'GABAA_3_Tau_decay':12.*5},
               'FS_low':{'GABAA_2_Tau_decay':12.*5},     
               }}
    misc.dict_update(solution,{'equal':d})           

    #Dopamine such that STN increase above 50-100 %    
    x=2.5
    d={'nest':{'ST':{'beta_I_AMPA_1': f_beta_rm(x),
                     'beta_I_NMDA_1': f_beta_rm(x)}}}
    misc.dict_update(solution,{'equal':d})            

    # Delay ctx striatum and ctx stn set to 2.5 ms Jaeger 2011
    y=2.5
    misc.dict_update(solution,{'equal':{'nest':{'C1_M1_ampa':{'delay':y}}}})
    misc.dict_update(solution,{'equal':{'nest':{'C1_M1_nmda':{'delay':y}}}})            
    misc.dict_update(solution,{'equal':{'nest':{'C2_M2_ampa':{'delay':y}}}})
    misc.dict_update(solution,{'equal':{'nest':{'C2_M2_nmda':{'delay':y}}}})            
    misc.dict_update(solution,{'equal':{'nest':{'CF_FS_ampa':{'delay':y}}}})     
    
    
    # Dopamine effect on MS-GI
    d={'equal':{'nest':{
                        'GI':{'beta_I_GABAA_1': f_beta_rm(2)},
                        'GF':{'beta_I_GABAA_1': f_beta_rm(2)},
                        }}}
    misc.dict_update(solution,d)
    
    # GI predominently connect to to GA 
#     d={'equal':{'conn': {
#                         'GA_GA_gaba':{'fan_in0': 5}, 
#                         'GI_GA_gaba':{'fan_in0': round(25*0.9) },
#                         'GF_GA_gaba':{'fan_in0': 25-round(25*0.9) },
#                         }}]
    
    misc.dict_update(solution,d) 
    
    return solution
            dd={net:simulate_network(**kw)}
            dd=compute_attrs(dd, net)
            save(sd, dd)
        
        if from_disk==1:
            filt= [net]+['gi','st', 'gi_st']+['spike_signal']
            dd = load(sd, *filt)
            pp(dd)
            dd=compute_attrs(dd, net)
            save(sd, dd)
            
        elif from_disk==2:
            filt = [net]+['gi','st', 'gi_st']+['firing_rate', 'phases_diff_with_cohere'] 
            dd = load(sd, *filt)
        
        d = misc.dict_update(d, dd)
    
    pp(d)
    fig, axs=get_fig_axs()
    
    
    for i in range(len(nets)):
        d['Net_0{0}'.format(i)]['gi']['firing_rate'].plot(axs[i], **{'win':1.})
        d['Net_0{0}'.format(i)]['st']['firing_rate'].plot(axs[i], **{'win':1.})
        axs[i].set_xlim(0.0,1500.0)
 
    colors=misc.make_N_colors('copper', len(kw_list))
    
    
#     for net, c in zip(nets, colors):
#         kw={ 'all':True,
示例#50
0
def get():
    
    
    l=[]
    solution=get_solution()

    d={}
    misc.dict_update(d, solution['mul'])
    l+=[pl(d, '*', **{'name':''})]
      
    d={}
    misc.dict_update(d, solution['equal']) 
    l[-1]+=pl(d, '=', **{'name':'control_sim'}) 
        
    # Connectivity GPe-STN
    v=STN_ampa_gaba_input_magnitude()    
    agg=[]
    for _,a,b in v:
        agg+=[[a,b] for _ in range(1)]

    STN_beta_I=[]
    for f in [1.]:
        STN_beta_I.append(reversed(list(numpy.linspace(f*1.8, f*2.5, len(v)))))
    STN_beta_I=zip(*STN_beta_I)
    STN_beta_I=reduce(lambda x,y:x+y, STN_beta_I)
    
    for i in range(len(agg)):
        agg[i].append(STN_beta_I[i])

# 
#     M2_rate=[[1.0, 1.1, 1.2] for _ in range(len(agg))]
#     M2_rate=reduce(lambda x,y:x+y, M2_rate)
#     agg=[[e[:] for e in agg] for _ in range(3)]
#     agg=zip(*agg)
#     agg=reduce(lambda x,y:x[:]+y[:], agg)
#  
#     for i in range(len(agg)):
#         agg[i].append(M2_rate[i])

#     ST_GA_ampa_w=[[0.75,1.] for _ in range(len(agg))]
#     ST_GA_ampa_w=reduce(lambda x,y:x+y, ST_GA_ampa_w)
#     agg=[[e[:] for e in agg] for _ in range(2)]
#     agg=zip(*agg)
#     agg=reduce(lambda x,y:x[:]+y[:], agg)
# 
#     for i in range(len(agg)):
#         agg[i].append(ST_GA_ampa_w[i])

    
    EA_rate=[[200.,400., 600.] for _ in range(len(agg))]
    EA_rate=reduce(lambda x,y:x+y, EA_rate)
    agg=[[e[:] for e in agg] for _ in range(3)]
    agg=zip(*agg)
    agg=reduce(lambda x,y:x+y, agg)

    for i in range(len(agg)):
        agg[i].append(EA_rate[i])
    
        
    for a0, a1, a2, a4 in agg:

        d={}
        misc.dict_update(d, solution['mul'])   
        
 
#         dd={'node':{'M1':{'rate':a3}}}
#         dd={'nest':{'ST_GA_ampa':{'weight':a3*0.25}}}
#         misc.dict_update(d,dd) 
        l+=[pl(d, '*', **{'name':''})]
        
        d={}
        misc.dict_update(d, solution['equal'])  
        
        dd={'node':{'CS':{'rate': float(a0)},
                   'EA':{'rate':a4}},
           'nest':{'GI_ST_gaba':{'weight':a1 },
                   'ST':{'beta_I_AMPA_1': f_beta_rm(a2),
                         'beta_I_NMDA_1': f_beta_rm(a2)}}}
        
        misc.dict_update(d,dd)
        
        s='CS_{0}_GPST_{1}_STbI_{2}_EAr_{3}'.format(a0,str(a1)[0:4],str(a2)[0:4], int(a4))
        print s
        l[-1]+=pl(d, '=', **{'name':s})   
               
    return l
示例#51
0
def pert_add_oscillations(**kwargs):

    amp_base = kwargs.get('amp_base')  # Scaling of base frequency
    amp_base_skip = kwargs.get(
        'amp_base_skip',
        [])  #skip amplitude modulation for nuclies in this list
    do_reset = kwargs.get(
        'do_reset',
        True)  #reset simulations between runs in engine.py with nest.reset
    down_vec = kwargs.get('down_vec')  #?
    freqs = kwargs.get('freqs')  # Frequency amplitude modulation
    freq_oscillation = kwargs.get('freq_oscillation')
    external_input_mod = kwargs.get('external_input_mod', [])
    input_mod = kwargs.get('input_mod', ['C1', 'C2', 'CF', 'CS'])
    no_mod = kwargs.get('no_mod', [])
    local_num_threads = kwargs.get('local_num_threads')
    null_down = kwargs.get('null_down', False)
    null_down_STN = kwargs.get('null_down_stn', False)
    path_rate_runs = kwargs.get('path_rate_runs')
    perturbation_list = kwargs.get('perturbation_list')
    sim_time = kwargs.get('sim_time')
    size = kwargs.get('size')
    STN_amp_mod = kwargs.get('STN_amp_mod', [1.])
    tuning_freq_amp_to = kwargs.get('tuning_freq_amp_to', 'M1')

    l = perturbation_list
    for i in range(len(l)):
        l[i] += pl(
            {
                'simu': {
                    'do_reset': do_reset,
                    'sd_params': {
                        'to_file': True,
                        'to_memory': False
                    },
                    'sim_time': sim_time,
                    'sim_stop': sim_time,
                    'local_num_threads': local_num_threads
                },
                'netw': {
                    'size': size
                }
            }, '=')

    kw_process = {'freqs': freqs, 'tuning_freq_amp_to': tuning_freq_amp_to}
    damp = process(path_rate_runs, **kw_process)
    for key in sorted(damp.keys()):
        val = damp[key]
        print key, numpy.round(val, 2)

    ll = []

    for j, i, STN_amp, _l in iterator_oscillations(freqs, STN_amp_mod, l):
        amp = [numpy.round(damp[_l.name][j], 2), amp_base[j]]

        _l = deepcopy(_l)
        dd = {}
        for key in input_mod:

            if key in ['C1', 'C2', 'CF']:
                factor = 1
            elif key in ['CS']:
                factor = STN_amp

            if null_down:
                down = -1.
            elif null_down_STN and key in ['CS']:
                down = -1
            elif down_vec:
                down = down_vec[j]
            else:
                down = -amp[0] * factor

            if key not in amp_base_skip:
                amp0 = amp[1]
            else:
                amp0 = 1.

            if amp0 > 1.0:
                pass

            upp = amp[0]

            #             print amp, amp0

            if (key in no_mod): upp, down = 0., 0.

            d = {
                'type': 'oscillation2',
                'params': {
                    'p_amplitude_upp': upp * factor,
                    'p_amplitude_down': down,
                    'p_amplitude0': amp0,
                    'freq': freq_oscillation
                }
            }

            dd = misc.dict_update(dd, {'netw': {'input': {key: d}}})

        if STN_amp != 1:
            _l += pl(
                dd, '=',
                **{'name': 'amp_{0}_{1}_stn_{2}'.format(upp, amp[1], STN_amp)})
        elif down_vec:
            _l += pl(dd, '=',
                     **{'name': 'amp_{0}_{1}_{2}'.format(upp, down, amp[1])})

        else:
            _l += pl(dd, '=', **{'name': 'amp_{0}_{1}'.format(*[upp, amp[1]])})

        if external_input_mod:

            dd = {}
            for key in external_input_mod:
                dd = misc.dict_update(dd, {'node': {key: {'rate': amp0}}})

            _l += pl(dd, '*', **{'name': 'EIEA_{0}'.format(amp0)})

        ll.append(_l)

    return ll
def get(flag='perturbations'):
    
    l=[]
    ld=[]
    solution=get_solution_eNeuro_rev()
#     
#     for s in solution:
#         print s

#     pp(solution)

    fEA=3.
    fEI=0.9 #*1.6 working solution 
    fCF=.85

    rEI=1700.0*fEI - 100.
    rEA=200.0 + 100. #*fEA
    rCS=250.0
    rES=2000.0
    rM2=740.0 
    rCF=950.0*fCF	
     
    d={}
    ld.append({'mul':d})
    misc.dict_update(d, solution['mul'])
    l+=[pl(d, '*', **{'name':''})]
      
    d={}
    ld[-1].update({'equal':d})
    misc.dict_update(d, solution['equal']) 
    d['node']['EF']['rate']=rEI 
    d['node']['EI']['rate']=rEI
    d['node']['EA']['rate']=rEA
    d['node']['C2']['rate']=rM2
    d['node']['CF']['rate']=rCF

    misc.dict_update(d, {'node':{'CS':{'rate':rCS}}})
    misc.dict_update(d, {'node':{'ES':{'rate':rES}}}) 
    s='rEI_{0}_rEA_{1}_rCS_{2}_rES_{3}_rM2_{4}'.format( rEI, rEA, rCS, rES, rM2 )
    
    l[-1]+=pl(d, '=', **{'name':s})   


    rEI=800.0*fEI - 100.
    rEA=100.0 + 100. #*fEA
    rCS=170.0
    rES=2000.0
    rM2=740.0
    rCF=950.0*fCF	
    
    d={}
    misc.dict_update(d, solution['mul'])
    l+=[pl(d, '*', **{'name':''})]
    ld.append({'mul':d})
      
      
    d={}
    misc.dict_update(d, solution['equal']) 
    d['node']['EF']['rate']=rEI 
    d['node']['EI']['rate']=rEI
    d['node']['EA']['rate']=rEA
    d['node']['C2']['rate']=rM2
    d['node']['CF']['rate']=rCF    
    
    misc.dict_update(d, {'node':{'CS':{'rate':rCS}}}) 
    misc.dict_update(d, {'node':{'ES':{'rate':rES}}}) 
    s='rEI_{0}_rEA_{1}_rCS_{2}_rES_{3}_rM2_{4}'.format( rEI, rEA, rCS, rES, rM2 )
    l[-1]+=pl(d, '=', **{'name':s})   
    ld[-1].update({'equal':d})
    



    if flag=='perturbations': return l
    if flag=='dictionary': return ld