Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] instantaneous_rate outputs a signal of one point less length #374

Closed
dizcza opened this issue Nov 2, 2020 · 0 comments
Closed

[Bug] instantaneous_rate outputs a signal of one point less length #374

dizcza opened this issue Nov 2, 2020 · 0 comments
Assignees
Labels
bug Indicates an unexpected problem or unintended behavior
Milestone

Comments

@dizcza
Copy link
Member

dizcza commented Nov 2, 2020

Originally found in #362

import matplotlib.pyplot as plt
import numpy as np
import quantities as pq

from elephant import statistics, kernels
from elephant.spike_train_generation import homogeneous_poisson_process

np.random.seed(0)
spiketrain = homogeneous_poisson_process(rate=10 * pq.Hz,
                                         t_stop=10 * pq.s)
kernel = kernels.GaussianKernel(sigma=300 * pq.ms)
sampling_period = 445 * pq.ms
rate = statistics.instantaneous_rate(
    spiketrain,
    sampling_period=sampling_period,
    kernel=kernel, center_kernel=True, trim=False)

plt.plot(rate.times.simplified.magnitude, rate.magnitude, color='orange',
         label='instantaneous rate')
plt.eventplot(
    [spiketrain.simplified.magnitude, rate.times.simplified.magnitude],
    colors=['black', 'green'], lineoffsets=2, linelengths=1)
plt.legend()
plt.title(f"{kernel.__class__.__name__}: sigma={int(kernel.sigma.item())} ms, "
          f"sampling_period={int(sampling_period.item())} ms")
plt.show()

sampling_period-445

On the plot above, the green stripes denote rate.times, which lacks one point before the t_stop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

3 participants