hnn_core.CellResponse

class hnn_core.CellResponse(spike_times=None, spike_gids=None, spike_types=None, times=None)

The CellResponse class.

Parameters
spike_timeslist (n_trials,) of list (n_spikes,) of float, shape | None

Each element of the outer list is a trial. The inner list contains the time stamps of spikes.

spike_gidslist (n_trials,) of list (n_spikes,) of float, shape | None

Each element of the outer list is a trial. The inner list contains the cell IDs of neurons that spiked.

spike_typeslist (n_trials,) of list (n_spikes,) of float, shape | None

Each element of the outer list is a trial. The inner list contains the type of spike (e.g., evprox1 or L2_pyramidal) that occured at the corresonding time stamp. Each gid corresponds to a type via Network().gid_ranges.

Attributes
spike_timeslist (n_trials,) of list (n_spikes,) of float, shape

Each element of the outer list is a trial. The inner list contains the time stamps of spikes.

spike_gidslist (n_trials,) of list (n_spikes,) of float, shape

Each element of the outer list is a trial. The inner list contains the cell IDs of neurons that spiked.

spike_typeslist (n_trials,) of list (n_spikes,) of float, shape

Each element of the outer list is a trial. The inner list contains the type of spike (e.g., evprox1 or L2_pyramidal) that occured at the corresonding time stamp. Each gid corresponds to a type via Network::gid_ranges.

vsomalist (n_trials,) of dict, shape

Each element of the outer list is a trial. Dictionary indexed by gids containing somatic voltages.

isomalist (n_trials,) of dict, shape

Each element of the outer list is a trial. Dictionary indexed by gids containing somatic currents.

timesnumpy array

Array of time points for samples in continuous data. This includes vsoma and isoma.

Methods

update_types(gid_ranges)

Update spike types in the current instance of CellResponse.

plot(ax=None, show=True)

Plot and return a matplotlib Figure object showing the aggregate network spiking activity according to cell type.

mean_rates(tstart, tstop, gid_ranges, mean_type=’all’)

Calculate mean firing rate for each cell type. Specify averaging method with mean_type argument.

write(fname)

Write spiking activity to a collection of spike trial files.

__getitem__(gid_item)

Returns a CellResponse object with a copied subset filtered by gid.

Parameters
gid_itemint | slice

Subset of gids .

Returns
cell_responseinstance of CellResponse

See below for use cases.

__repr__()

Return repr(self).

mean_rates(tstart, tstop, gid_ranges, mean_type='all')

Mean spike rates (Hz) by cell type.

Parameters
tstartint | float | None

Value defining the start time of all trials.

tstopint | float | None

Value defining the stop time of all trials.

gid_rangesdict of lists or range objects

Dictionary with keys ‘evprox1’, ‘evdist1’ etc. containing the range of Cell or input IDs of different cell or input types.

mean_typestr
‘all’Average over trials and cells

Returns mean rate for cell types

‘trial’Average over cell types

Returns trial mean rate for cell types

‘cell’Average over individual cells

Returns trial mean rate for individual cells

Returns
spike_ratedict

Dictionary with keys ‘L5_pyramidal’, ‘L5_basket’, etc.

plot_spikes_hist(ax=None, spike_types=None, show=True)

Plot the histogram of spiking activity across trials.

Parameters
axinstance of matplotlib axis | None

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

spike_types: string | list | dictionary | None
String input of a valid spike type is plotted individually.

Ex: ‘common’, ‘evdist’, ‘evprox’, ‘extgauss’, ‘extpois’

List of valid string inputs will plot each spike type individually.

Ex: [‘common’, ‘evdist’]

Dictionary of valid lists will plot list elements as a group.

Ex: {‘Evoked’: [‘evdist’, ‘evprox’], ‘External’: [‘extpois’]}

If None, all input spike types are plotted individually if any are present. Otherwise spikes from all cells are plotted. Valid strings also include leading characters of spike types

Example: ‘ext’ is equivalent to [‘extgauss’, ‘extpois’]

showbool

If True, show the figure.

Returns
figinstance of matplotlib Figure

The matplotlib figure handle.

plot_spikes_raster(ax=None, show=True)

Plot the aggregate spiking activity according to cell type.

Parameters
axinstance of matplotlib axis | None

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

showbool

If True, show the figure.

Returns
figinstance of matplotlib Figure

The matplotlib figure object.

update_types(gid_ranges)

Update spike types in the current instance of CellResponse.

Parameters
gid_rangesdict of lists or range objects

Dictionary with keys ‘evprox1’, ‘evdist1’ etc. containing the range of Cell or input IDs of different cell or input types.

write(fname)

Write spiking activity per trial to a collection of files.

Parameters
fnamestr

String format (e.g., ‘<pathname>/spk_%d.txt’) of the path to the output spike file(s).