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 | 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 | 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 | 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 occurred at the corresponding 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
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
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
Each element of the outer list is a trial. The inner list contains the type of spike (e.g., evprox1 or L2_pyramidal) that occurred at the corresponding time stamp. Each gid corresponds to a type via Network::gid_ranges.
- vseclist (n_trials,) of dict
Each element of the outer list is a trial. Dictionary indexed by gids containing voltages for cell sections.
- iseclist (n_trials,) of dict
Each element of the outer list is a trial. Dictionary indexed by gids containing currents for cell sections.
- calist (n_trials,) of dict, shape
Each element of the outer list is a trial. Dictionary indexed by gids containing calcium concentration 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.
- property cell_types¶
Get unique cell types.
- 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, color=None, invert_spike_types=None, show=True, **kwargs_hist)[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']
- colorstr | list of str | dict | None
Input defining colors of plotted histograms. If str, all histograms plotted with same color. If list of str provided, histograms for each spike type will be plotted by cycling through colors in the list.
If dict, colors must be specified for all spike_types as a key. If a group of spike types is defined by the
spike_types
parameter (see dictionary example forspike_types
), the name of this group must be used to specify the colors.Ex:{'evdist': 'g', 'evprox': 'r'}
,{'Tonic': 'b'}
If None, default color cycle used.
- showbool
If True, show the figure.
- **kwargs_histdict
Additional keyword arguments to pass to ax.hist.
- 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.
- property spike_times_by_type¶
Get a dictionary of spike times by cell type
- to_dict()[source]¶
Return cell response as a dict object.
- Returns:
- dict object containing the cell response