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

Raster Plot for spiking activity #362

Open
2 of 8 tasks
ackurth-nc opened this issue Sep 22, 2022 · 0 comments
Open
2 of 8 tasks

Raster Plot for spiking activity #362

ackurth-nc opened this issue Sep 22, 2022 · 0 comments
Assignees
Labels
0-needs-review For all new issues 1-feature New feature request

Comments

@ackurth-nc
Copy link
Contributor

ackurth-nc commented Sep 22, 2022

Lava version:

  • 0.5.0 (feature release)
  • 0.4.1 (bug fixes)
  • 0.4.0 (current version)
  • 0.3.0
  • 0.1.2

I'm submitting a ...

  • bug report
  • feature request
  • documentation request

Feature request:
Function to plot spiking activity of raster plot akin to one implemented in #309.
Integrating this function into Lava directly suggested by @mathisrichter in discussion of #309.

def raster_plot(spks, stride=6, fig=None, color='b', alpha=1):
    """Generate raster plot of spiking activity.
    
    Parameters
    ----------
    
    spks : np.ndarray shape (num_neurons, timesteps)
        Spiking activity of neurons, a spike is indicated by a one    
    stride : int
        Stride for plotting neurons
    """
    num_time_steps = spks.shape[1]
    assert stride < num_time_steps, "Stride must be smaller than number of time steps"
    
    time_steps = np.arange(0, num_time_steps, 1)
    if fig is None:
        fig = plt.figure(figsize=(10,5))
    timesteps = spks.shape[1]
    
    plt.xlim(-1, num_time_steps)
    plt.yticks([])
    
    plt.xlabel('Time steps')
    plt.ylabel('Neurons')
    
    for i in range(0, dim, stride):
        spike_times = time_steps[spks[i] == 1]
        plt.plot(spike_times,
                 i * np.ones(spike_times.shape),
                 linestyle=' ',
                 marker='o',
                 markersize=1.5,
                 color=color,
                 alpha=alpha)
        
    return fig 
@ackurth-nc ackurth-nc mentioned this issue Sep 22, 2022
16 tasks
@PhilippPlank PhilippPlank added the 1-feature New feature request label Sep 22, 2022
@mathisrichter mathisrichter added the 0-needs-review For all new issues label Jan 3, 2023
@ssgier ssgier mentioned this issue Feb 14, 2023
16 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0-needs-review For all new issues 1-feature New feature request
Projects
None yet
Development

No branches or pull requests

3 participants