Exemplo n.º 1
0
    def spike_patterns(self, cell):
        """Show distribution and PSTH of spike patterns.
        
        Requires selection of spike windows in the Event Selector.
        """
        
        dataset, cl = self._get_patterns(cell)
        ev = self._get_events(cell)
        spt = dataset['spt']
        stim = dataset['stim']
        
        plt.figure()
        plt.subplot(211)
        bins = np.arange(cl.min(), cl.max()+2)
        n, _ = np.histogram(cl, bins)
        n = n*1./np.sum(n)
        bins = bins[:-1]
        w = 0.8
        plt.bar(bins, n, width=w, fc='none')
        ndigits = int(np.ceil(np.log2(cl.max())))
        labels = map(lambda x: self._dec2binstr(x, ndigits), bins)
        plt.xticks(bins+w/2, labels)
        plt.xlabel('spike patterns')
        plt.ylabel('frequency')

        ax=plt.subplot(212)
        for i in np.unique(cl):
            basic.plotPSTH(spt, stim[cl==i], rate=True, 
                           label=self._dec2binstr(i, ndigits))
        trans = blended_transform_factory(ax.transData, ax.transAxes)
        plt.vlines(ev, 0, 1, transform=trans)
        plt.legend(prop=dict(size=8))
Exemplo n.º 2
0
spike_src = "/Gollum/s44gollum07/el3/cell1"
background_src = "/Gollum/s44gollum01/el4"
sp_win = [-2, 2]
pow_frac = 5
out_dataset = "/TestSubject/sSession01/el1"


if __name__ == "__main__":
    in_filter = filters.BakerlabFilter("../data/gollum.inf")
    out_filter = filters.PyTablesFilter("simulated.h5")

    sp_sim, stim_bg, spt_sim = eval.mix_cellbg(in_filter, spike_src,
                                               background_src,
                                              sp_win, pow_frac) 
    #export
    out_filter.write_spt(spt_sim, out_dataset+"/cell1_orig",
                        overwrite=True)
    out_filter.write_spt(stim_bg,out_dataset+ "stim",
                        overwrite=True)
    out_filter.write_sp(sp_sim, out_dataset+"/raw",
                       overwrite=True)
   
    #plotting
    print "Total spikes: ", len(spt_sim['data'])
    raw_bg, _ = eval.read_data(in_filter, background_src)
    basic.plotPSTH(spt_sim['data'], stim_bg['data'], win=[0,300])
    plt.figure()
    plt.plot(raw_bg['data'][0,:25E3])
    plt.plot(sp_sim['data'][0,:25E3])
    plt.show()