Exemplo n.º 1
0
    def makeHDPlot(self, spk_times: np.array = None,
                   ax: matplotlib.axes = None, **kwargs) -> matplotlib.axes:
        self.initialise()
        spk_times_in_pos_samples = self.getSpikePosIndices(spk_times)
        spk_weights = np.bincount(
            spk_times_in_pos_samples, minlength=self.npos)
        rmap = self.RateMapMaker.getMap(spk_weights, 'dir')
        if ax is None:
            fig = plt.figure()
            ax = fig.add_subplot(111, projection='polar')
        # need to deal with the case where the axis is supplied but
        # is not polar. deal with polar first
        theta = np.deg2rad(rmap[1][0])
        ax.clear()
        r = rmap[0]
        r = np.insert(r, -1, r[0])
        if 'polar' in ax.name:
            ax.plot(theta, r)
            if 'fill' in kwargs:
                ax.fill(theta, r, alpha=0.5)
            ax.set_aspect('equal')
        else:
            pass

        # See if we should add the mean resultant vector (mrv)
        if 'add_mrv' in kwargs:
            from ephysiopy.common.statscalcs import mean_resultant_vector
            angles = self.dir[spk_times_in_pos_samples]
            r, th = mean_resultant_vector(np.deg2rad(angles))
            ax.plot([th, th], [0, r*np.max(rmap[0])], 'r')
        if 'polar' in ax.name:
            ax.set_thetagrids([0, 90, 180, 270])
        return ax
Exemplo n.º 2
0
def force_aspect(ax: mpl.axes, aspect: int = 1):
    '''
    Forces the aspect of the axes object `ax`.
    '''
    im = ax.get_images()
    extent = im[0].get_extent()
    ax.set_aspect(
        abs((extent[1] - extent[0]) / (extent[3] - extent[2])) / aspect)
Exemplo n.º 3
0
 def makeRateMap(self, spk_times: np.array,
                 ax: matplotlib.axes = None) -> matplotlib.axes:
     self.initialise()
     spk_times_in_pos_samples = self.getSpikePosIndices(spk_times)
     spk_weights = np.bincount(
         spk_times_in_pos_samples, minlength=self.npos)
     rmap = self.RateMapMaker.getMap(spk_weights)
     ratemap = np.ma.MaskedArray(rmap[0], np.isnan(rmap[0]), copy=True)
     x, y = np.meshgrid(rmap[1][1][0:-1], rmap[1][0][0:-1])
     vmax = np.nanmax(np.ravel(ratemap))
     if ax is None:
         fig = plt.figure()
         ax = fig.add_subplot(111)
     ax.pcolormesh(
         x, y, ratemap, cmap=plt.cm.get_cmap("jet"), edgecolors='face',
         vmax=vmax, shading='auto')
     ax.set_aspect('equal')
     return ax
Exemplo n.º 4
0
 def makeSpikePathPlot(self, spk_times: np.array = None,
                       ax: matplotlib.axes = None,
                       **kwargs) -> matplotlib.axes:
     self.initialise()
     if 'c' in kwargs:
         col = kwargs.pop('c')
     else:
         col = tcols.colours[1]
     if ax is None:
         fig = plt.figure()
         ax = fig.add_subplot(111)
     ax.plot(self.xy[0, :], self.xy[1, :], c=tcols.colours[0], zorder=1)
     ax.set_aspect('equal')
     if spk_times is not None:
         idx = self.getSpikePosIndices(spk_times)
         ax.plot(
             self.xy[0, idx], self.xy[1, idx], 's', c=col, **kwargs)
     return ax