def plot_template_set2(self, show=False): """plot the template set in a waveform plot""" # get plotting tools try: from spikeplot import plt except ImportError: return None # checks if self.nf == 0: warnings.warn("skipping plot, no active units!") return None # init f = plt.figure() y_min, y_max = 0, 0 share = None for k, i in enumerate(self._idx_active_set): ax = f.add_subplot(self.nf, 1, k + 1, sharex=share, sharey=share) a, b = self.bank[i].plot_buffer_to_axis(axis=ax, idx=i) y_min = min(y_min, a) y_max = max(y_max, b) share = ax f.axes[0].set_ylim(y_min, y_max) if show is True: plt.show() return f
def test_visualize(): indata = open('C:\\Dev\\blockstream_runtimes\\test_file1_res.cove', 'rb').read() bh = BS3CoveBlockHeader.from_data(indata[38:40]) print bh.version, bh.block_type bk = BS3CoveDataBlock.from_data(bh, indata[40:]) print bk.data_lst from spikeplot import plt plt.matshow(bk.data_lst[-1]) plt.show()
def plot(self, data, views=2, show=False, filename=None): """plot clustering""" # get plotting tools try: from spikeplot import plt, cluster, save_figure except ImportError: return None # init views = min(views, int(data.shape[1] / 2)) fig = plt.figure() fig.suptitle('clustering [%s]' % self.clus_type) ax = [fig.add_subplot(2, views, v + 1) for v in xrange(views)] axg = fig.add_subplot(212) ncmp = int(self.labels.max() + 1) cdata = dict( zip(xrange(ncmp), [data[self.labels == c] for c in xrange(ncmp)])) # plot clustering for v in xrange(views): cluster(cdata, data_dim=(2 * v, 2 * v + 1), plot_handle=ax[v], plot_mean=sp.sqrt(self.sigma_factor), xlabel='PC %d' % int(2 * v), ylabel='PC %d' % int(2 * v + 1), show=False) # plot gof axg.plot(self._gof, ls='steps') for i in xrange(1, len(self.crange)): axg.axvline(i * self.repeats - 0.5, c='y', ls='--') axg.axvspan(self._winner - 0.5, self._winner + 0.5, fc='gray', alpha=0.2) labels = [] for k in self.crange: labels += ['%d' % k] labels += ['.'] * (self.repeats - 1) axg.set_xticks(sp.arange(len(labels))) axg.set_xticklabels(labels) axg.set_xlabel('cluster count and repeats') axg.set_ylabel(str(self.gof_type).upper()) axg.set_xlim(-1, len(labels)) # handle the resulting plot if filename is not None: save_figure(fig, filename, '') if show is True: plt.show() return True
def plot(self, data, views=2, show=False, filename=None): """plot clustering""" # get plotting tools try: from spikeplot import plt, cluster, save_figure except ImportError: return None # init views = min(views, int(data.shape[1] / 2)) fig = plt.figure() fig.suptitle('clustering [%s]' % self.clus_type) ax = [fig.add_subplot(2, views, v + 1) for v in xrange(views)] axg = fig.add_subplot(212) ncmp = int(self.labels.max() + 1) cdata = dict(zip(xrange(ncmp), [data[self.labels == c] for c in xrange(ncmp)])) # plot clustering for v in xrange(views): cluster( cdata, data_dim=(2 * v, 2 * v + 1), plot_handle=ax[v], plot_mean=sp.sqrt(self.sigma_factor), xlabel='PC %d' % int(2 * v), ylabel='PC %d' % int(2 * v + 1), show=False) # plot gof axg.plot(self._gof, ls='steps') for i in xrange(1, len(self.crange)): axg.axvline(i * self.repeats - 0.5, c='y', ls='--') axg.axvspan(self._winner - 0.5, self._winner + 0.5, fc='gray', alpha=0.2) labels = [] for k in self.crange: labels += ['%d' % k] labels += ['.'] * (self.repeats - 1) axg.set_xticks(sp.arange(len(labels))) axg.set_xticklabels(labels) axg.set_xlabel('cluster count and repeats') axg.set_ylabel(str(self.gof_type).upper()) axg.set_xlim(-1, len(labels)) # handle the resulting plot if filename is not None: save_figure(fig, filename, '') if show is True: plt.show() return True
def plot(self, show=False): """plot detection in mcdata plot""" try: from spikeplot import plt, mcdata, COLOURS except ImportError: return None fig = mcdata(self.data, other=self.energy, events={0: self.events}, show=False) for i, th in enumerate(self.threshold): fig.axes[-1].axhline(th, c=COLOURS[i % len(COLOURS)]) self._plot_additional(fig) if show is True: plt.show() return fig
def test(debug=True): from spikeplot import plt, mcdata # setup TF = 47 signal, noise, ce, temps = load_input_data(TF) FB = BOTMNode( templates=temps, ce=ce, adapt_templates=10, learn_noise=False, verbose=VERBOSE(debug * 10), ovlp_taus=None, chunk_size=500) x = sp.ascontiguousarray(signal + noise, dtype=sp.float32) # sort FB.plot_xvft() FB(x) FB.plot_sorting() print FB.rval plt.show()
try: import unittest2 as ut except ImportError: import unittest as ut from botmpy.common import mad_scaling from botmpy.common.datafile import XpdFile import scipy as sp try: from spikeplot import mcdata, plt WITH_PLOT = True except ImportError: WITH_PLOT = False if __name__ == '__main__': xpd = XpdFile('/home/pmeier/Data/Munk/Louis/L014/L0140001.xpd') data = xpd.get_data(item=1) if WITH_PLOT: mcdata(data, show=False) data_scaled, scale = mad_scaling(data) if WITH_PLOT: mcdata(data_scaled, show=False) print 'magic eq', sp.stats.norm.ppf(0.75) print 'STD:', sp.std(data, 0), sp.std(data_scaled, 0) if WITH_PLOT: plt.show()
def test_visualize_block(block): from spikeplot import plt plt.matshow(block.data_lst[-2]) plt.matshow(block.data_lst[-1]) plt.show()