allensdk.core.nwb_data_set module

class allensdk.core.nwb_data_set.NwbDataSet(file_name, spike_time_key=None)[source]

Bases: object

A very simple interface for exracting electrophysiology data from an NWB file.

DEPRECATED_SPIKE_TIMES = 'aibs_spike_times'
SPIKE_TIMES = 'spike_times'
fill_sweep_responses(fill_value=0.0, sweep_numbers=None, extend_experiment=False)[source]

Fill sweep response arrays with a single value.

Parameters:
fill_value: float

Value used to fill sweep response array

sweep_numbers: list

List of integer sweep numbers to be filled (default all sweeps)

extend_experiment: bool

If True, extend experiment epoch length to the end of the sweep (undo any truncation)

get_experiment_sweep_numbers()[source]

Get all of the sweep numbers for experiment epochs in the file, not including test sweeps.

get_pipeline_version()[source]

Returns the AI pipeline version number, stored in the metadata field ‘generated_by’. If that field is missing, version 0.0 is returned.

Returns:
int tuple: (major, minor)
get_spike_times(sweep_number, key=None)[source]

Return any spike times stored in the NWB file for a sweep.

Parameters:
sweep_number: int

index to access

key : string

label where the spike times are stored (default NwbDataSet.SPIKE_TIMES)

Returns:
list

list of spike times in seconds relative to the start of the sweep

get_sweep(sweep_number)[source]

Retrieve the stimulus, response, index_range, and sampling rate for a particular sweep. This method hides the NWB file’s distinction between a “Sweep” and an “Experiment”. An experiment is a subset of of a sweep that excludes the initial test pulse. It also excludes any erroneous response data at the end of the sweep (usually for ramp sweeps, where recording was terminated mid-stimulus).

Some sweeps do not have an experiment, so full data arrays are returned. Sweeps that have an experiment return full data arrays (include the test pulse) with any erroneous data trimmed from the back of the sweep.

Parameters:
sweep_number: int
Returns:
dict

A dictionary with ‘stimulus’, ‘response’, ‘index_range’, and ‘sampling_rate’ elements. The index range is a 2-tuple where the first element indicates the end of the test pulse and the second index is the end of valid response data.

get_sweep_metadata(sweep_number)[source]

Retrieve the sweep level metadata associated with each sweep. Includes information on stimulus parameters like its name and amplitude as well as recording quality metadata, like access resistance and seal quality.

Parameters:
sweep_number: int
Returns:
dict

A dictionary with ‘aibs_stimulus_amplitude_pa’, ‘aibs_stimulus_name’, ‘gain’, ‘initial_access_resistance’, ‘seal’ elements. These specific fields are ones encoded in the original AIBS in vitro .nwb files.

get_sweep_numbers()[source]

Get all of the sweep numbers in the file, including test sweeps.

set_spike_times(sweep_number, spike_times, key=None)[source]

Set or overwrite the spikes times for a sweep.

Parameters:
sweep_number : int

index to access

key : string

where the times are stored (default NwbDataSet.SPIKE_TIME)

spike_times: np.array

array of spike times in seconds

set_sweep(sweep_number, stimulus, response)[source]

Overwrite the stimulus or response of an NWB file. If the supplied arrays are shorter than stored arrays, they are padded with zeros to match the original data size.

Parameters:
sweep_number: int
stimulus: np.array

Overwrite the stimulus with this array. If None, stimulus is unchanged.

response: np.array

Overwrite the response with this array. If None, response is unchanged.