Esempio n. 1
0
    def evaluate(self, raster_plot_interval, firing_rates_interval):
        """ Displays simulation results.

        Creates a spike raster plot.
        Calculates the firing rate of each population and displays them as a
        box plot.

        Parameters
        ----------
        raster_plot_interval
            Times (in ms) to start and stop loading spike times for raster plot
            (included).
        firing_rates_interval
            Times (in ms) to start and stop lading spike times for computing
            firing rates (included).

        Returns
        -------
            None

        """
        if nest.Rank() == 0:
            print(
                'Interval to plot spikes: {} ms'.format(raster_plot_interval))
            helpers.plot_raster(self.data_path, 'spike_recorder',
                                raster_plot_interval[0],
                                raster_plot_interval[1],
                                self.net_dict['N_scaling'])

            print('Interval to compute firing rates: {} ms'.format(
                firing_rates_interval))
            helpers.firing_rates(self.data_path, 'spike_recorder',
                                 firing_rates_interval[0],
                                 firing_rates_interval[1])
            helpers.boxplot(self.data_path, self.net_dict['populations'])
Esempio n. 2
0
    def evaluate(self, raster_plot_time_idx, fire_rate_time_idx):
        """ Displays output of the simulation.

        Calculates the firing rate of each population,
        creates a spike raster plot and a box plot of the
        firing rates.

        """
        if nest.Rank() == 0:
            print(
                'Interval to compute firing rates: %s ms'
                % np.array2string(fire_rate_time_idx)
                )
            fire_rate(
                self.data_path, 'spike_detector',
                fire_rate_time_idx[0], fire_rate_time_idx[1]
                )
            print(
                'Interval to plot spikes: %s ms'
                % np.array2string(raster_plot_time_idx)
                )
            plot_raster(
                self.data_path, 'spike_detector',
                raster_plot_time_idx[0], raster_plot_time_idx[1]
                )
            boxplot(self.net_dict, self.data_path)
Esempio n. 3
0
    def evaluate(self, raster_plot_interval, firing_rates_interval):
        """ Displays simulation results.

        Creates a spike raster plot.
        Calculates the firing rate of each population and displays them as a
        box plot.

        Parameters
        ----------
        raster_plot_interval
            Times (in ms) to start and stop loading spike times for raster plot
            (included).
        firing_rates_interval
            Times (in ms) to start and stop lading spike times for computing
            firing rates (included).

        Returns
        -------
            None

        """

        for i_pop in range(len(self.pops)):
            population = self.pops[i_pop]
            data = []
            for i_neur in range(len(population)):
                spike_times = ngpu.GetRecSpikeTimes(population[i_neur])
                if (len(spike_times) != 0):
                    # print("i_pop:", i_pop, " i_neur:", i_neur, " n_spikes:",
                    #      len(spike_times))
                    for t in spike_times:
                        data.append([population[i_neur], t])
            arr = np.array(data)
            fn = os.path.join(self.data_path,
                              'spike_times_' + str(i_pop) + '.dat')
            fmt = '%d\t%.3f'
            np.savetxt(fn, arr, fmt=fmt, header="sender time_ms", comments='')
        if self.Rank == 0:
            print(
                'Interval to plot spikes: {} ms'.format(raster_plot_interval))
            helpers.plot_raster(self.data_path, 'spike_detector',
                                raster_plot_interval[0],
                                raster_plot_interval[1],
                                self.net_dict['N_scaling'])

            print('Interval to compute firing rates: {} ms'.format(
                firing_rates_interval))
            helpers.firing_rates(self.data_path, 'spike_detector',
                                 firing_rates_interval[0],
                                 firing_rates_interval[1])
            helpers.boxplot(self.data_path, self.net_dict['populations'])