def animate(i): plt.cla() printprogress("animating frame", start + i * skip, recording.shape[2]) if i * skip < recording.shape[2]: nx.draw_networkx_edges(network, positions, edge_color='gray') nx.draw_networkx_nodes(network.subgraph(roinodes), positions, with_labels=False, node_size=70, node_color=[measured_color] * len(roinodes), linewidths=0) nx.draw_networkx_nodes(network, positions, with_labels=False, node_size=50, node_color=nodecolors(start + i * skip), linewidths=0) nx.draw_networkx_nodes(network.subgraph(inputnodes), positions, with_labels=False, node_size=7, node_color=[(0.8, 0, 0)] * len(inputnodes), linewidths=0) t = " ({}ms)".format( start + i * skip * ms_per_step) if ms_per_step is not None else "" plt.title(title + t, titlefont)
def animate(i): printprogress("animating frame",start+i*skip,data.shape[2]) if i*skip < data.shape[2]: picture.set_data(data[:,:,start+i*skip]) t = " {}ms".format(start+i*skip * ms_per_step) if ms_per_step is not None else "" plt.title(title+t,titlefont) return picture
def run(self): """Run all simulation trials & apply all measurements""" le = len(self.seeds) [meas.reset() for meas in self.measures.values()] for i, s in enumerate(self.seeds): printprogress('running "' + self.name + '", repetition ', i, le) voltage, spikes = self.getraw(i) for meas in self.measures.values(): meas.apply(voltage, spikes, verbose=self.verbose)
def compute_movingwindow(self, recording): """ run the measure repeatedly in a moving window. Args: recording: MxNxT numerical array, where M,N match the network's grid dimensions """ wl = self.wlength res = np.zeros(recording.shape[2] - wl) for step in range(len(res)): res[step] = self.compute(recording[:, :, step:step + wl]) printprogress("calc. moving window, step ", step, len(res)) return res
def compute_tilingwindow(self, recording): """ run the measure repeatedly in subsequent, nonoverlapping windows Args: recording: MxNxT numerical array, where M,N match the network's grid dimensions """ wl = self.wlength nrtiles = int(recording.shape[2] / wl) # floor via int() res = np.zeros(nrtiles) for tile in range(nrtiles): res[tile] = self.compute(recording[:, :, tile * wl:tile * wl + wl]) printprogress("calc. tiling window, no. ", tile, nrtiles) return res
def compute_growingwindow(self, recording): """ run the measure repeatedly in a growing window Args: recording: MxNxT numerical array, where M,N match the network's grid dimensions """ tr = self.wait ssz = self.grw_startsize usablesteps = recording.shape[2] - tr - ssz res = np.zeros(int(np.ceil(usablesteps / float(self.increment)))) for i, step in enumerate(range(0, usablesteps, self.increment)): res[i] = self.compute(recording[:, :, tr:tr + ssz + step]) printprogress("calc. growing window, step ", i, len(res)) return res