def print_results(self, print_v=True):
        """
            # # # # # # # # # # # # # # # # #
            #   P R I N T    R E S U L T S  #
            # # # # # # # # # # # # # # # # #
        """
        if print_v:
            if self.pc_id == 0:
                print "print_v to file: %s.v" % (self.params["exc_volt_fn_base"])
            self.exc_pop_view.print_v("%s.v" % (self.params["exc_volt_fn_base"]), compatible_output=False)
            if self.pc_id == 0:
                print "Printing inhibitory membrane potentials"
            self.inh_pop_view.print_v("%s.v" % (self.params["inh_volt_fn_base"]), compatible_output=False)

        if self.pc_id == 0:
            print "Printing excitatory spikes"
        self.exc_pop.printSpikes(self.params["exc_spiketimes_fn_merged"] + ".ras")
        if self.pc_id == 0:
            print "Printing inhibitory spikes"
        self.inh_pop.printSpikes(self.params["inh_spiketimes_fn_merged"] + ".ras")

        self.times["t_print"] = self.timer.diff()
        if self.pc_id == 0:
            print "calling pyNN.end() ...."
        end()
        self.times["t_end"] = self.timer.diff()

        if self.pc_id == 0:
            self.times["t_all"] = 0.0
            for k in self.times.keys():
                self.times["t_all"] += self.times[k]

            self.n_cells = {}
            self.n_cells["n_exc"] = self.params["n_exc"]
            self.n_cells["n_inh"] = self.params["n_inh"]
            self.n_cells["n_cells"] = self.params["n_cells"]
            self.n_cells["n_proc"] = self.n_proc
            output = {"times": self.times, "n_cells_proc": self.n_cells}
            print "Proc %d Simulation time: %d sec or %.1f min for %d cells (%d exc %d inh)" % (
                self.pc_id,
                self.times["t_sim"],
                (self.times["t_sim"]) / 60.0,
                self.params["n_cells"],
                self.params["n_exc"],
                self.params["n_inh"],
            )
            print "Proc %d Full pyNN run time: %d sec or %.1f min for %d cells (%d exc %d inh)" % (
                self.pc_id,
                self.times["t_all"],
                (self.times["t_all"]) / 60.0,
                self.params["n_cells"],
                self.params["n_exc"],
                self.params["n_inh"],
            )
            fn = utils.convert_to_url(params["folder_name"] + "times_dict_np%d.py" % self.n_proc)
            output = ntp.ParameterSet(output)
            output.save(fn)
Пример #2
0
 def get_parameter(self, param_name):
     """
     For all simulations (in self.dirs_to_process) get the according parameter value
     """
     for i_, folder in enumerate(self.dirs_to_process):
         param_fn = folder + '/Parameters/simulation_parameters.info'
         param_fn = utils.convert_to_url(param_fn)
         param_dict = NTP.ParameterSet(param_fn)
         value = param_dict[param_name]
         self.param_space[i_][param_name] = value
Пример #3
0
    def print_results(self, print_v=True):
        """
            # # # # # # # # # # # # # # # # #
            #   P R I N T    R E S U L T S  #
            # # # # # # # # # # # # # # # # #
        """
        if print_v:
            if self.pc_id == 0:
                print 'print_v to file: %s.v' % (self.params['exc_volt_fn_base'])
            self.exc_pop_view.print_v("%s.v" % (self.params['exc_volt_fn_base']), compatible_output=False)
            if self.pc_id == 0:
                print "Printing inhibitory membrane potentials"
            self.inh_pop_view.print_v("%s.v" % (self.params['inh_volt_fn_base']), compatible_output=False)

        print 'DEBUG printing anticipatory cells', self.anticipatory_record
        if self.anticipatory_record == True:   
            print 'print_v to file: %s' % (self.params['exc_volt_anticipation'])
            self.exc_pop_view_anticipation.print_v("%s" % (self.params['exc_volt_anticipation']), compatible_output=False)
            print 'print_gsyn to file: %s' % (self.params['exc_gsyn_anticipation'])
            self.exc_pop_view_anticipation.print_gsyn("%s" % (self.params['exc_gsyn_anticipation']), compatible_output=False)


        if self.pc_id == 0:
            print "Printing excitatory spikes"
        self.exc_pop.printSpikes(self.params['exc_spiketimes_fn_merged'] + '.ras')
        if self.pc_id == 0:
            print "Printing inhibitory spikes"
        self.inh_pop.printSpikes(self.params['inh_spiketimes_fn_merged'] + '.ras')

        self.times['t_print'] = self.timer.diff()
        if self.pc_id == 0:
            print "calling pyNN.end() ...."
        end()
        self.times['t_end'] = self.timer.diff()

        if self.pc_id == 0:
            self.times['t_all'] = 0.
            for k in self.times.keys():
                self.times['t_all'] += self.times[k]

            self.n_cells = {}
            self.n_cells['n_exc'] = self.params['n_exc']
            self.n_cells['n_inh'] = self.params['n_inh']
            self.n_cells['n_cells'] = self.params['n_cells']
            self.n_cells['n_proc'] = self.n_proc
            output = {'times' : self.times, 'n_cells_proc' : self.n_cells}
            print "Proc %d Simulation time: %d sec or %.1f min for %d cells (%d exc %d inh)" % (self.pc_id, self.times['t_sim'], (self.times['t_sim'])/60., self.params['n_cells'], self.params['n_exc'], self.params['n_inh'])
            print "Proc %d Full pyNN run time: %d sec or %.1f min for %d cells (%d exc %d inh)" % (self.pc_id, self.times['t_all'], (self.times['t_all'])/60., self.params['n_cells'], self.params['n_exc'], self.params['n_inh'])
            fn = utils.convert_to_url(params['folder_name'] + 'times_dict_np%d.py' % self.n_proc)
Пример #4
0
    def write_parameters_to_file(self, fn=None):
        if not (os.path.isdir(self.params['folder_name'])):
            print 'Creating folder:\n\t%s' % self.params['folder_name']
            self.create_folders()

        if fn == None:
            fn = self.params['params_fn']
        print 'Writing parameters to: %s' % (fn)

        self.ParamSet = ntp.ParameterSet(self.params)
        fn = utils.convert_to_url(fn)
        self.ParamSet.save(fn)

        output_file = file(self.params['params_fn_json'], 'w')
        d = json.dump(self.params, output_file)
Пример #5
0
    def print_results(self, print_v=True):
        """
            # # # # # # # # # # # # # # # # #
            #     P R I N T    R E S U L T S 
            # # # # # # # # # # # # # # # # #
        """
        if print_v:
            if self.pc_id == 0:
                print 'print_v to file: %s.v' % (self.params['exc_volt_fn_base'])
            self.exc_pop_view.print_v("%s.v" % (self.params['exc_volt_fn_base']), compatible_output=False)

        if self.pc_id == 0:
            print "Printing excitatory spikes"
        self.exc_pop.printSpikes(self.params['exc_spiketimes_fn_merged'] + '.ras')
        # print a dummy file for inhibitory
        np.savetxt(self.params['inh_spiketimes_fn_merged'] + '.ras', np.array([]))

        self.times['t_print'] = self.timer.diff()
        if self.pc_id == 0:
            print "calling pyNN.end() ...."
        end()
        self.times['t_end'] = self.timer.diff()

        if self.pc_id == 0:
            self.times['t_all'] = 0.
            for k in self.times.keys():
                self.times['t_all'] += self.times[k]

            self.n_cells = {}
            self.n_cells['n_exc'] = self.params['n_exc']
            self.n_cells['n_inh'] = self.params['n_inh']
            self.n_cells['n_cells'] = self.params['n_cells']
            self.n_cells['n_proc'] = self.n_proc
            output = {'times' : self.times, 'n_cells_proc' : self.n_cells}
            print "Proc %d Simulation time: %d sec or %.1f min for %d cells (%d exc %d inh)" % (self.pc_id, self.times['t_sim'], (self.times['t_sim'])/60., self.params['n_cells'], self.params['n_exc'], self.params['n_inh'])
            print "Proc %d Full pyNN run time: %d sec or %.1f min for %d cells (%d exc %d inh)" % (self.pc_id, self.times['t_all'], (self.times['t_all'])/60., self.params['n_cells'], self.params['n_exc'], self.params['n_inh'])
            fn = utils.convert_to_url(params['folder_name'] + 'times_dict_np%d.py' % self.n_proc)
            output = ntp.ParameterSet(output)
            output.save(fn)
Пример #6
0
import utils
import os
rcP= { 'axes.labelsize' : 24,
            'label.fontsize': 24,
            'xtick.labelsize' : 24, 
            'ytick.labelsize' : 24, 
            'axes.titlesize'  : 32,
            'legend.fontsize': 9}


if len(sys.argv) > 1:
    param_fn = sys.argv[1]
    if os.path.isdir(param_fn):
        param_fn += '/Parameters/simulation_parameters.info'
    import NeuroTools.parameters as NTP
    fn_as_url = utils.convert_to_url(param_fn)
    print 'Loading parameters from', param_fn
    params = NTP.ParameterSet(fn_as_url)

else:
    print '\nPlotting the default parameters given in simulation_parameters.py\n'
    import simulation_parameters
    network_params = simulation_parameters.parameter_storage()  # network_params class containing the simulation parameters
    params = network_params.load_params()                       # params stores cell numbers, etc as a dictionary


def plot_input_spikes(ax, shift=0, m='o', c='k', ms=2):
    """
    Shift could be used when plotting in the same axis as the output spikes
    """
    n_cells = params['n_exc']
Пример #7
0
    if len(sys.argv) > 1:
        if len(sys.argv[1]) == 2:
            conn_type = sys.argv[1]
            assert (conn_type in conn_types), 'Non-existant conn_type %s' % conn_type
            try:
                param_fn = sys.argv[2]
            except:
                network_params = simulation_parameters.parameter_storage()  # network_params class containing the simulation parameters
                params = network_params.load_params()                       # params stores cell numbers, etc as a dictionary
        else:
            param_fn = sys.argv[1]
            if os.path.isdir(param_fn):
                param_fn += '/Parameters/simulation_parameters.info'
            print 'Trying to load parameters from', param_fn
            import NeuroTools.parameters as NTP
            params = NTP.ParameterSet(utils.convert_to_url(param_fn))
    else:
        print '\nLoading the parameters currently in simulation_parameters.py\n'
        network_params = simulation_parameters.parameter_storage()  # network_params class containing the simulation parameters
        params = network_params.load_params()                       # params stores cell numbers, etc as a dictionary

    # get the connection type either from sys.argv[1] or [2]
    if conn_type == None:
        conn_types = ['ee', 'ei', 'ie', 'ii']
    else:
        conn_types = [conn_type]
    print 'Processing conn_types', conn_types
    CA = ConnectivityAnalyser(params, comm)


    def plot_outgoing_connections(conn_type):