def ifr_sp_corr(self, x1, speed, minSpeed=2.0, maxSpeed=40.0, sigma=3, shuffle=False, nShuffles=100, minTime=30, plot=False):
    '\n        x1 : np.array\n            The indices of pos at which the cluster fired\n        speed: np.array (1 x nSamples)\n            instantaneous speed\n        minSpeed: int\n            speeds below this value are ignored - defaults to 2cm/s as with\n            Kropff et al., 2015\n        '
    speed = speed.ravel()
    posSampRate = 50
    nSamples = len(speed)
    spk_hist = np.bincount(x1, minlength=nSamples)
    h = signal.gaussian(13, sigma)
    h = (h / float(np.sum(h)))
    lowSpeedIdx = (speed < minSpeed)
    highSpeedIdx = (speed > maxSpeed)
    speed_filt = speed[(~ np.logical_or(lowSpeedIdx, highSpeedIdx))]
    spk_hist_filt = spk_hist[(~ np.logical_or(lowSpeedIdx, highSpeedIdx))]
    spk_sm = signal.filtfilt(h.ravel(), 1, spk_hist_filt)
    sm_spk_rate = (spk_sm * posSampRate)
    res = stats.pearsonr(sm_spk_rate, speed_filt)
    if plot:
        (_, sp_bin_edges) = np.histogram(speed_filt, bins=50)
        sp_dig = np.digitize(speed_filt, sp_bin_edges, right=True)
        spks_per_sp_bin = [spk_hist_filt[(sp_dig == i)] for i in range(len(sp_bin_edges))]
        rate_per_sp_bin = []
        for x in spks_per_sp_bin:
            rate_per_sp_bin.append((np.mean(x) * posSampRate))
        rate_filter = signal.gaussian(5, 1.0)
        rate_filter = (rate_filter / np.sum(rate_filter))
        binned_spk_rate = signal.filtfilt(rate_filter, 1, rate_per_sp_bin)
        spk_binning_edges = np.linspace(np.min(sm_spk_rate), np.max(sm_spk_rate), len(sp_bin_edges))
        (speed_mesh, spk_mesh) = np.meshgrid(sp_bin_edges, spk_binning_edges)
        (binned_rate, _, _) = np.histogram2d(speed_filt, sm_spk_rate, bins=[sp_bin_edges, spk_binning_edges])
        from ephysiopy.common.utils import blurImage
        sm_binned_rate = blurImage(binned_rate, 5)
        fig = plt.figure()
        ax = fig.add_subplot(111)
        from matplotlib.colors import LogNorm
        speed_mesh = speed_mesh[:(- 1), :(- 1)]
        spk_mesh = spk_mesh[:(- 1), :(- 1)]
        ax.pcolormesh(speed_mesh, spk_mesh, sm_binned_rate, norm=LogNorm(), alpha=0.5, shading='nearest', edgecolors='None')
        ax.plot(sp_bin_edges, binned_spk_rate, 'r')
        lr = stats.linregress(speed_filt, sm_spk_rate)
        end_point = (lr.intercept + ((sp_bin_edges[(- 1)] - sp_bin_edges[0]) * lr.slope))
        ax.plot([np.min(sp_bin_edges), np.max(sp_bin_edges)], [lr.intercept, end_point], 'r--')
        ax.set_xlim(np.min(sp_bin_edges), np.max(sp_bin_edges[(- 2)]))
        ax.set_ylim(0, (np.nanmax(binned_spk_rate) * 1.1))
        ax.set_ylabel('Firing rate(Hz)')
        ax.set_xlabel('Running speed(cm/s)')
        ax.set_title('Intercept: {0:.3f}   Slope: {1:.5f}\nPearson: {2:.5f}'.format(lr.intercept, lr.slope, lr.rvalue))
    if shuffle:
        timeSteps = np.random.randint((30 * posSampRate), (nSamples - (30 * posSampRate)), nShuffles)
        shuffled_results = []
        for t in timeSteps:
            spk_count = np.roll(spk_hist, t)
            spk_count_filt = spk_count[(~ lowSpeedIdx)]
            spk_count_sm = signal.filtfilt(h.ravel(), 1, spk_count_filt)
            shuffled_results.append(stats.pearsonr(spk_count_sm, speed_filt)[0])
        if plot:
            fig = plt.figure()
            ax = fig.add_subplot(1, 1, 1)
            ax.hist(np.abs(shuffled_results), 20)
            ylims = ax.get_ylim()
            ax.vlines(res, ylims[0], ylims[1], 'r')
    if isinstance(fig, plt.Figure):
        return fig
x1 : np.array
    The indices of pos at which the cluster fired
speed: np.array (1 x nSamples)
    instantaneous speed
minSpeed: int
    speeds below this value are ignored - defaults to 2cm/s as with
    Kropff et al., 2015
def ifr_sp_corr(self, x1, speed, minSpeed=2.0, maxSpeed=40.0, sigma=3, shuffle=False, nShuffles=100, minTime=30, plot=False):
    '\n        x1 : np.array\n            The indices of pos at which the cluster fired\n        speed: np.array (1 x nSamples)\n            instantaneous speed\n        minSpeed: int\n            speeds below this value are ignored - defaults to 2cm/s as with\n            Kropff et al., 2015\n        '
    speed = speed.ravel()
    posSampRate = 50
    nSamples = len(speed)
    spk_hist = np.bincount(x1, minlength=nSamples)
    h = signal.gaussian(13, sigma)
    h = (h / float(np.sum(h)))
    lowSpeedIdx = (speed < minSpeed)
    highSpeedIdx = (speed > maxSpeed)
    speed_filt = speed[(~ np.logical_or(lowSpeedIdx, highSpeedIdx))]
    spk_hist_filt = spk_hist[(~ np.logical_or(lowSpeedIdx, highSpeedIdx))]
    spk_sm = signal.filtfilt(h.ravel(), 1, spk_hist_filt)
    sm_spk_rate = (spk_sm * posSampRate)
    res = stats.pearsonr(sm_spk_rate, speed_filt)
    if plot:
        (_, sp_bin_edges) = np.histogram(speed_filt, bins=50)
        sp_dig = np.digitize(speed_filt, sp_bin_edges, right=True)
        spks_per_sp_bin = [spk_hist_filt[(sp_dig == i)] for i in range(len(sp_bin_edges))]
        rate_per_sp_bin = []
        for x in spks_per_sp_bin:
            rate_per_sp_bin.append((np.mean(x) * posSampRate))
        rate_filter = signal.gaussian(5, 1.0)
        rate_filter = (rate_filter / np.sum(rate_filter))
        binned_spk_rate = signal.filtfilt(rate_filter, 1, rate_per_sp_bin)
        spk_binning_edges = np.linspace(np.min(sm_spk_rate), np.max(sm_spk_rate), len(sp_bin_edges))
        (speed_mesh, spk_mesh) = np.meshgrid(sp_bin_edges, spk_binning_edges)
        (binned_rate, _, _) = np.histogram2d(speed_filt, sm_spk_rate, bins=[sp_bin_edges, spk_binning_edges])
        from ephysiopy.common.utils import blurImage
        sm_binned_rate = blurImage(binned_rate, 5)
        fig = plt.figure()
        ax = fig.add_subplot(111)
        from matplotlib.colors import LogNorm
        speed_mesh = speed_mesh[:(- 1), :(- 1)]
        spk_mesh = spk_mesh[:(- 1), :(- 1)]
        ax.pcolormesh(speed_mesh, spk_mesh, sm_binned_rate, norm=LogNorm(), alpha=0.5, shading='nearest', edgecolors='None')
        ax.plot(sp_bin_edges, binned_spk_rate, 'r')
        lr = stats.linregress(speed_filt, sm_spk_rate)
        end_point = (lr.intercept + ((sp_bin_edges[(- 1)] - sp_bin_edges[0]) * lr.slope))
        ax.plot([np.min(sp_bin_edges), np.max(sp_bin_edges)], [lr.intercept, end_point], 'r--')
        ax.set_xlim(np.min(sp_bin_edges), np.max(sp_bin_edges[(- 2)]))
        ax.set_ylim(0, (np.nanmax(binned_spk_rate) * 1.1))
        ax.set_ylabel('Firing rate(Hz)')
        ax.set_xlabel('Running speed(cm/s)')
        ax.set_title('Intercept: {0:.3f}   Slope: {1:.5f}\nPearson: {2:.5f}'.format(lr.intercept, lr.slope, lr.rvalue))
    if shuffle:
        timeSteps = np.random.randint((30 * posSampRate), (nSamples - (30 * posSampRate)), nShuffles)
        shuffled_results = []
        for t in timeSteps:
            spk_count = np.roll(spk_hist, t)
            spk_count_filt = spk_count[(~ lowSpeedIdx)]
            spk_count_sm = signal.filtfilt(h.ravel(), 1, spk_count_filt)
            shuffled_results.append(stats.pearsonr(spk_count_sm, speed_filt)[0])
        if plot:
            fig = plt.figure()
            ax = fig.add_subplot(1, 1, 1)
            ax.hist(np.abs(shuffled_results), 20)
            ylims = ax.get_ylim()
            ax.vlines(res, ylims[0], ylims[1], 'r')
    if isinstance(fig, plt.Figure):
        return fig