allensdk.ephys.ephys_extractor module

class allensdk.ephys.ephys_extractor.EphysCellFeatureExtractor(ramps_ext, short_squares_ext, long_squares_ext, subthresh_min_amp=-100)[source]
SAG_TARGET = -100.0
SUBTHRESH_MAX_AMP = 0
as_dict()[source]

Create dict of cell features.

cell_features()[source]
long_squares_features(option=None)[source]
long_squares_stim_amps(option=None)[source]
process(keys=None)[source]

Processes features. Can take a specific key (or set of keys) to do a subset of processing.

ramps_features(all=False)[source]
short_squares_features()[source]
class allensdk.ephys.ephys_extractor.EphysSweepFeatureExtractor(t=None, v=None, i=None, start=None, end=None, filter=10.0, dv_cutoff=20.0, max_interval=0.005, min_height=2.0, min_peak=-30.0, thresh_frac=0.05, baseline_interval=0.1, baseline_detect_thresh=0.3, id=None)[source]

Feature calculation for a sweep (voltage and/or current time series).

as_dict()[source]

Create dict of features and spikes.

burst_metrics()[source]

Find bursts and return max “burstiness” index (normalized max rate in burst vs out).

Returns:
max_burstiness_index : max “burstiness” index across detected bursts
num_bursts : number of bursts detected
delay_metrics()[source]

Calculates ratio of latency to dominant time constant of rise before spike

Returns:
delay_ratio : ratio of latency to tau (higher means more delay)
tau : dominant time constant of rise before spike
estimate_sag(peak_width=0.005)[source]

Calculate the sag in a hyperpolarizing voltage response.

Parameters:
peak_width : window width to get more robust peak estimate in sec (default 0.005)
Returns:
sag : fraction that membrane potential relaxes back to baseline
estimate_time_constant()[source]

Calculate the membrane time constant by fitting the voltage response with a single exponential.

Returns:
tau : membrane time constant in seconds
is_spike_feature_affected_by_clipping(key)[source]
pause_metrics()[source]

Estimate average number of pauses and average fraction of time spent in a pause

Attempts to detect pauses with a variety of conditions and averages results together.

Pauses that are consistently detected contribute more to estimates.

Returns:
avg_n_pauses : average number of pauses detected across conditions
avg_pause_frac : average fraction of interval (between start and end) spent in a pause
max_reliability : max fraction of times most reliable pause was detected given weights tested
n_max_rel_pauses : number of pauses detected with max_reliability
process_new_spike_feature(feature_name, feature_func, affected_by_clipping=False)[source]

Add new spike-level feature calculation function

The function should take this sweep extractor as its argument. Its results can be accessed by calling the method spike_feature(<feature_name>).

process_new_sweep_feature(feature_name, feature_func)[source]

Add new sweep-level feature calculation function

The function should take this sweep extractor as its argument. Its results can be accessed by calling the method sweep_feature(<feature_name>).

process_spikes()[source]

Perform spike-related feature analysis

set_stimulus_amplitude_calculator(function)[source]
spike_feature(key, include_clipped=False, force_exclude_clipped=False)[source]

Get specified feature for every spike.

Parameters:
key : feature name
include_clipped: return values for every identified spike, even when clipping means they will be incorrect/undefined
Returns:
spike_feature_values : ndarray of features for each spike
spike_feature_keys()[source]

Get list of every available spike feature.

spikes()[source]

Get all features for each spike as a list of records.

stimulus_amplitude()[source]
sweep_feature(key, allow_missing=False)[source]

Get sweep-level feature (key).

Parameters:
key : name of sweep-level feature
allow_missing : return np.nan if key is missing for sweep (default False)
Returns:
sweep_feature : sweep-level feature value
sweep_feature_keys()[source]

Get list of every available sweep-level feature.

voltage_deflection(deflect_type=None)[source]

Measure deflection (min or max, between start and end if specified).

Parameters:
deflect_type : measure minimal (‘min’) or maximal (‘max’) voltage deflection

If not specified, it will check to see if the current (i) is positive or negative between start and end, then choose ‘max’ or ‘min’, respectively If the current is not defined, it will default to ‘min’.

Returns:
deflect_v : peak
deflect_index : index of peak deflection
class allensdk.ephys.ephys_extractor.EphysSweepSetFeatureExtractor(t_set=None, v_set=None, i_set=None, start=None, end=None, filter=10.0, dv_cutoff=20.0, max_interval=0.005, min_height=2.0, min_peak=-30.0, thresh_frac=0.05, baseline_interval=0.1, baseline_detect_thresh=0.3, id_set=None)[source]
classmethod from_sweeps(sweep_list)[source]

Initialize EphysSweepSetFeatureExtractor object with a list of pre-existing sweep feature extractor objects.

process_spikes()[source]

Analyze spike features for all sweeps.

spike_feature_averages(key)[source]

Get nparray of average spike-level feature (key) for all sweeps

sweep_features(key, allow_missing=False)[source]

Get nparray of sweep-level feature (key) for all sweeps

Parameters:
key : name of sweep-level feature
allow_missing : return np.nan if key is missing for sweep (default False)
Returns:
sweep_feature : nparray of sweep-level feature values
sweeps()[source]

Get list of EphysSweepFeatureExtractor objects.

allensdk.ephys.ephys_extractor.cell_extractor_for_nwb(dataset, ramps, short_squares, long_squares, subthresh_min_amp=-100)[source]

Initialize EphysCellFeatureExtractor object from NWB data set

Parameters:
dataset : NwbDataSet
ramps : list of sweep numbers of ramp sweeps
short_squares : list of sweep numbers of short square sweeps
long_squares : list of sweep numbers of long square sweeps
allensdk.ephys.ephys_extractor.extractor_for_nwb_sweeps(dataset, sweep_numbers, fixed_start=None, fixed_end=None, dv_cutoff=20.0, thresh_frac=0.05)[source]
allensdk.ephys.ephys_extractor.fit_fi_slope(ext)[source]

Fit the rate and stimulus amplitude to a line and return the slope of the fit.

allensdk.ephys.ephys_extractor.input_resistance(ext)[source]

Estimate input resistance in MOhms, assuming all sweeps in passed extractor are hyperpolarizing responses.

allensdk.ephys.ephys_extractor.membrane_time_constant(ext)[source]

Average the membrane time constant values estimated from each sweep in passed extractor.

allensdk.ephys.ephys_extractor.reset_long_squares_start(when)[source]