def process_data(self):
        
        self.ap = [ np.zeros((0,4), dtype=np.uint) for i in range(2) ]
        self.noap = np.zeros((0,4), dtype=np.uint)

        for (path,dirs,files) in os.walk(self.srcfolder):
            for fn in files:
                if self.fnpattern in fn and fn[:1] != '.':
                    fp = os.path.join(path,fn)
                    print 'process file', fp

                    d = np.load(fp)
                    hhdata = d['hhdata']
                    w1 = d['w1']
                    w2 = d['w2']
                    w3 = d['w3']
                    d.close()

                    ap, noap = self.get_ap([w1,w2,w3], [850, 850+2344])
                    self.noap = np.vstack((self.noap, noap))
                    for i,a in enumerate(ap):
                        self.ap[i] = np.vstack((self.ap[i], a))

        np.savez(os.path.join(self.savefolder, 'clicks.npz'), noap=self.noap,
                ap1 = self.ap[0], ap2 = self.ap[1])
        np.savez(os.path.join(self.savefolder, 'click_times_ch1.npz'), 
                noap=hht3.get_click_times(self.noap)[1],
                ap1=hht3.get_click_times(self.ap[0])[1],
                ap2=hht3.get_click_times(self.ap[1])[1])
Esempio n. 2
0
    def process_data(self):
        
        self.ap = [ np.zeros((0,4), dtype=np.uint) for i in range(2) ]
        self.noap = np.zeros((0,4), dtype=np.uint)

        for (path,dirs,files) in os.walk(self.srcfolder):
            for fn in files:
                if self.fnpattern in fn and fn[:1] != '.':
                    fp = os.path.join(path,fn)
                    print 'process file', fp

                    d = np.load(fp)
                    hhdata = d['hhdata']
                    w1 = d['w1']
                    w2 = d['w2']
                    w3 = d['w3']
                    d.close()

                    ap, noap = self.get_ap([w1,w2,w3], [850, 850+2344])
                    self.noap = np.vstack((self.noap, noap))
                    for i,a in enumerate(ap):
                        self.ap[i] = np.vstack((self.ap[i], a))

        np.savez(os.path.join(self.savefolder, 'clicks.npz'), noap=self.noap,
                ap1 = self.ap[0], ap2 = self.ap[1])
        np.savez(os.path.join(self.savefolder, 'click_times_ch1.npz'), 
                noap=hht3.get_click_times(self.noap)[1],
                ap1=hht3.get_click_times(self.ap[0])[1],
                ap2=hht3.get_click_times(self.ap[1])[1])
    def count_histogram(self, ch=1, rng=(0,3*2400), bins=(3*40+1)):
        t_noap = hht3.get_click_times(self.noap)[ch]
        t_ap = [ hht3.get_click_times(ap)[ch] for ap in self.ap ]

        apcolors = ['r', 'b', 'g']
        aphatches = ['', '', '']
        aplabels = ['AP pulse 1', 'AP pulse 2', 'AP pulse 3']
        apalphas = [ 0.5, 0.5, 0.5 ]

        fig = plt.figure()
        ax = plt.subplot(111)
        
        ax.hist(t_noap, bins=bins, range=rng, log=True, label='no AP',
                color='w', hatch='/')
        
        for t,c,h,l,a in zip(t_ap, apcolors, aphatches, aplabels, apalphas):
            ax.hist(t, bins=bins, label=l, range=rng, color=c,
                    hatch=h, alpha=a)

        ax.legend()

        fig.savefig(os.path.join(self.savefolder, 'click_histogram.pdf'),
            format='pdf')

        return
Esempio n. 4
0
    def count_histogram(self, ch=1, rng=(0,3*2400), bins=(3*40+1)):
        t_noap = hht3.get_click_times(self.noap)[ch]
        t_ap = [ hht3.get_click_times(ap)[ch] for ap in self.ap ]

        apcolors = ['r', 'b', 'g']
        aphatches = ['', '', '']
        aplabels = ['AP pulse 1', 'AP pulse 2', 'AP pulse 3']
        apalphas = [ 0.5, 0.5, 0.5 ]

        fig = plt.figure()
        ax = plt.subplot(111)
        
        ax.hist(t_noap, bins=bins, range=rng, log=True, label='no AP',
                color='w', hatch='/')
        
        for t,c,h,l,a in zip(t_ap, apcolors, aphatches, aplabels, apalphas):
            ax.hist(t, bins=bins, label=l, range=rng, color=c,
                    hatch=h, alpha=a)

        ax.legend()

        fig.savefig(os.path.join(self.savefolder, 'click_histogram.pdf'),
            format='pdf')

        return