def scatterDiff(self, i, plot = True): s, t = nh.getEventsFromSpikeDetector(self.sd_list[i], [self.last_sim_time, self.sim_time]) data = np.array([np.floor(t-self.last_sim_time).astype(int), s]) data = data.transpose() data = data.tolist() overlap = 0 newones = 0 for item in data: if item in self.scattDiff: if plot: mp.scatter(item[0], item[1], c='b') overlap += 1 else: if plot: mp.scatter(item[0], item[1], c='r') newones += 1 if plot: for item in self.scattDiff: if not item in data: mp.scatter(item[0], item[1], c='r') mp.xlim(0, 50) if len(self.scattDiff)==0: self.scattDiff = data overlap = len(data) newones = 0 return overlap, newones
def scatterDiff(self, i, plot=True): s, t = nh.getEventsFromSpikeDetector( self.sd_list[i], [self.last_sim_time, self.sim_time]) data = np.array([np.floor(t - self.last_sim_time).astype(int), s]) data = data.transpose() data = data.tolist() overlap = 0 newones = 0 for item in data: if item in self.scattDiff: if plot: mp.scatter(item[0], item[1], c='b') overlap += 1 else: if plot: mp.scatter(item[0], item[1], c='r') newones += 1 if plot: for item in self.scattDiff: if not item in data: mp.scatter(item[0], item[1], c='r') mp.xlim(0, 50) if len(self.scattDiff) == 0: self.scattDiff = data overlap = len(data) newones = 0 return overlap, newones
def scatterSD(self, i, color): """ create a scatter plot for a given spikedetector-index for the last simulation. color refers to the color-code """ s, t = nh.getEventsFromSpikeDetector(self.sd_list[i], [self.last_sim_time, self.sim_time]) mp.figure() mp.scatter(t-self.last_sim_time, s, c=color)
def scatterSD(self, i, color): """ create a scatter plot for a given spikedetector-index for the last simulation. color refers to the color-code """ s, t = nh.getEventsFromSpikeDetector( self.sd_list[i], [self.last_sim_time, self.sim_time]) mp.figure() mp.scatter(t - self.last_sim_time, s, c=color)
def exportSpikes(self,t_range=[0, float("Inf")]): """ Exports data from a list of spike detector ids for a given time range (t_range) in CSV format into zip folder containing delay CSVs for Blender""" with zipfile.ZipFile(self.output_prefix, 'a') as zf: matrix = [] for index, sd in enumerate(self.sd_list): sender, times = nh.getEventsFromSpikeDetector(sd, t_range) for i in range(len(sender)): matrix.append([index, sender[i] - self.ngs[index][0], times[i]]) pam2nest.csv_write_matrix(zf, 'spikes', matrix)
def getWeightsSpiking(self, sd, post = 4, target = (0,25)): ''' Returns the connection weights between neurons of the pre-synaptic layer, that fire (given by a spike-detector) and that are connected with specific neurons in the post-synaptic layer ''' # get spiking neurons s, t = nh.getEventsFromSpikeDetector(sd) # create unique spiking neuron-ids su = np.unique(s) connections = nest.GetConnections(su.tolist(), self.ngs[post][target[0]:target[1]]) weights = nest.GetStatus(connections, 'weight') targets = nest.GetStatus(connections, 'target') return weights, su, targets
def getSpikeOnsetTimes(self, spike_take = 4): """ returns the occurence of the first spike in each area for the last simulation """ data = [] for o in self.order: s, t = nh.getEventsFromSpikeDetector(self.sd_list[o], t_range=[self.last_sim_time, self.sim_time]) if len(t) >= spike_take: data.append(t[spike_take-1]) else: data.append(-1) return np.array(data)
def getSpikeOnsetTimes(self, spike_take=4): """ returns the occurence of the first spike in each area for the last simulation """ data = [] for o in self.order: s, t = nh.getEventsFromSpikeDetector( self.sd_list[o], t_range=[self.last_sim_time, self.sim_time]) if len(t) >= spike_take: data.append(t[spike_take - 1]) else: data.append(-1) return np.array(data)
def exportSpikes(self, t_range=[0, float("Inf")]): """ Exports data from a list of spike detector ids for a given time range (t_range) in CSV format into zip folder containing delay CSVs for Blender""" with zipfile.ZipFile(self.output_prefix, 'a') as zf: matrix = [] for index, sd in enumerate(self.sd_list): sender, times = nh.getEventsFromSpikeDetector(sd, t_range) for i in range(len(sender)): matrix.append( [index, sender[i] - self.ngs[index][0], times[i]]) pam2nest.csv_write_matrix(zf, 'spikes', matrix)
def getWeightsSpiking(self, sd, post=4, target=(0, 25)): ''' Returns the connection weights between neurons of the pre-synaptic layer, that fire (given by a spike-detector) and that are connected with specific neurons in the post-synaptic layer ''' # get spiking neurons s, t = nh.getEventsFromSpikeDetector(sd) # create unique spiking neuron-ids su = np.unique(s) connections = nest.GetConnections(su.tolist(), self.ngs[post][target[0]:target[1]]) weights = nest.GetStatus(connections, 'weight') targets = nest.GetStatus(connections, 'target') return weights, su, targets
def getSpikeHistogramRange(self, bins, time_range, plot=True, stretch = 3): """ Get histogram of spikes for a given time_range [x,y]""" data = [] for o in self.order: s, t = nh.getEventsFromSpikeDetector(self.sd_list[o], t_range=time_range) for _ in range(stretch): data.append(np.histogram(t, bins, range = time_range)[0]) if plot: mp.figure() mp.imshow(data, vmin = 0, vmax = 50, interpolation='none') mp.title('Temporal spike evolution') mp.xlabel('ms') return np.array(data)
def getSpikeHistogram(self, bins, plot=True, stretch = 3): """Creates a histogram of spikes with bins as ms""" data = [] for o in self.order: s, t = nh.getEventsFromSpikeDetector(self.sd_list[o], t_range=[self.last_sim_time, self.sim_time]) for _ in range(stretch): data.append(np.histogram(t, bins, range = [self.last_sim_time, self.sim_time])[0]) if plot: mp.figure() mp.imshow(data, vmin = 0, vmax = 50, interpolation='none') mp.title('Temporal spike evolution') mp.xlabel('ms') return np.array(data)
def getSpikeHistogramRange(self, bins, time_range, plot=True, stretch=3): """ Get histogram of spikes for a given time_range [x,y]""" data = [] for o in self.order: s, t = nh.getEventsFromSpikeDetector(self.sd_list[o], t_range=time_range) for _ in range(stretch): data.append(np.histogram(t, bins, range=time_range)[0]) if plot: mp.figure() mp.imshow(data, vmin=0, vmax=50, interpolation='none') mp.title('Temporal spike evolution') mp.xlabel('ms') return np.array(data)
def getSpikeHistogram(self, bins, plot=True, stretch=3): """Creates a histogram of spikes with bins as ms""" data = [] for o in self.order: s, t = nh.getEventsFromSpikeDetector( self.sd_list[o], t_range=[self.last_sim_time, self.sim_time]) for _ in range(stretch): data.append( np.histogram(t, bins, range=[self.last_sim_time, self.sim_time])[0]) if plot: mp.figure() mp.imshow(data, vmin=0, vmax=50, interpolation='none') mp.title('Temporal spike evolution') mp.xlabel('ms') return np.array(data)