Beispiel #1
0
def simulate_rate_first_and_second_bursts(
        selection_intervals=[0.0, 500.0, 1000., 1500.], load=True):
    global SNR_INJECTED_CURRENT
    global NEURON_MODELS
    global N_GPE
    global N_MSN_BURST
    global N_MSN
    global N_STN
    global MSN_BASE_RATE
    global GPE_BASE_RATE
    global STN_BASE_RATE
    global FILE_NAME
    global OUTPUT_PATH
    global SYNAPSE_MODELS_TESTED
    global SEL_ONSET

    #n_exp=20
    n_exp = 200
    msn_burst_rate = 20
    n_msn_burst = N_MSN_BURST

    transient_stop = selection_intervals[2] - selection_intervals[1]
    save_result_at = (OUTPUT_PATH + '/simulate_rate_first_and_second_bursts_' +
                      str(transient_stop) + 'ms.pkl')
    save_header_at = (OUTPUT_PATH + '/simulate_rate_first_and_second_bursts_' +
                      str(transient_stop) + 'ms_header')

    burst_time = 500.
    sim_time = SEL_ONSET + selection_intervals[3] + 500.

    EXPERIMENTS = range(n_exp)

    model_list = models()
    my_nest.ResetKernel(threads=1)
    my_nest.MyLoadModels(model_list, NEURON_MODELS)
    my_nest.MyLoadModels(model_list, SYNAPSE_MODELS_TESTED)
    my_nest.MyLoadModels(model_list, SYNAPSE_MODELS_BACKGROUND)
    if not load:
        MSN_list = []  # MSN input for each experiment
        for i_exp in EXPERIMENTS:
            MSN = MyPoissonInput(n=N_MSN + n_msn_burst, sd=True)
            MSN_list.append(MSN)

        GPE_list = []  # GPE input for each experiment
        for i_exp in EXPERIMENTS:
            GPE = MyPoissonInput(n=N_GPE, sd=True)
            GPE_list.append(GPE)

        STN_list = []  # GPE input for each experiment
        for i_exp in EXPERIMENTS:
            STN = MyPoissonInput(n=N_STN, sd=True)
            STN_list.append(STN)

        SNR_list = []  # SNR groups for each synapse and number of selected MSN
        SNR_list_experiments = []
        for i_syn, syn in enumerate(SYNAPSE_MODELS_TESTED):
            SNR = []
            for i_sel in range(1):

                I_e = my_nest.GetDefaults(
                    NEURON_MODELS[0])['I_e'] + SNR_INJECTED_CURRENT
                SNR.append(
                    MyGroup(NEURON_MODELS[0],
                            n=n_exp,
                            sd=True,
                            params={'I_e': I_e}))

            SNR_list.append(SNR)

        for i_exp in EXPERIMENTS:
            MSN = MSN_list[i_exp]
            GPE = GPE_list[i_exp]
            STN = STN_list[i_exp]

            # Set spike times
            # Base rate
            for id in MSN[1:N_MSN]:
                MSN.set_spike_times(id=id,
                                    rates=[MSN_BASE_RATE],
                                    times=[1],
                                    t_stop=sim_time,
                                    seed=int(numpy.random.random() * 10000.0))

            # Selection
            for id in MSN[N_MSN:N_MSN + n_msn_burst]:
                rates = [
                    MSN_BASE_RATE, msn_burst_rate, MSN_BASE_RATE,
                    msn_burst_rate, MSN_BASE_RATE
                ]

                t1 = selection_intervals[0]
                t2 = selection_intervals[1]
                t3 = selection_intervals[2]
                t4 = selection_intervals[3]
                times = [
                    1, SEL_ONSET + t1, SEL_ONSET + t2, SEL_ONSET + t3,
                    SEL_ONSET + t4
                ]
                t_stop = sim_time
                MSN.set_spike_times(id=id,
                                    rates=rates,
                                    times=times,
                                    t_stop=t_stop,
                                    seed=int(numpy.random.random() * 10000.0))

            # Base rate GPE
            for id in GPE[:]:
                GPE.set_spike_times(id=id,
                                    rates=[GPE_BASE_RATE],
                                    times=[1],
                                    t_stop=sim_time,
                                    seed=int(numpy.random.random() * 10000.0))

            # Base rate GPE
            for id in STN[:]:
                STN.set_spike_times(id=id,
                                    rates=[STN_BASE_RATE],
                                    times=[1],
                                    t_stop=sim_time,
                                    seed=int(numpy.random.random() * 10000.0))

            # Connect
            for i_syn, syn in enumerate(SYNAPSE_MODELS_TESTED):
                # i_sel goes over 0,..., n_max_sel
                for i_sel, n_sel in enumerate(
                        range(n_msn_burst, n_msn_burst + 1)):
                    target = SNR_list[i_syn][i_sel][i_exp]

                    my_nest.ConvergentConnect(MSN[0:N_MSN - n_sel], [target],
                                              model=syn)
                    my_nest.ConvergentConnect(MSN[N_MSN:N_MSN + n_sel],
                                              [target],
                                              model=syn)
                    my_nest.ConvergentConnect(
                        GPE[:], [target], model=SYNAPSE_MODELS_BACKGROUND[0])
                    my_nest.ConvergentConnect(
                        STN[:], [target], model=SYNAPSE_MODELS_BACKGROUND[1])

        my_nest.MySimulate(sim_time)

        for SNR_sel in SNR_list:
            for SNR in SNR_sel:
                SNR.get_signal('s')

        t1 = selection_intervals[0]
        t3 = selection_intervals[2]

        mean_rates = []
        mean_rates_std = []
        # Time until arrival of spikes in SNr
        delay = my_nest.GetDefaults(SYNAPSE_MODELS_BACKGROUND[0])['delay']
        for SNR_sel in SNR_list:
            m_r = []
            m_r_std = []
            for SNR in SNR_sel:

                # Mean rate during first 200 ms
                m_r.append(SNR.signals['spikes'].mean_rate(
                    SEL_ONSET + t1 + delay, SEL_ONSET + t1 + 200 + delay))
                m_r.append(SNR.signals['spikes'].mean_rate(
                    SEL_ONSET + t3 + delay, SEL_ONSET + t3 + 200 + delay))

                m_r_std.append(SNR.signals['spikes'].mean_rate_std(
                    SEL_ONSET + t1 + delay, SEL_ONSET + t1 + 200 + delay))
                m_r_std.append(SNR.signals['spikes'].mean_rate_std(
                    SEL_ONSET + t3 + delay, SEL_ONSET + t3 + 200 + delay))

            mean_rates.append(m_r)
            mean_rates_std.append(m_r_std)

        mean_rates = numpy.array(mean_rates)
        mean_rates_std = numpy.array(mean_rates_std)

        s = '\n'
        s = s + 'simulate_rate_first_and_second_bursts\n'
        s = s + '%s %5s %3s \n' % ('Simulation time', str(sim_time), '#')
        s = s + '%s %5s %3s \n' % ('N MSNs:', str(N_MSN), '#')
        s = s + '%s %5s %3s \n' % ('N MSN_bursts:', str(n_msn_burst), '#')
        s = s + '%s %5s %3s \n' % ('N experiments:', str(n_exp), '#')
        s = s + '%s %5s %3s \n' % ('MSN base rate:', str(MSN_BASE_RATE),
                                   'spikes/s')
        s = s + '%s %5s %3s \n' % ('MSN burst rate:', str(MSN_BURST_RATE),
                                   'spikes/s')
        s = s + '%s %5s %3s \n' % ('MSN burst time:', str(burst_time), 'ms')
        s = s + '%s %5s %3s \n' % ('GPe base rate:', str(GPE_BASE_RATE),
                                   'spikes/s')
        s = s + '%s %5s %3s \n' % ('SNR injected current:',
                                   str(SNR_INJECTED_CURRENT), 'pA')
        for i_interval, interval in enumerate(selection_intervals):
            s = s + '%s %5s %3s \n' % ('Sel interval ' + str(i_interval) + ':',
                                       str(selection_intervals), 'ms')

        info_string = s

        header = s
        misc.text_save(header, save_header_at)
        misc.pickle_save([mean_rates, mean_rates_std, info_string],
                         save_result_at)

    elif load:
        mean_rates, mean_rates_std, info_string = misc.pickle_load(
            save_result_at)

    return mean_rates, mean_rates_std, info_string
def simulate_example(MSN_hz=20, GPE_hz=0, load=True, n_gpe_sel=3, sel_time_GPE=500):
    global GPE_BASE_RATE
    global STN_BASE_RATE
    global MSN_BASE_RATE
    global MSN_BURST_TIME

    global NEURON_MODELS
    global N_GPE
    global N_STN
    global N_MSN
    global N_MSN_BURST

    global SNAME
    global SPATH
    global SYNAPSE_MODELS
    global SEL_ONSET
    global SNR_INJECTED_CURRENT
    
    n_exp = 200
   
    msn_rate_sel = MSN_hz # Selection rate     
    gpe_sel_rate = GPE_hz # Selection rate     

    sel_time_MSN = MSN_BURST_TIME
    sim_time = sel_time_MSN+SEL_ONSET+500.
    
    EXPERIMENTS=range(n_exp)
    
    MODEL_LIST=models()
    my_nest.ResetKernel()       
    my_nest.MyLoadModels( MODEL_LIST, NEURON_MODELS )
    my_nest.MyLoadModels( MODEL_LIST, SYNAPSE_MODELS)      
    my_nest.MyLoadModels( MODEL_LIST, SYNAPSE_MODELS_BACKGROUND)       
 
    
    MSN_list=[] # MSN input for each experiment
    for i_exp in EXPERIMENTS:
        MSN = MyPoissonInput( n=N_MSN+N_MSN_BURST, sd=True)
        MSN_list.append(MSN)
 
    GPE_list=[] # GPE input for each experiment
    for i_exp in EXPERIMENTS:
        GPE = MyPoissonInput( n=N_GPE+n_gpe_sel, sd=True)
        GPE_list.append(GPE)

    STN_list=[] # GPE input for each experiment
    for i_exp in EXPERIMENTS:
        STN = MyPoissonInput( n=N_STN, sd=True)
        STN_list.append(GPE)

    
    SNR_list=[] # SNR groups for each synapse
    
    
    for i, SNR_i_c in enumerate(SNR_INJECTED_CURRENT):
        I_e=my_nest.GetDefaults(NEURON_MODELS[0])['I_e']+SNR_i_c    
        SNR = MyGroup( NEURON_MODELS[0], n=n_exp, params={'I_e':I_e}, 
                       sd=True, mm=False,
                       mm_dt=.1, record_from=[''])
        SNR_list.append(SNR)

   
    if not load:
        for i_exp in EXPERIMENTS:    
            
            # MSN
            MSN = MSN_list[i_exp]
            
            # Set spike times
            # Base rate
            for id in MSN[0:N_MSN]:                 
                MSN.set_spike_times(id=id, rates=[MSN_BASE_RATE], times=[1], 
                                    t_stop=sim_time,
                                    seed=int(numpy.random.random()*10000.0))               
      
            # Selection MSN        
            for id in MSN[N_MSN:N_MSN+N_MSN_BURST]: 
                rates = [MSN_BASE_RATE, msn_rate_sel, MSN_BASE_RATE]
                times = [1, SEL_ONSET, sel_time_MSN + SEL_ONSET]
                t_stop = sim_time
                MSN.set_spike_times(id=id, rates=rates, times=times, 
                                    t_stop=t_stop, 
                                    seed=int(numpy.random.random()*10000.0))     
        
     
            # GPE
            GPE = GPE_list[i_exp]
            
            # Set spike times
            # Base rate
            for id in GPE[:]:                 
                GPE.set_spike_times(id=id, rates=[GPE_BASE_RATE], times=[1], 
                                    t_stop=sim_time,
                                    seed=int(numpy.random.random()*10000.0))               
      
            # Selection GPE        
            for id in GPE[N_GPE:N_GPE+n_gpe_sel]: 
                rates = [GPE_BASE_RATE, gpe_sel_rate, GPE_BASE_RATE]
                
                # If GPe excited smaller selection time
                times = [1, SEL_ONSET, sel_time_GPE + SEL_ONSET]
                t_stop = sim_time
                GPE.set_spike_times(id=id, rates=rates, times=times, 
                                    t_stop=t_stop, seed=int(numpy.random.random()*100000.0))     

            # Base rate STN
            for id in STN[:]:                 
                STN.set_spike_times(id=id, rates=[STN_BASE_RATE], times=[1], 
                                    t_stop=sim_time,
                                    seed=int(numpy.random.random()*10000.0))     
                
            idx_MSN_s=range(0,N_MSN-N_MSN_BURST)
            idx_MSN_s.extend(range(N_MSN,N_MSN+N_MSN_BURST))
            idx_GPE_s=range(0,N_GPE-n_gpe_sel)
            idx_GPE_s.extend(range(N_GPE,N_GPE+n_gpe_sel))
            
            # Connect with MSN burst         
            target=SNR_list[0][i_exp]
            my_nest.ConvergentConnect(MSN[idx_MSN_s], [target], model=SYNAPSE_MODELS[0])
            my_nest.ConvergentConnect(GPE[0:N_GPE], [target], model=SYNAPSE_MODELS[1])               
            my_nest.ConvergentConnect(STN[:], [target], model=SYNAPSE_MODELS_BACKGROUND[0]) 
      
            # With GPe pause
            target=SNR_list[1][i_exp]
            my_nest.ConvergentConnect(MSN[0:N_MSN], [target], model=SYNAPSE_MODELS[0])
            my_nest.ConvergentConnect(GPE[idx_GPE_s], [target], model=SYNAPSE_MODELS[1])                
            my_nest.ConvergentConnect(STN[:], [target], model=SYNAPSE_MODELS_BACKGROUND[0]) 
            
            # With MSN burst and GPe pause
            target=SNR_list[2][i_exp]
            my_nest.ConvergentConnect(MSN[idx_MSN_s], [target], model=SYNAPSE_MODELS[0])
            my_nest.ConvergentConnect(GPE[idx_GPE_s], [target], model=SYNAPSE_MODELS[1])         
            my_nest.ConvergentConnect(STN[:], [target], model=SYNAPSE_MODELS_BACKGROUND[0]) 
                      
        my_nest.MySimulate( sim_time )

        for MSN in MSN_list: 
            MSN.get_signal( 's' )      
        for GPE in GPE_list: 
            GPE.get_signal( 's' )   
        for SNR in SNR_list: 
            SNR.get_signal( 's' ) 

        misc.pickle_save([MSN_list, GPE_list,SNR_list] , save_at)

    if load:
        MSN_list, GPE_list, SNR_list=misc.pickle_load(save_at)
        
    pre_dyn_MSN=str(SNR_list[0].signals['spikes'].mean_rate(SEL_ONSET-500,
                                                            SEL_ONSET)) 
    pre_dyn_GPE=str(SNR_list[1].signals['spikes'].mean_rate(SEL_ONSET-500,
                                                            SEL_ONSET))   
      
    s='\n'
    s=s+'Example:\n'
    s = s + ' %s %5s %3s \n' % ( 'N experiments:', str ( len(EXPERIMENTS) ),  '#' )  
    s = s + ' %s %5s %3s \n' % ( 'N MSN:', str ( N_MSN ),  '#' )  
    s = s + ' %s %5s %3s \n' % ( 'N GPE:', str ( N_GPE ),  '#' )  
    s='\n'
    s = s + ' %s %5s %3s \n' % ( 'Base rate MSN:',   str ( MSN_BASE_RATE),'spikes/s' )     
    s = s + ' %s %5s %3s \n' % ( 'Sel rate MSN:', str ( msn_rate_sel ), 'spikes/s' )
    s = s + ' %s %5s %3s \n' % ( 'Sel time MSN:', str ( sel_time_MSN ), 'ms' )
    s='\n'
    s = s + ' %s %5s %3s \n' % ( 'Base rate GPe:',   str ( GPE_BASE_RATE),'spikes/s' )   
    s = s + ' %s %5s %3s \n' % ( 'Sel rate GPe:', str ( gpe_sel_rate ), 'spikes/s' )  
    s = s + ' %s %5s %3s \n' % ( 'Sel time GPe:', str ( sel_time_GPE ), 'ms' )
    s = s + ' %s %5s %3s \n' % ( 'Pre sel rate Dyn MSN:', pre_dyn_MSN[0:4], 'spikes/s' )
    s = s + ' %s %5s %3s \n' % ( 'Pre sel rate Dyn GPe:', pre_dyn_GPE[0:4], 'spikes/s' )
      
    return MSN_list, GPE_list, SNR_list, s

    info_string=s
    
    return MSN_hzs, GPE_hzs, data, info_string
Beispiel #3
0
def simulate_MSN_vs_SNR_const_syn_events(load=True):
    global SNR_INJECTED_CURRENT
    global N_MSN
    global N_GPE
    global MSN_BURST_RATE
    global GPE_BASE_RATE

    # Path were raw data is saved. For example the spike trains.
    save_result_at = OUTPUT_PATH + '/simulate_MSN_vs_SNR_const_syn_events.pkl'
    save_header_at = OUTPUT_PATH + '/simulate_MSN_vs_SNR_const_syn_events_header'

    # REMARK can not be more than rate=const_syn_events/burst_rate
    n_MSN_bursting = numpy.arange(0, N_MAX_BURSTING + 1)

    n_exp = 200
    #n_exp=20

    # Solve (500-n)*x + 20*n=600, where 500 is total number of MSNs, 20 is burst
    # activation, x is MSN mean rate and n is number of bursters.
    # Then x=(600-20*n)/(500-n)
    MSNmeanRates = (SYN_EVENTS -
                    MSN_BURST_RATE * n_MSN_bursting) / (N_MSN - n_MSN_bursting)

    SNRmeanRates = []

    sim_time = 3000.

    if not load:
        for r, n_MSN_b in zip(MSNmeanRates, n_MSN_bursting):
            my_nest.ResetKernel(threads=4)
            model_list, model_dict = models()
            my_nest.MyLoadModels(model_list, NEURON_MODELS)
            my_nest.MyLoadModels(model_list, SYNAPSE_MODELS_TESTED)
            my_nest.MyLoadModels(model_list, SYNAPSE_MODELS_BACKGROUND)

            MSN = []
            SNR = []
            GPE = []
            STN = []

            for i in range(n_exp):
                MSN.append(MyPoissonInput(n=N_MSN, sd=True))
                GPE.append(MyPoissonInput(n=N_GPE, sd=True))
                STN.append(MyPoissonInput(n=N_STN, sd=True))

                I_e = my_nest.GetDefaults(
                    NEURON_MODELS[0])['I_e'] + SNR_INJECTED_CURRENT
                SNR.append(
                    MyGroup(NEURON_MODELS[0],
                            n=len(SYNAPSE_MODELS_TESTED),
                            params={'I_e': I_e},
                            sd=True))

            for i_exp in range(n_exp):
                for id in MSN[i_exp][:N_MSN - n_MSN_b]:
                    MSN[i_exp].set_spike_times(id=id,
                                               rates=numpy.array([r]),
                                               times=numpy.array([1]),
                                               t_stop=sim_time,
                                               seed=int(numpy.random.random() *
                                                        10000.0))

                for id in MSN[i_exp][N_MSN - n_MSN_b:]:
                    MSN[i_exp].set_spike_times(
                        id=id,
                        rates=numpy.array([r, MSN_BURST_RATE, r]),
                        times=numpy.array([1, SEL_ONSET, SEL_OFFSET]),
                        t_stop=sim_time,
                        seed=int(numpy.random.random() * 10000.0))

                # Base rate GPE
                for id in GPE[i_exp][:]:
                    GPE[i_exp].set_spike_times(id=id,
                                               rates=[GPE_BASE_RATE],
                                               times=[1],
                                               t_stop=sim_time,
                                               seed=int(numpy.random.random() *
                                                        10000.0))
                # Base rate STN
                for id in STN[i_exp][:]:
                    STN[i_exp].set_spike_times(id=id,
                                               rates=[STN_BASE_RATE],
                                               times=[1],
                                               t_stop=sim_time,
                                               seed=int(numpy.random.random() *
                                                        10000.0))

                for j, syn in enumerate(SYNAPSE_MODELS_TESTED):
                    my_nest.ConvergentConnect(MSN[i_exp][:], [SNR[i_exp][j]],
                                              model=syn)
                    my_nest.ConvergentConnect(
                        GPE[i_exp][:], [SNR[i_exp][j]],
                        model=SYNAPSE_MODELS_BACKGROUND[0])
                    my_nest.ConvergentConnect(
                        STN[i_exp][:], [SNR[i_exp][j]],
                        model=SYNAPSE_MODELS_BACKGROUND[1])

            my_nest.MySimulate(sim_time)

            delay = my_nest.GetDefaults(SYNAPSE_MODELS_BACKGROUND[0])['delay']
            SNRmeanRates_tmp = []
            for i in range(n_exp):
                SNR[i].get_signal('s')  # retrieve signal

                SNRmeanRates_tmp.append(SNR[i].signals['spikes'].mean_rates(
                    SEL_ONSET + delay, SEL_OFFSET + delay))

            SNRmeanRates.append(numpy.mean(SNRmeanRates_tmp, axis=0))

        SNRmeanRates = numpy.array(SNRmeanRates).transpose()

        s = '\n'
        s = s + 'simulate_MSN_vs_SNR_const_syn_events:\n'
        s = s + '%s %5s %3s \n' % ('Syn events:', str(SYN_EVENTS), '#')
        s = s + '%s %5s %3s \n' % ('n_exp:', str(n_exp), '#')
        infoString = s

        header = HEADER_SIMULATION_SETUP + s
        misc.text_save(header, save_header_at)
        misc.pickle_save([SNRmeanRates, infoString], save_result_at)

    elif load:
        SNRmeanRates, infoString = misc.pickle_load(save_result_at)

    return n_MSN_bursting, MSNmeanRates, SNRmeanRates, infoString
Beispiel #4
0
def simulate_example(load=True):

    global GPE_BASE_RATE
    global FILE_NAME
    global N_GPE
    global N_STN
    global N_MSN_BURST
    global N_MSN
    global NEURON_MODELS
    global OUTPUT_PATH
    global SEL_ONSET
    global SNR_INJECTED_CURRENT
    global SYNAPSE_MODELS_TESTED

    #n_exp =200 # number of experiments
    n_exp = 200  # number of experiments

    # Path were raw data is saved. For example the spike trains.
    save_result_at = OUTPUT_PATH + '/simulate_example.pkl'
    save_header_at = OUTPUT_PATH + '/simulate_example_header'

    burst_time = 500.
    sim_time = SEL_INTERVAL_2[1] + 500

    model_list = models()
    my_nest.ResetKernel(threads=8)
    my_nest.MyLoadModels(model_list, NEURON_MODELS)
    my_nest.MyLoadModels(model_list, SYNAPSE_MODELS_TESTED)
    my_nest.MyLoadModels(model_list, SYNAPSE_MODELS_BACKGROUND)

    SNR_list = []  # List with SNR groups for synapse.
    if not load:
        MSN_base = MyPoissonInput(n=N_MSN_BASE * n_exp)
        MSN_burst = MyPoissonInput(n=N_MSN_BURST * n_exp)
        GPE = MyPoissonInput(n=N_GPE * n_exp, sd=True)
        STN = MyPoissonInput(n=N_STN * n_exp, sd=True)

        # Set spike times MSN and GPe
        # Non bursting MSNs
        for id in MSN_base[:]:
            seed = numpy.random.random_integers(0, 1000000.0)
            MSN_base.set_spike_times(id=id,
                                     rates=[MSN_BASE_RATE],
                                     times=[1],
                                     t_stop=sim_time,
                                     seed=seed)

        # Background GPe
        for id in GPE[:]:
            seed = numpy.random.random_integers(0, 1000000.0)
            GPE.set_spike_times(id=id,
                                rates=[GPE_BASE_RATE],
                                times=[1],
                                t_stop=sim_time,
                                seed=seed)
        # Background STN
        for id in STN[:]:
            seed = numpy.random.random_integers(0, 1000000.0)
            STN.set_spike_times(id=id,
                                rates=[STN_BASE_RATE],
                                times=[1],
                                t_stop=sim_time,
                                seed=seed)

        # Bursting MSNs
        for id in MSN_burst[:]:
            rates = [
                MSN_BASE_RATE, MSN_BURST_RATE, MSN_BASE_RATE, MSN_BURST_RATE,
                MSN_BASE_RATE
            ]
            times = [
                1, SEL_INTERVAL_1[0], SEL_INTERVAL_1[1], SEL_INTERVAL_2[0],
                SEL_INTERVAL_2[1]
            ]
            t_stop = sim_time
            seed = numpy.random.random_integers(0, 1000000.0)

            MSN_burst.set_spike_times(id=id,
                                      rates=rates,
                                      times=times,
                                      t_stop=t_stop,
                                      seed=seed)

        for i_syn in range(len(SYNAPSE_MODELS_TESTED)):

            I_e = my_nest.GetDefaults(
                NEURON_MODELS[0])['I_e'] + SNR_INJECTED_CURRENT
            SNR = MyGroup(NEURON_MODELS[0],
                          n=n_exp,
                          sd=True,
                          params={'I_e': I_e},
                          mm_dt=.1,
                          record_from=[''])

            SNR_list.append(SNR)

        # Connect, experiment specific
        sources_MSN_SNR_base = numpy.arange(0, n_exp * N_MSN_BASE)
        sources_MSN_SNR_burst = numpy.arange(0, n_exp * N_MSN_BURST)

        targets_MSN_SNR_base = numpy.mgrid[0:n_exp, 0:N_MSN_BASE][0].reshape(
            1, N_MSN_BASE * n_exp)[0]
        targets_MSN_SNR_burst = numpy.mgrid[0:n_exp, 0:N_MSN_BURST][0].reshape(
            1, N_MSN_BURST * n_exp)[0]

        sources_GPE_SNR = numpy.arange(0, n_exp * N_GPE)
        targets_GPE_SNR = numpy.mgrid[0:n_exp,
                                      0:N_GPE][0].reshape(1, N_GPE * n_exp)[0]

        sources_STN_SNR = numpy.arange(0, n_exp * N_STN)
        targets_STN_SNR = numpy.mgrid[0:n_exp,
                                      0:N_STN][0].reshape(1, N_STN * n_exp)[0]

        for i_syn, syn in enumerate(SYNAPSE_MODELS_TESTED):
            syn = SYNAPSE_MODELS_TESTED[i_syn]
            SNR = SNR_list[i_syn]
            my_nest.Connect(MSN_base[sources_MSN_SNR_base],
                            SNR[targets_MSN_SNR_base],
                            model=syn)
            my_nest.Connect(MSN_burst[sources_MSN_SNR_burst],
                            SNR[targets_MSN_SNR_burst],
                            model=syn)
            my_nest.Connect(GPE[sources_GPE_SNR],
                            SNR[targets_GPE_SNR],
                            model=SYNAPSE_MODELS_BACKGROUND[0])
            my_nest.Connect(STN[sources_STN_SNR],
                            SNR[targets_STN_SNR],
                            model=SYNAPSE_MODELS_BACKGROUND[1])

        my_nest.MySimulate(sim_time)

        for SNR in SNR_list:
            SNR.get_signal('s', start=0, stop=sim_time)

        pre_ref_1 = str(SNR_list[0].signals['spikes'].mean_rate(
            SEL_ONSET - 500, SEL_ONSET))
        burst_1 = str(SNR_list[0].signals['spikes'].mean_rate(
            SEL_ONSET, SEL_ONSET + 200))
        burst_2 = str(SNR_list[0].signals['spikes'].mean_rate(
            SEL_ONSET + 1000, SEL_ONSET + 1200))
        s = '\n'
        s = s + 'Simulate example:\n'
        s = s + '%s %5s %3s \n' % ('Simulation time', str(sim_time), '#')
        s = s + '%s %5s %3s \n' % ('N experiments:', str(n_exp), '#')
        s = s + '%s %5s %3s \n' % ('MSN base rate:', str(MSN_BASE_RATE),
                                   'spikes/s')
        s = s + '%s %5s %3s \n' % ('MSN burst rate:', str(MSN_BURST_RATE),
                                   'spikes/s')
        s = s + '%s %5s %3s \n' % ('GPe rate:', str(GPE_BASE_RATE), 'spikes/s')
        s = s + '%s %5s %3s \n' % ('Burst time:', str(burst_time), 'ms')
        s = s + '%s %5s %3s \n' % ('Pre sel rate Ref:', pre_ref_1[0:4],
                                   'spikes/s')
        s = s + '%s %5s %3s \n' % ('Burst 1:', burst_1[0:4], 'spikes/s')
        s = s + '%s %5s %3s \n' % ('Burst 2:', burst_2[0:4], 'spikes/s')
        header = s
        misc.text_save(header, save_header_at)
        misc.pickle_save([SNR_list, s], save_result_at)

    else:
        SNR_list, s = misc.pickle_load(save_result_at)

    return SNR_list, s
Beispiel #5
0
def simulate_MSN_vs_SNR_rate(load=True):
    global SNR_INJECTED_CURRENT
    global N_MSN
    global N_GPE
    global N_STN
    global GPE_BASE_RATE

    # Path were raw data is saved. For example the spike trains.
    save_result_at = OUTPUT_PATH + '/simulate_MSN_vs_SNR_rate.pkl'
    save_header_at = OUTPUT_PATH + '/simulate_MSN_vs_SNR_rate_header'

    MSNmeanRates = numpy.arange(0.1, 3.1, 0.1)
    SNRmeanRates = []

    sim_time = 100000.

    if not load:
        for r in MSNmeanRates:
            my_nest.ResetKernel(threads=3)
            model_list, model_dict = models()
            my_nest.MyLoadModels(model_list, NEURON_MODELS)
            my_nest.MyLoadModels(model_list, SYNAPSE_MODELS_TESTED)
            my_nest.MyLoadModels(model_list, SYNAPSE_MODELS_BACKGROUND)

            MSN = MyPoissonInput(n=N_MSN)
            GPE = MyPoissonInput(n=N_GPE)
            STN = MyPoissonInput(n=N_STN)

            I_e = my_nest.GetDefaults(
                NEURON_MODELS[0])['I_e'] + SNR_INJECTED_CURRENT
            SNR = MyGroup(NEURON_MODELS[0],
                          n=len(SYNAPSE_MODELS_TESTED),
                          params={'I_e': I_e},
                          sd=True)

            for id in MSN[:]:
                MSN.set_spike_times(id=id,
                                    rates=numpy.array([r]),
                                    times=numpy.array([1]),
                                    t_stop=sim_time,
                                    seed=int(numpy.random.random() * 10000.0))

            # Base rate GPE
            for id in GPE[:]:
                GPE.set_spike_times(id=id,
                                    rates=[GPE_BASE_RATE],
                                    times=[1],
                                    t_stop=sim_time,
                                    seed=int(numpy.random.random() * 10000.0))

            # Base rate STN
            for id in STN[:]:
                STN.set_spike_times(id=id,
                                    rates=[STN_BASE_RATE],
                                    times=[1],
                                    t_stop=sim_time,
                                    seed=int(numpy.random.random() * 10000.0))

            for i, syn in enumerate(SYNAPSE_MODELS_TESTED):
                my_nest.ConvergentConnect(MSN[:], [SNR[i]], model=syn)
                my_nest.ConvergentConnect(GPE[:], [SNR[i]],
                                          model=SYNAPSE_MODELS_BACKGROUND[0])
                my_nest.ConvergentConnect(STN[:], [SNR[i]],
                                          model=SYNAPSE_MODELS_BACKGROUND[1])

            my_nest.MySimulate(sim_time)

            SNR.get_signal('s')  # retrieve signal

            SNRmeanRates.append(SNR.signals['spikes'].mean_rates(
                1000.0, sim_time))

        SNRmeanRates = numpy.array(SNRmeanRates).transpose()
        MSNmeanRates = numpy.array(MSNmeanRates)

        rateAtThr = ''
        for SNRr in SNRmeanRates:
            tmp = str(MSNmeanRates[SNRr >= SELECTION_THR][-1])
            rateAtThr += ' ' + tmp[0:4]

        s = '\n'
        s = s + 'simulate_MSN_vs_SNR_rate:\n'
        s = s + ' %s %5s %3s \n' % ('N MSNs:', str(N_MSN), '#')
        s = s + ' \n%s \n%5s %3s \n' % ('MSN rates:', str(
            MSNmeanRates[0]) + '-' + str(MSNmeanRates[-1]), 'spikes/s')
        s = s + ' %s %5s %3s \n' % ('N GPes:', str(N_GPE), '#')
        s = s + ' %s %5s %3s \n' % ('Threshold SNr:', str(SELECTION_THR),
                                    'spikes/s')
        s = s + ' \n%s \n%5s %3s \n' % ('MSN rate right before threshold SNr:',
                                        str(rateAtThr), 'spikes/s')
        s = s + ' \n%s %5s %3s \n' % ('Simulation time:', str(sim_time), 'ms')
        s = s + ' %s %5s %3s \n' % ('Injected current:',
                                    str(SNR_INJECTED_CURRENT), 'pA')
        infoString = s

        header = HEADER_SIMULATION_SETUP + s
        misc.text_save(header, save_header_at)
        misc.pickle_save([MSNmeanRates, SNRmeanRates, infoString],
                         save_result_at)
    elif load:
        MSNmeanRates, SNRmeanRates, infoString = misc.pickle_load(
            save_result_at)

    return MSNmeanRates, SNRmeanRates, infoString
def simulate_example(hz=20):
    sname_nb = hz + 1000

    saveAt = SPATH + '/' + SNAME + '-' + NEURONMODELS[0] + '-example.pkl'

    nGPE = 100
    EXPERIMENTS = range(20)
    nSelected = 50
    selectionRate = hz
    baseRate = 20.
    model_list = models()
    I_e = -5.
    simTime = 3500.
    selectionTime = 500.
    selectionOnset = 2500.

    my_nest.ResetKernel()
    my_nest.MyLoadModels(model_list, NEURONMODELS)
    my_nest.MyLoadModels(model_list, SYNAPSE_MODELS)

    GPE_list = []  # GPE input for each experiment
    for iExp in EXPERIMENTS:
        GPE_list.append(
            MyPoissonInput(n=nGPE,
                           sd=True,
                           spath=SPATH,
                           sname_nb=sname_nb + iExp))

    SNR_list = []  # SNR groups for each synapse
    for iSyn, syn in enumerate(SYNAPSE_MODELS):
        SNR_list.append(
            MyGroup(NEURONMODELS[0],
                    n=len(EXPERIMENTS),
                    params={'I_e': I_e},
                    mm_dt=.1,
                    record_from=[''],
                    spath=SPATH,
                    sname_nb=sname_nb + iSyn))
    if not LOAD:
        for iExp in EXPERIMENTS:

            GPE = GPE_list[iExp]

            # Base rate
            for id in GPE[:]:
                GPE.set_spike_times(id=id,
                                    rates=[baseRate],
                                    times=[1],
                                    t_stop=simTime)

            # Selection
            for id in GPE[:]:
                GPE.set_spike_times(
                    id=id,
                    rates=[baseRate, selectionRate, baseRate],
                    times=[1, selectionOnset, selectionTime + selectionOnset],
                    t_stop=simTime)

            for iSyn, syn in enumerate(SYNAPSE_MODELS):
                target = SNR_list[iSyn][iExp]
                my_nest.ConvergentConnect(GPE[:], [target], model=syn)

        my_nest.MySimulate(simTime)

        for GPE in GPE_list:
            GPE.get_signal('s')  # retrieve signal

        for SNR in SNR_list:
            SNR.get_signal('s')  # retrieve signal
        misc.pickle_save([GPE_list, SNR_list], saveAt)

    if LOAD:
        GPE_list, SNR_list = misc.pickle_load(saveAt)

    s = '\n'
    s = s + 'Example:\n'
    s = s + ' %s %5s %3s \n' % ('N experiments:', str(len(EXPERIMENTS)), '#')
    s = s + ' %s %5s %3s \n' % ('Base rate:', str(baseRate), '#')
    s = s + ' %s %5s %3s \n' % ('Selection rate:', str(selectionRate), '#')

    return GPE_list, SNR_list, s
def simulate_example(hz=0, load=True):
    global NEURON_MODELS
    global SNAME
    global SPATH
    global SYNAPSE_MODELS
    global SEL_ONSET
    global I_E

    N_EXP = 200
    N_GPE = 50
    N_SEL = 30  # Number of selected GPE
    N_INH = 0  # Number of inhibited GPE
    RATE_BASE = 15  # Base rate
    RATE_SELE = hz  # Selection rate
    RATE_INHI = 0
    SAVE_AT = SPATH + '/' + NEURON_MODELS[0] + '-example.pkl'
    SEL_TIME = 20.
    sim_time = SEL_TIME + SEL_ONSET + 800.
    SNAME_NB = hz + 1000

    EXPERIMENTS = range(N_EXP)

    MODEL_LIST = models()
    my_nest.ResetKernel()
    my_nest.MyLoadModels(MODEL_LIST, NEURON_MODELS)
    my_nest.MyLoadModels(MODEL_LIST, SYNAPSE_MODELS)

    GPE_list = []  # GPE input for each experiment
    for i_exp in EXPERIMENTS:
        GPE = MyPoissonInput(n=N_GPE,
                             sd=True,
                             spath=SPATH,
                             sname_nb=SNAME_NB + i_exp)
        GPE_list.append(GPE)

    SNR_list = []  # SNR groups for each synapse
    for i_syn, syn in enumerate(SYNAPSE_MODELS):
        SNR = MyGroup(NEURON_MODELS[0],
                      n=N_EXP,
                      params={'I_e': I_E},
                      sd=True,
                      mm=False,
                      mm_dt=.1,
                      record_from=[''],
                      spath=SPATH,
                      sname_nb=SNAME_NB + i_syn)
        SNR_list.append(SNR)

    if not load:
        for i_exp in EXPERIMENTS:
            GPE = GPE_list[i_exp]

            # Set spike times
            # Base rate
            for id in GPE[:]:
                GPE.set_spike_times(id=id,
                                    rates=[RATE_BASE],
                                    times=[1],
                                    t_stop=sim_time)

            # Selection
            for id in GPE[N_GPE - N_SEL:N_GPE + 1]:
                rates = [RATE_BASE, RATE_SELE, RATE_BASE]
                times = [1, SEL_ONSET, SEL_TIME + SEL_ONSET]
                t_stop = sim_time
                GPE.set_spike_times(id=id,
                                    rates=rates,
                                    times=times,
                                    t_stop=t_stop)

            # Inhibition
            for id in GPE[N_GPE - N_SEL - N_INH:N_GPE + 1 - N_SEL]:
                rates = [RATE_BASE, RATE_INHI, RATE_BASE]
                times = [1, SEL_ONSET, SEL_TIME + SEL_ONSET]
                t_stop = sim_time
                GPE.set_spike_times(id=id,
                                    rates=rates,
                                    times=times,
                                    t_stop=t_stop)

            # Connect
            for i_syn, syn in enumerate(SYNAPSE_MODELS):
                target = SNR_list[i_syn][i_exp]
                my_nest.ConvergentConnect(GPE[:], [target], model=syn)

        my_nest.MySimulate(sim_time)

        for GPE in GPE_list:
            GPE.get_signal('s')
        for SNR in SNR_list:
            SNR.get_signal('s')

        misc.pickle_save([GPE_list, SNR_list], SAVE_AT)

    if load:
        GPE_list, SNR_list = misc.pickle_load(SAVE_AT)

    pre_ref = str(SNR_list[0].signals['spikes'].mean_rate(
        SEL_ONSET - 500, SEL_ONSET))
    pre_dyn = str(SNR_list[2].signals['spikes'].mean_rate(
        SEL_ONSET - 500, SEL_ONSET))

    s = '\n'
    s = s + 'Example:\n'
    s = s + ' %s %5s %3s \n' % ('N experiments:', str(len(EXPERIMENTS)), '#')
    s = s + ' %s %5s %3s \n' % ('Base rate:', str(RATE_BASE), 'Hz')
    s = s + ' %s %5s %3s \n' % ('Selection rate:', str(RATE_SELE), 'Hz')
    s = s + ' %s %5s %3s \n' % ('Selection time:', str(SEL_TIME), 'ms')
    s = s + ' %s %5s %3s \n' % ('Pre sel rate Ref:', pre_ref[0:4], 'Hz')
    s = s + ' %s %5s %3s \n' % ('Pre sel rate Dyn:', pre_dyn[0:4], 'Hz')

    return GPE_list, SNR_list, s
def simulate_GPE_vs_SNR_const_syn_events(load=True):
    global N_GPE
    global N_MSN
    global MSN_BASE_RATE
    global SNR_INJECTED_CURRENT
    
    save_at = (SPATH+'/'+NEURON_MODELS[0]+'-' + '-GPE_vs_SNR_const_syn_events.pkl') 
    
    nGPE_range=numpy.arange(N_GPE,4,-1)
    
    # To maintain CONSTANT_SYN_EVENTS in to SNr while changing number of pausing 
    # GPe we have to increase the mean rate of the non-pausing GPe's
    
    GPEmeanRates=CONSTANT_SYN_EVENTS/nGPE_range
    SNRmeanRates=[]

    sim_time=10000.
    I_e=0.
    
    if not load:
        for r, n_gpe in zip(GPEmeanRates,nGPE_range):
            my_nest.ResetKernel()
            model_list=models()
            my_nest.MyLoadModels( model_list, NEURON_MODELS )
            my_nest.MyLoadModels( model_list, SYNAPSE_MODELS_TESTED )      
            my_nest.MyLoadModels( model_list, SYNAPSE_MODELS_BACKGROUND )
            
            GPE = MyPoissonInput( n=n_gpe)          
            MSN = MyPoissonInput( n=N_MSN)          
            STN = MyPoissonInput( n=N_STN)    
            
            I_e=my_nest.GetDefaults(NEURON_MODELS[0])['I_e']+SNR_INJECTED_CURRENT
            SNR = MyGroup( NEURON_MODELS[0], n=len(SYNAPSE_MODELS_TESTED), 
                           sd=True,params={'I_e':I_e})

            for id in GPE[:]:
                GPE.set_spike_times(id=id, rates=[r], times=[1], 
                                    t_stop=sim_time, 
                                    seed=int(numpy.random.random()*10000.0))  
            for id in MSN[:]:
                MSN.set_spike_times(id=id, rates=[MSN_BASE_RATE], times=[1], 
                                    t_stop=sim_time, 
                                    seed=int(numpy.random.random()*10000.0))              
            for id in STN[:]:
                STN.set_spike_times(id=id, rates=[STN_BASE_RATE], times=[1], 
                                    t_stop=sim_time, 
                                    seed=int(numpy.random.random()*10000.0))          
                
            for i, syn in enumerate(SYNAPSE_MODELS_TESTED):
                my_nest.ConvergentConnect(GPE[:],[SNR[i]], model=syn)
                my_nest.ConvergentConnect(MSN[:],[SNR[i]], model=SYNAPSE_MODELS_BACKGROUND[0])
                my_nest.ConvergentConnect(STN[:],[SNR[i]], model=SYNAPSE_MODELS_BACKGROUND[1])
    
            
            my_nest.MySimulate( sim_time )

            SNR.get_signal( 's') # retrieve signal
                
            SNRmeanRates.append(SNR.signals['spikes'].mean_rates(5000,sim_time))   
        
        SNRmeanRates=numpy.array(SNRmeanRates).transpose()
        GPEmeanRates=numpy.array(GPEmeanRates)

        rateAtThr=''
        for SNRr in SNRmeanRates:
            tmp=str(GPEmeanRates[SNRr>=SELECTION_THR][-1])
            rateAtThr+=' '+tmp[0:4]
        
            
        
        
        s='\n'
        s =s + 'GPE vs SNr rate:\n'   
        s = s + ' %s %5s %3s \n' % ( 'N GPEs:', str ( N_GPE ),  '#' )  
        s = s + ' \n%s %5s %3s \n' % ( 'GPE rates:', str ( GPEmeanRates[0] ) + '-'+ 
                                         str ( GPEmeanRates[-1] ),  'spikes/s' ) 
        s = s + ' %s %5s %3s \n' % ( 'Threshold SNr:', str ( SELECTION_THR ),  'spikes/s' )
        s = s + ' \n%s %5s %3s \n' % ( 'GPE rate at threshold SNr:', str ( rateAtThr ),  'spikes/s' )   
        s = s + ' \n%s %5s %3s \n' % ( 'Simulation time:', str ( sim_time), 'ms' )
        s = s + ' %s %5s %3s \n' % ( 'I_e:', str ( I_e ), 'pA' )
        s = s + ' %s %5s %3s \n' % ( 'Steady state rate ref:', str ( round(SNRmeanRates[0][0],1) ), 'pA' )
        s = s + ' %s %5s %3s \n' % ( 'Steady state rate dyn:', str ( round(SNRmeanRates[1][0],1) ), 'pA' )
        statusSynapse=[]
        for syn in SYNAPSE_MODELS_TESTED:
            statusSynapse.append( my_nest.GetDefaults(syn) )

            for ss in statusSynapse:
                s = s + '\n'  
                s = s + ' %s %10s\n' % ( 'Synapse', ss['synapsemodel'])   
                s = s + ' %s %5s %3s\n' % ( 'Weight', 
                                      str( round( ss['weight'], 1) ), 'nS')
        
        infoString=s
        
        
        misc.pickle_save([GPEmeanRates, SNRmeanRates, infoString], 
                                save_at)
    
    elif load:
        GPEmeanRates, SNRmeanRates, infoString = misc.pickle_load(save_at)
    return nGPE_range, GPEmeanRates, SNRmeanRates, infoString
def simulate_GPE_vs_SNR_rate(load=True):
    global N_GPE
    global N_MSN
    global N_STN
    global MSN_BASE_RATE
   
    # Path were data is saved. For example the spike trains.
    save_at = (SPATH+'/'+NEURON_MODELS[0]+'-' + '-GPE_vs_SNR_rate.pkl') 
    
    GPEmeanRates=numpy.arange(0,150,1)
    SNRmeanRates=[]

    sim_time=50000.
    I_e=0.
    
    if not load:
        for r in GPEmeanRates:
            my_nest.ResetKernel()
            model_list=models()
            my_nest.MyLoadModels( model_list, NEURON_MODELS )
            my_nest.MyLoadModels( model_list, SYNAPSE_MODELS_TESTED )
            my_nest.MyLoadModels( model_list, SYNAPSE_MODELS_BACKGROUND )
            
            MSN = MyPoissonInput( n=N_MSN)           
            GPE = MyPoissonInput( n=N_GPE)          
            STN = MyPoissonInput( n=N_STN) 
            
            I_e=my_nest.GetDefaults(NEURON_MODELS[0])['I_e']+SNR_INJECTED_CURRENT
            SNR = MyGroup( NEURON_MODELS[0], n=len(SYNAPSE_MODELS_TESTED), 
                           sd=True,params={'I_e':I_e})
            
            for id in GPE[:]:
                GPE.set_spike_times(id=id, rates=[r], times=[1], 
                                    t_stop=sim_time, 
                                    seed=int(numpy.random.random()*10000.0))  
            for id in MSN[:]:
                MSN.set_spike_times(id=id, rates=[MSN_BASE_RATE], times=[1], 
                                    t_stop=sim_time, 
                                    seed=int(numpy.random.random()*10000.0))              

            for id in STN[:]:
                STN.set_spike_times(id=id, rates=[STN_BASE_RATE], times=[1], 
                                    t_stop=sim_time, 
                                    seed=int(numpy.random.random()*10000.0))
        
                
            for i, syn in enumerate(SYNAPSE_MODELS_TESTED):
                my_nest.ConvergentConnect(GPE[:],[SNR[i]], model=syn)
                my_nest.ConvergentConnect(MSN[:],[SNR[i]], model=SYNAPSE_MODELS_BACKGROUND[0])
                my_nest.ConvergentConnect(STN[:],[SNR[i]], model=SYNAPSE_MODELS_BACKGROUND[1])
                
            my_nest.MySimulate( sim_time )
            SNR.get_signal( 's') # retrieve signal
  
                
            SNRmeanRates.append(SNR.signals['spikes'].mean_rates( 5000, sim_time))   
        
        SNRmeanRates=numpy.array(SNRmeanRates).transpose()
        GPEmeanRates=numpy.array(GPEmeanRates)
        

        rateAtThr=''
        for SNRr in SNRmeanRates:
            tmp=str(GPEmeanRates[SNRr>=SELECTION_THR][-1])
            rateAtThr+=' '+tmp[0:4]
        
            
        
        
        s='\n'
        s =s + 'GPE vs SNr rate:\n'   
        s = s + ' %s %5s %3s \n' % ( 'N GPEs:', str ( N_GPE ),  '#' )  
        s = s + ' %s %5s %3s \n' % ( 'Max SNr rate:', str ( SNRmeanRates[0] ),  '#' )  
        s = s + ' \n%s \n%5s %3s \n' % ( 'GPE rates:', str ( GPEmeanRates[0] ) + '-'+ 
                                         str ( GPEmeanRates[-1] ),  'spikes/s' ) 
        s = s + ' %s %5s %3s \n' % ( 'Threshold SNr:', str ( SELECTION_THR ),  'spikes/s' )
        s = s + ' \n%s \n%5s %3s \n' % ( 'GPE rate at threshold SNr:', str ( rateAtThr ),  'spikes/s' )   
        s = s + ' \n%s %5s %3s \n' % ( 'Simulation time:', str ( sim_time), 'ms' )
        s = s + ' %s %5s %3s \n' % ( 'I_e:', str ( I_e ), 'pA' )
        infoString=s
        
        
        misc.pickle_save([GPEmeanRates, SNRmeanRates, infoString], 
                                save_at)
    
    elif load:
        GPEmeanRates, SNRmeanRates, infoString = misc.pickle_load(save_at)
    return GPEmeanRates, SNRmeanRates, infoString