hnn_core.CellResponse

class hnn_core.CellResponse(spike_times=None, spike_gids=None, spike_types=None, times=None, cell_type_names=None)[source]

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.

timesnumpy array | None

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

cell_type_nameslist

List of unique cell type names that are explicitly modeled in the network

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.

vseclist (n_trials,) of dict, shape

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

iseclist (n_trials,) of dict, shape

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

timesarray-like, shape (n_times,)

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

Methods

reset()

Reset all recorded attributes to empty lists.

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)[source]

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__()[source]

Return repr(self).

mean_rates(tstart, tstop, gid_ranges, mean_type='all')[source]

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(trial_idx=None, ax=None, spike_types=None, show=True)[source]

Plot the histogram of spiking activity across trials.

Parameters
trial_idxint | list of int | None

Index of trials to be plotted. If None, all trials plotted.

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: 'poisson', 'evdist', 'evprox', …

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

Ex: ['poisson', 'evdist']

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

Ex: {'Evoked': ['evdist', 'evprox'], 'Tonic': ['poisson']}

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

Ex: 'ev' is equivalent to ['evdist', 'evprox']
showbool

If True, show the figure.

Returns
figinstance of matplotlib Figure

The matplotlib figure handle.

plot_spikes_raster(trial_idx=None, ax=None, show=True)[source]

Plot the aggregate spiking activity according to cell type.

Parameters
trial_idxint | list of int | None

Index of trials to be plotted. If None, all trials plotted.

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)[source]

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)[source]

Write spiking activity per trial to a collection of files.

Parameters
fnamestr

String format (e.g., ‘spk_%d.txt’ or ‘spk_{0}.txt’) of the path to the output spike file(s). If no string format is provided, the trial index will be automatically appended to the file name.

Examples using hnn_core.CellResponse