hnn_core.viz.plot_spikes_raster#

hnn_core.viz.plot_spikes_raster(cell_response, trial_idx=None, ax=None, show=True, cell_types=None, gid_ranges=None, colors=None, show_legend=True, marker_size=1.0, dpl=None, overlay_dipoles=False, xticks=None, yticks=None, xlabel='Time (ms)', ylabel='Neuron index', title=None)[source]#

Plot the aggregate spiking activity according to cell type.

By default, this only plots spikes from cells, and NOT spikes from drives.

Parameters:
cell_responseinstance of CellResponse

The CellResponse object from net.cell_response

trial_idxint | list of int | None, default=None

Index of trials to be plotted. If None (default), all trials plotted

axinstance of matplotlib axis | None, default=None

An axis object from matplotlib. If None (default), a new figure is created.

showbool, default=True

If True (default), show the figure.

cell_typeslist of str | None, default=None

List of cell types (or drives) to plot. If None (default), all cell types listed in cell_response._cell_type_names are plotted.

gid_rangesdict of lists or range objects | None, default=None

Dictionary whose keys are cell type names (or drive names) and whose values are lists or range objects of GIDs for that cell type (or drive). If provided, the raster spans the full range of the plotted cell/drive types, so that cells/drives which never spiked still occupy a row, and any overlaid dipoles are scaled to that range. If None (default), the extent of the raster is inferred from the cells (not drives) that spiked. Note that the keys of gid_ranges must match the cell types (or drives) specified in cell_types; if cell_types is None (default), the keys of gid_ranges must match the cell types listed in cell_response._cell_type_names.

colorslist of str | None, default=None

Optional custom colors to plot. If None (default) will use the default matplotlib color cycler.

show_legendbool, default=True

If True (default), show the legend with colors for cell types

marker_sizefloat, default=1.0

Optional marker size to use when plotting spikes. Uses “linelengths” argument of ax.eventplot, which accepts positive numeric values only.

dplinstance of Dipole | list of Dipole | None, default=None

The Dipole object containing layer-specific dipole data to overlay on the raster plot. Required if overlay_dipoles is True.

overlay_dipolesbool, default=False

If True, overlay the layer-specific dipole data on the raster plot. If True, dpl must be provided.

xtickslist | np.array | None, default=None

Ticks on x-axis. If None (default), ticks are created by matplotlib.

ytickslist | np.array | None, default=None

Ticks on y-axis. If None (default), ticks are created by matplotlib.

xlabelstr, default=”Time (ms)”

The matplotlib x-axis label

ylabelstr, default=”Neuron index”

The matplotlib y-axis label

titlestr | None, default=None

The matplotlib figure title

Returns:
figinstance of matplotlib Figure

The matplotlib figure object.