session.electrophysiology¶
Units table, spike times, unit labels and locations, electrodes and electrical series.
cicada_nwb.submodules.electrophysiology.NWBElectrophysiology ¶
Read-only access to electrophysiology data stored in an NWB file. Targets the standard NWB units table (nwb.units) and electrode metadata. No spike sorting, PSTH, or any other computation — raw access only.
get_electrical_series ¶
get_electrical_series()
All ElectricalSeries, stored directly or inside LFP / FilteredEphys containers, in acquisition and in processing modules. Structure: {location: {container_name: [series_name, ...]}}; location is 'acquisition' or a processing module name; a series stored directly is listed under its own name as container.
get_electrical_series_channels ¶
get_electrical_series_channels(keys)
The electrodes table rows of the series' channels, in channel order: a DataFrame indexed by channel position (0 .. n_channels - 1), with an 'electrode_id' column and the electrode columns (object columns such as 'group' left out). None if the series does not exist.
get_electrical_series_data ¶
get_electrical_series_data(keys, start=None, stop=None, channels=None, dtype=np.float32)
Read a time window of an ElectricalSeries, in volts.
Only the samples of the window and the requested channels are read from the file. Values = stored value x conversion x channel_conversion (per channel, if present) + offset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys
|
[location, container_name, series_name] (see get_electrical_series) |
required | |
start, stop
|
window in seconds (inclusive); None = from the first / to the last sample |
required | |
channels
|
positions of the channels in the series (0 .. n_channels - 1), any order; None = all channels |
None
|
|
dtype
|
dtype of the returned data (float32 by default, to limit memory) |
float32
|
Returns: (data, times): data (n_channels, n_times) in volts, times (n_times,) in seconds; None if the series does not exist.
get_electrical_series_electrode_groups ¶
get_electrical_series_electrode_groups(keys)
Electrode group of each channel of the series (list, channel order): the electrodes table's 'group_name', else the name of its 'group' (e.g. shanks of a probe, grids and strips of ECoG). None if the series does not exist or the table has no group.
get_electrical_series_locations ¶
get_electrical_series_locations(keys, col_name=None)
(locations, col_name): location of each channel of the series (list, channel order) from the electrodes table, using col_name or the first known location column; (None, None) if none.
get_electrical_series_rate ¶
get_electrical_series_rate(keys)
Sampling rate (Hz) of the series: its rate, or estimated from its first timestamps. None if unknown.
get_electrical_series_time_range ¶
get_electrical_series_time_range(keys)
(first, last) sample times (s) of the series, read without loading the timestamps. None if unknown.
get_electrode_info ¶
get_electrode_info()
Return the electrodes table as a pandas DataFrame. Returns None if no electrodes table is present. Columns typically include: location, group, group_name, filtering, imp, x, y, z.
get_known_unit_label_columns
staticmethod
¶
get_known_unit_label_columns()
All the quality label columns looked for (UNIT_LABEL_COLUMNS), in order of preference.
get_recording_time_range ¶
get_recording_time_range()
(start, end) in s of the ephys recording: from the earliest to the latest time of the electrical series and the spikes. None if the file has neither.
get_single_unit_spike_times ¶
get_single_unit_spike_times(unit_id)
Return spike times for a single unit as a 1D numpy array. Args: unit_id: The unit ID (as stored in the units table id column). Returns: 1D numpy array of spike times in seconds, or None if unit not found.
get_spike_times ¶
get_spike_times(col_name, labels=['all'], label_col=None, return_ids=False)
Spike trains of the units, as an array of arrays (units table order).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
col_name
|
spike times column (see get_spiketimes_col) |
required | |
labels
|
quality labels to keep (['all'] or None: every unit) |
['all']
|
|
label_col
|
quality label column; None = the first one of the file. Ignored if the file does not have it (every unit kept). |
None
|
|
return_ids
|
also return the unit ids of the trains |
False
|
Returns: trains, or (trains, unit_ids) if return_ids; None if no units table.
get_spiketimes_col ¶
get_spiketimes_col()
Return the names of the units-table columns holding spike times (no data loaded).
get_spiketimes_group ¶
get_spiketimes_group(spkst_col='spike_times', col_name=None, target=None, labels=['all'], label_col=None, return_ids=False)
Spike trains of the units whose location (col_name) is in target, filtered on quality labels like get_spike_times; (trains, unit_ids) if return_ids.
get_unit_cell_type_map ¶
get_unit_cell_type_map()
{unit_id: cell type} for every unit (None where missing), from the cell type column of the units table (same search as for imaging ROIs: 'cell_type', 'celltype', ..., then categorical columns whose name contains 'type'); {} if there is none.
get_unit_cell_types ¶
get_unit_cell_types()
Sorted unique cell types of the units (e.g. 'excitatory', 'inhibitory'); [] if none.
get_unit_ids ¶
get_unit_ids()
Return a list of unit IDs as they appear in the units table. Returns an empty list if no units table is present.
get_unit_label_columns ¶
get_unit_label_columns()
Quality label columns of the units table (UNIT_LABEL_COLUMNS: Bombcell 'bc_label', Allen 'quality', Kilosort 'ks_label' / 'KSLabel', IBL 'kilosort2_label', phy 'group'), in that order; columns with no value at all are left out.
get_unit_labels ¶
get_unit_labels(label_col=None)
Sorted unique values of a unit quality label column (missing values left out), or [] if absent. label_col: column name; None = the first quality label column (see get_unit_label_columns).
get_units_coordinates ¶
get_units_coordinates(cols=('x', 'y', 'z'), join_col='peak_channel_id')
Return a DataFrame indexed by unit_id with the given coordinate columns, taken from the electrodes table for whichever of cols aren't already on the units table: through join_col (Allen 'peak_channel_id'), else the units' 'max_electrode', else their 'electrodes' (mean position of the unit's electrodes). Columns that can't be found anywhere come back all-NaN. Returns None if no units table is present.
get_units_table ¶
get_units_table(extra_columns=None)
Return the full units table as a pandas DataFrame. Returns None if no units table is present. Columns typically include: id, spike_times, electrodes, and any custom columns.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
extra_columns
|
dict mapping new column name → callable(units_table) → Series/array. Use the DataFrame itself (or its index) to compute the new column. Example: {'neuron_id': lambda df: df.index, 'area_bis': lambda df: df['location'].str.upper()} |
None
|