Esempio n. 1
0
    def crosscorrs(self, clusters=None, bin_width=0.0015, limit=0.03, 
                         figsize=(9,5)):
        """ Plots of cross-correlations of clustered spike times. """

        times = self.clusters.select(clusters).times()
        colors = plt.get_colors(max(self.clusters.keys()) + 1, self.cm)
        
        # Set the number of rows and columns to plot
        n_rows, n_cols = [len(times)]*2
        fig, axes = plt.generate_crosscorr_axes(n_rows, n_cols, num=4,
                                                figsize=figsize)
        
        for (ii, jj) in axes:
            ax = axes[(ii,jj)]
            cl1, cl2 = times.keys()[ii], times.keys()[jj]
            t1, t2 = times[cl1], times[cl2]
            # Get the cross-correlation for different clusters
            if ii != jj:
                plt.crosscorr(t1, t2, ax=ax, bin_width=bin_width, limit=limit)
                ax.set_xticklabels('')
                ax.set_yticklabels('')
            
            # If cluster 1 is the same as cluster 2, get the autocorrelation
            else:
                plt.autocorr(t1, ax=ax, color=colors[cl1],
                                 bin_width=bin_width, limit=limit)
                ax.set_ylabel('{}'.format(cl1))
                ax.set_xticklabels('')
                ax.set_yticklabels('')
        
        return fig
Esempio n. 2
0
    def autocorrs(self, clusters=None, bin_width=0.0015, limit=0.03, 
                        figsize=None):
        """ Plots of autocorrelations of clustered spike times.

            **Keywords**:
                *clusters*: list or iterable
                 List of clusters to plot
                *bin_width*: float
                 Width of bins in the autocorrelation calculation
                *limit*: float
                 Time limit over which to calculate the autocorrelation
        """
        
        cls = self.clusters.select(clusters)
        cl_times = cls.times()
        colors = plt.get_colors(max(self.clusters.keys()) + 1, self.cm)

        fig, axes = plt.generate_axes(len(cls), 4, num=3, figsize=figsize,
                                      sharex=True)
        for ax, cl in zip(axes, cl_times):
            ax.clear()
            tstamps = cl_times[cl]
            plt.autocorr(tstamps, ax=ax, color=colors[cl], 
                         bin_width=bin_width, limit=limit)
            ax.set_title('Cluster {}'.format(cl))
            ax.set_xlabel('Lag (ms)')
        
        fig.tight_layout()
        
        return fig
Esempio n. 3
0
    def crosscorrs(self,
                   clusters=None,
                   bin_width=0.0015,
                   limit=0.03,
                   figsize=(9, 5)):
        """ Plots of cross-correlations of clustered spike times. """

        times = self.clusters.select(clusters).times()
        colors = plt.get_colors(max(self.clusters.keys()) + 1, self.cm)

        # Set the number of rows and columns to plot
        n_rows, n_cols = [len(times)] * 2
        fig, axes = plt.generate_crosscorr_axes(n_rows,
                                                n_cols,
                                                num=4,
                                                figsize=figsize)

        for (ii, jj) in axes:
            ax = axes[(ii, jj)]
            cl1, cl2 = times.keys()[ii], times.keys()[jj]
            t1, t2 = times[cl1], times[cl2]
            # Get the cross-correlation for different clusters
            if ii != jj:
                plt.crosscorr(t1, t2, ax=ax, bin_width=bin_width, limit=limit)
                ax.set_xticklabels('')
                ax.set_yticklabels('')

            # If cluster 1 is the same as cluster 2, get the autocorrelation
            else:
                plt.autocorr(t1,
                             ax=ax,
                             color=colors[cl1],
                             bin_width=bin_width,
                             limit=limit)
                ax.set_ylabel('{}'.format(cl1))
                ax.set_xticklabels('')
                ax.set_yticklabels('')

        return fig
Esempio n. 4
0
    def autocorrs(self,
                  clusters=None,
                  bin_width=0.0015,
                  limit=0.03,
                  figsize=None):
        """ Plots of autocorrelations of clustered spike times.

            **Keywords**:
                *clusters*: list or iterable
                 List of clusters to plot
                *bin_width*: float
                 Width of bins in the autocorrelation calculation
                *limit*: float
                 Time limit over which to calculate the autocorrelation
        """

        cls = self.clusters.select(clusters)
        cl_times = cls.times()
        colors = plt.get_colors(max(self.clusters.keys()) + 1, self.cm)

        fig, axes = plt.generate_axes(len(cls),
                                      4,
                                      num=3,
                                      figsize=figsize,
                                      sharex=True)
        for ax, cl in zip(axes, cl_times):
            ax.clear()
            tstamps = cl_times[cl]
            plt.autocorr(tstamps,
                         ax=ax,
                         color=colors[cl],
                         bin_width=bin_width,
                         limit=limit)
            ax.set_title('Cluster {}'.format(cl))
            ax.set_xlabel('Lag (ms)')

        fig.tight_layout()

        return fig