ipfx package

Subpackages

Submodules

ipfx.chirp module

ipfx.chirp.chirp_amp_phase(sweep_set, start=0.6, end=20.6, down_rate=2000, min_freq=0.2, max_freq=40.0)[source]

Calculate amplitude and phase of chirp responses

Parameters:
sweep_set: SweepSet

Set of chirp sweeps

start: float (optional, default 0.6)

Start of chirp stimulus in seconds

end: float (optional, default 20.6)

End of chirp stimulus in seconds

down_rate: int (optional, default 2000)

Sampling rate for downsampling before FFT

min_freq: float (optional, default 0.2)

Minimum frequency for output to contain

max_freq: float (optional, default 40)

Maximum frequency for output to contain

Returns:
amplitude: array

Aka resistance

phase: array

Aka reactance

freq: array

Frequencies for amplitude and phase results

ipfx.chirp.divide_chirps_by_stimulus(sweep_set)[source]
ipfx.chirp.extract_chirp_feature_vector(data_set, chirp_sweep_numbers)[source]
ipfx.chirp.feature_vectors_chirp(chirp_sweeps, min_freq=0.2, max_freq=40.0)[source]

ipfx.data_access module

get_archive_info(dataset:str, archive_info:pandas.core.frame.DataFrame= size (GB) ... experiment_metadata_path
dataset ...
human 12 ... /home/docs/checkouts/readthedocs.org/user_buil...
mouse 114 ... /home/docs/checkouts/readthedocs.org/user_buil...
[2 rows x 4 columns]) -> Tuple[str, pandas.core.frame.DataFrame, pandas.core.frame.DataFrame]

Provide information about released archive

Parameters:
dataset : name of the dataset to query. Currently supported options are:
  • human
  • mouse
archive_info : dataframe of metadata and manifest files for each supported

dataset. Dataset name is the index.

Returns:
Information about the archive

ipfx.data_set_features module

ipfx.data_set_features.detection_parameters(stimulus_type)[source]
ipfx.data_set_features.detection_parameters_from_stimulus_name(stimulus_name)[source]
ipfx.data_set_features.extract_cell_long_square_features(data_set, subthresh_min_amp=None)[source]
ipfx.data_set_features.extract_cell_ramp_features(data_set)[source]
ipfx.data_set_features.extract_cell_short_square_features(data_set)[source]
ipfx.data_set_features.extract_data_set_features(data_set, subthresh_min_amp=None)[source]
Parameters:
data_set : EphysDataSet

data set

subthresh_min_amp
Returns:
cell_features :
sweep_features :
cell_record :
sweep_records :
ipfx.data_set_features.extract_sweep_features(data_set, sweep_table)[source]
ipfx.data_set_features.extractors_for_sweeps(sweep_set, dv_cutoff=20.0, thresh_frac=0.05, reject_at_stim_start_interval=0, min_peak=-30, filter_frequency=10.0, thresh_frac_floor=None, est_window=None, start=None, end=None)[source]

Extract data from sweeps

Parameters:
sweep_set : SweepSet object
dv_cutoff : float
thresh_frac :
reject_at_stim_start_interval :
thresh_frac_floor
est_window :
start :
end :
Returns:
spx : SpikeExtractor object
spfx : SpikeTrainFeatureExtractor object
ipfx.data_set_features.fallback_on_error(fallback_value=None, catch_errors=<class 'Exception'>)[source]
ipfx.data_set_features.record_errors(fn)[source]
ipfx.data_set_features.select_subthreshold_min_amplitude(stim_amps, decimals=0)[source]

Find the min delta between amplitudes of coarse long square sweeps. Includes failed sweeps.

Parameters:
stim_amps: list of stimulus amplitudes
decimals: int of decimals to keep
Returns:
subthresh_min_amp: float min amplitude
min_amp_delta: min increment in the stimulus amplitude

ipfx.data_set_utils module

A shim for backwards compatible imports of create_data_set

ipfx.ephys_data_set module

A shim for backwards compatible imports of EphysDataSet

ipfx.epochs module

ipfx.epochs.get_experiment_epoch(i, hz, test_pulse=True)[source]

Find index range for the experiment epoch. The start index of the experiment epoch is defined as stim_start_idx - PRESTIM_DURATION*sampling_rate The end index of the experiment epoch is defined as stim_end_idx + POSTSTIM_DURATION*sampling_rate

Parameters:
i : float np.array of current
hz : float sampling rate
test_pulse: bool True if present, False otherwise
Returns:
(expt_start_idx,expt_end_idx): int tuple with start, end indices of the epoch
ipfx.epochs.get_first_noise_epoch(idx, hz)[source]
ipfx.epochs.get_first_stability_epoch(stim_start_idx, hz)[source]
ipfx.epochs.get_last_noise_epoch(idx1, hz)[source]
ipfx.epochs.get_last_stability_epoch(idx1, hz)[source]

Get epoch lasting LAST_STABILITY_EPOCH before idx1

Parameters:
idx1 : int last index of the epoch
hz : float sampling rate
Returns:
(idx0,idx1) : int tuple of epoch indices
ipfx.epochs.get_recording_epoch(response)[source]

Detect response epoch defined as interval from start to the last non-nan value of the response

Parameters:
response: float np.array
Returns:
start,end: int

indices of the epoch

ipfx.epochs.get_stim_epoch(i, test_pulse=True)[source]

Determine the start index, and end index of a general stimulus.

Parameters:
i : numpy array

current

test_pulse: bool

True if test pulse is assumed

Returns:
start,end: int tuple
ipfx.epochs.get_sweep_epoch(response)[source]

Defined as interval including entire sweep

Parameters:
response: float np.array
Returns:
(start_index,end_index): int tuple

with start,end indices of the epoch

ipfx.epochs.get_test_epoch(i, hz)[source]

Find index range of the test epoch

Parameters:
i : float np.array

current trace

Returns:
start_idx,end_idx: int tuple

start,end indices of the epoch

hz: float

sampling rate

ipfx.error module

exception ipfx.error.FeatureError[source]

Bases: Exception

Generic Python-exception-derived object raised by feature detection functions.

ipfx.feature_extractor module

class ipfx.feature_extractor.SpikeFeatureExtractor(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, reject_at_stim_start_interval=0)[source]

Bases: object

Methods

System Message: WARNING/2 (/home/docs/checkouts/readthedocs.org/user_builds/ipfx/checkouts/latest/ipfx/feature_extractor.py:docstring of ipfx.feature_extractor.SpikeFeatureExtractor, line 19)

toctree references unknown document ‘ipfx.feature_extractor.SpikeFeatureExtractor.spike_feature’

System Message: WARNING/2 (/home/docs/checkouts/readthedocs.org/user_builds/ipfx/checkouts/latest/ipfx/feature_extractor.py:docstring of ipfx.feature_extractor.SpikeFeatureExtractor, line 19)

toctree references unknown document ‘ipfx.feature_extractor.SpikeFeatureExtractor.spike_feature_keys’

System Message: WARNING/2 (/home/docs/checkouts/readthedocs.org/user_builds/ipfx/checkouts/latest/ipfx/feature_extractor.py:docstring of ipfx.feature_extractor.SpikeFeatureExtractor, line 19)

toctree references unknown document ‘ipfx.feature_extractor.SpikeFeatureExtractor.spikes’
spike_feature(self, spikes_df, key[, …]) Get specified feature for every spike.
spike_feature_keys(self, spikes_df) Get list of every available spike feature.
spikes(self, spikes_df) Get all features for each spike as a list of records.
is_spike_feature_affected_by_clipping  
process  
AFFECTED_BY_CLIPPING = ['trough_t', 'trough_v', 'trough_i', 'trough_index', 'downstroke', 'downstroke_t', 'downstroke_v', 'downstroke_index', 'fast_trough_t', 'fast_trough_v', 'fast_trough_i', 'fast_trough_indexadp_t', 'adp_v', 'adp_i', 'adp_index', 'slow_trough_t', 'slow_trough_v', 'slow_trough_i', 'slow_trough_index', 'isi_type', 'width', 'upstroke_downstroke_ratio']

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

is_spike_feature_affected_by_clipping(self, key)[source]
process(self, t, v, i)[source]
spike_feature(self, spikes_df, 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(self, spikes_df)[source]

Get list of every available spike feature.

spikes(self, spikes_df)[source]

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

class ipfx.feature_extractor.SpikeTrainFeatureExtractor(start, end, burst_tol=0.5, pause_cost=1.0, deflect_type=None, stim_amp_fn=None, baseline_interval=0.1, filter_frequency=1.0, sag_baseline_interval=0.03, peak_width=0.005)[source]

Bases: object

Methods

process  
process(self, t, v, i, spikes_df, extra_features=None, exclude_clipped=False)[source]

ipfx.feature_record module

ipfx.feature_record.add_features_to_record(feature_names, feature_data, cell_record, postfix=None)[source]
ipfx.feature_record.build_cell_feature_record(cell_features)[source]
ipfx.feature_record.build_sweep_feature_record(sweep_table, sweep_features)[source]
ipfx.feature_record.convert_units(cell_record)[source]
ipfx.feature_record.nan_get(obj, key)[source]

Return a value from a dictionary. If it does not exist, return None. If it is NaN, return None

ipfx.feature_vectors module

ipfx.feature_vectors.first_ap_vectors(sweeps_list, spike_info_list, target_sampling_rate=50000, window_length=0.003, skip_clipped=False)[source]

Average waveforms of first APs from sweeps

Parameters:
sweeps_list: list

List of Sweep objects

spike_info_list: list

List of spike info DataFrames

target_sampling_rate: float (optional, default 50000)

Desired sampling rate of output (Hz)

window_length: float (optional, default 0.003)

Length of AP waveform (seconds)

Returns:
ap_v: array of shape (target_sampling_rate * window_length)

Waveform of average AP

ap_dv: array of shape (target_sampling_rate * window_length - 1)

Waveform of first derivative of ap_v

ipfx.feature_vectors.first_ap_waveform(sweep, spikes, length_in_points)[source]

Waveform of first AP with length_in_points time samples

Parameters:
sweep: Sweep

Sweep object with spikes

System Message: WARNING/2 (/home/docs/checkouts/readthedocs.org/user_builds/ipfx/checkouts/latest/ipfx/feature_vectors.py:docstring of ipfx.feature_vectors.first_ap_waveform, line 9)

Block quote ends without a blank line; unexpected unindent.

spikes: DataFrame

Spike info dataframe with “threshold_index” column

length_in_points: int

Length of returned AP waveform

Returns:
first_ap_v: array of shape (length_in_points)

The waveform of the first AP in sweep

ipfx.feature_vectors.identify_subthreshold_depol_with_amplitudes(features, sweeps)[source]

Identify subthreshold responses from depolarizing steps

Parameters:
features: dict

Output of LongSquareAnalysis.analyze()

sweeps: SweepSet

Long square sweeps

Returns:
amp_sweep_dict: dict

Amplitude-sweep pairs

deflect_dict: dict

Dictionary of (base, deflect) tuples with amplitudes as keys

ipfx.feature_vectors.identify_subthreshold_hyperpol_with_amplitudes(features, sweeps)[source]

Identify subthreshold responses from hyperpolarizing steps

Parameters:
features: dict

Output of LongSquareAnalysis.analyze()

sweeps: SweepSet

Long square sweeps

Returns:
amp_sweep_dict: dict

Amplitude-sweep pairs

deflect_dict: dict

Dictionary of (base, deflect) tuples with amplitudes as keys

ipfx.feature_vectors.identify_suprathreshold_spike_info(features, target_amplitudes, shift=None, amp_tolerance=0)[source]

Find spike information for sweeps matching desired amplitudes relative to rheobase

Parameters:
features: dict

Output of LongSquareAnalysis.analyze()

target_amplitudes: array

Amplitudes (relative to rheobase) for each desired step

shift: float (optional, default None)

Amount to consider shifting “rheobase” to identify more matching sweeps if only a single sweep matches. A value of None means that no shift is attempted.

amp_tolerance: float (optional, default 0)

Tolerance for matching amplitude (pA)

Returns:
info_list: list

Spike info in order of desired amplitudes. If a given amplitude cannot be found, the list has None at that location

ipfx.feature_vectors.identify_suprathreshold_sweeps(sweeps, features, target_amplitudes, shift=None, amp_tolerance=0)[source]

Find spike information for sweeps matching desired amplitudes relative to rheobase

Parameters:
sweeps: Sweep set

Long square sweeps

features: dict

Output of LongSquareAnalysis.analyze()

target_amplitudes: array

Amplitudes (relative to rheobase) for each desired step

shift: float (optional, default None)

Amount to consider shifting “rheobase” to identify more matching sweeps if only a single sweep matches. A value of None means that no shift is attempted.

amp_tolerance: float (optional, default 0)

Tolerance for matching amplitude (pA)

Returns:
sweeps: list

Sweeps in order of desired amplitudes. If a given amplitude cannot be found, the list has None at that location

ipfx.feature_vectors.identify_sweep_for_isi_shape(sweeps, features, duration, min_spike=5)[source]

Find lowest-amplitude spiking sweep that has at least min_spike or else sweep with most spikes

Parameters:
sweeps: SweepSet

Sweeps to consider for ISI shape calculation

features: dict

Output of LongSquareAnalysis.analyze()

duration: float

Length of stimulus interval (seconds)

min_spike: int (optional, default 5)

Minimum number of spikes for first preference sweep (default 5)

Returns:
selected_sweep: Sweep

Sweep object for ISI shape calculation

selected_spike_info: DataFrame

Spike info for selected sweep

ipfx.feature_vectors.inst_freq_vector(spike_info_list, start, end, width=20)[source]
Create binned instantaneous frequency feature vector,
concatenated across sweeps
Parameters:
spike_info_list: list

Spike info DataFrames for each sweep

start: float

Start of stimulus interval (seconds)

end: float

End of stimulus interval (seconds)

width: float (optional, default 20)

Bin width in ms

Returns:
output: array

Concatenated vector of binned instantaneous firing rates (spikes/s)

ipfx.feature_vectors.isi_shape(sweep, spike_info, end, n_points=100, steady_state_interval=0.1, single_return_tolerance=1.0, single_max_duration=0.1)[source]

Average interspike voltage trajectory with normalized duration, aligned to threshold

Parameters:
sweep: Sweep

Sweep object with at least one action potential

spike_info: DataFrame

Spike info for sweep

end: float

End of stimulus interval (seconds)

n_points: int (optional, default 100)

Number of points in output

steady_state_interval: float (optional, default 0.1)

Interval for calculating steady-state for sweeps with only one spike (seconds)

single_return_tolerance: float (optional, default 1)

Allowable difference from steady-state for determining end of “ISI” if only one spike is in sweep (mV)

single_max_duration: float (optional, default 0.1)

Allowable max duration for finding end of “ISI” if only one spike is in sweep (seconds)

Returns:
isi_norm: array of shape (n_points)

Averaged, threshold-aligned, duration-normalized voltage trace

ipfx.feature_vectors.noise_ap_features(noise_sweeps, stim_interval_list=[(2.02, 5.02), (10.02, 13.02), (18.02, 21.02)], target_sampling_rate=50000, window_length=0.003, skip_first_n=1)[source]

Average AP waveforms in noise sweeps

Parameters:
noise_sweeps: SweepSet

Noise sweeps

stim_interval_list: list

Tuples of start and end times (in seconds) of analysis intervals

target_sampling_rate: float (optional, default 50000)

Desired sampling rate of output (Hz)

window_length: float (optional, default 0.003)

Length of AP waveform (seconds)

skip_first_n: int (optional, default 1)

Number of initial APs to exclude from average (default 1)

Returns:
ap_v: array of shape (target_sampling_rate * window_length)

Waveform of average AP

ap_dv: array of shape (target_sampling_rate * window_length - 1)

Waveform of first derivative of ap_v

ipfx.feature_vectors.psth_vector(spike_info_list, start, end, width=50)[source]
Create binned “PSTH”-like feature vector based on spike times, concatenated
across sweeps
Parameters:
spike_info_list: list

Spike info DataFrames for each sweep

start: float

Start of stimulus interval (seconds)

end: float

End of stimulus interval (seconds)

width: float (optional, default 50)

Bin width in ms

Returns:
output: array

Concatenated vector of binned spike rates (spikes/s)

ipfx.feature_vectors.spike_feature_vector(feature, spike_info_list, start, end, width=20)[source]
Create binned feature vector for specified features,
concatenated across sweeps
Parameters:
feature: string

Name of feature found in members of spike_info_list

spike_info_list: list

Spike info DataFrames for each sweep

start: float

Start of stimulus interval (seconds)

end: float

End of stimulus interval (seconds)

width: float (optional, default 20)

Bin width in ms

Returns:
output: array

Concatenated vector of binned spike features

ipfx.feature_vectors.step_subthreshold(amp_sweep_dict, target_amps, start, end, extend_duration=0.2, subsample_interval=0.01, amp_tolerance=0.0)[source]

Subsample set of subthreshold step responses including regions before and after step

Parameters:
amp_sweep_dict : dict

Amplitude-sweep pairs

target_amps: list

Desired amplitudes for output vector

start: float

start stimulus interval (seconds)

end: float

end of stimulus interval (seconds)

extend_duration: float (optional, default 0.2)

Duration to extend sweep before and after stimulus interval (seconds)

subsample_interval: float (optional, default 0.01)

Size of subsampled bins (seconds)

amp_tolerance: float (optional, default 0)

Tolerance for finding matching amplitudes

Returns:
output_vector: subsampled, concatenated voltage trace
ipfx.feature_vectors.subthresh_depol_norm(amp_sweep_dict, deflect_dict, start, end, extend_duration=0.2, subsample_interval=0.01, steady_state_interval=0.1)[source]

Largest positive-going subthreshold step response that does not evoke spikes, normalized to baseline and steady-state at end of step

Parameters:
amp_sweep_dict: dict

Amplitude-sweep pairs

deflect_dict:

Dictionary of (baseline, deflect) tuples with amplitude keys

start: float

start stimulus interval (seconds)

end: float

end of stimulus interval (seconds)

extend_duration: float (optional, default 0.2)

Duration to extend sweep on each side of stimulus interval (seconds)

subsample_interval: float (optional, default 0.01)

Size of subsampled bins (seconds)

steady_state_interval: float (optional, default 0.1)

Interval before end for normalization (seconds)

Returns:
subsampled_v: array

Subsampled, normalized voltage trace

ipfx.feature_vectors.subthresh_norm(amp_sweep_dict, deflect_dict, start, end, target_amp=-101.0, extend_duration=0.2, subsample_interval=0.01)[source]

Subthreshold step response closest to target amplitude normalized to baseline and peak deflection

Parameters:
amp_sweep_dict: dict

Amplitude-sweep pairs

deflect_dict:

Dictionary of (baseline, deflect) tuples with amplitude keys

start: float

start stimulus interval (seconds)

end: float

end of stimulus interval (seconds)

target_amp: float (optional, default=-101)

Search target for amplitude (pA)

extend_duration: float (optional, default 0.2)

Duration to extend sweep on each side of stimulus interval (seconds)

subsample_interval: float (optional, default 0.01)

Size of subsampled bins (seconds)

Returns:
subsampled_v: array

Subsampled, normalized voltage trace

ipfx.lab_notebook_reader module

A shim for backwards compatible imports of lab_notebook_reader

ipfx.lims_queries module

ipfx.lims_queries.able_to_connect_to_lims()[source]
ipfx.lims_queries.get_igorh5_path_from_lims(ephys_roi_result)[source]
ipfx.lims_queries.get_input_h5_file(specimen_id)[source]
ipfx.lims_queries.get_input_nwb_file(specimen_id)[source]
ipfx.lims_queries.get_nwb_path_from_lims(ephys_roi_result)[source]

Try to find NWBIgor file preferentially If not found, look for a processed NWB file

well known file type ID for NWB files is 475137571 well known file type ID for NWBIgor files is 570280085

Parameters:
ephys_roi_result: int
Returns:
full path of the nwb file
ipfx.lims_queries.get_specimen_info_from_lims_by_id(specimen_id)[source]
ipfx.lims_queries.get_stimuli_description()[source]
ipfx.lims_queries.get_sweep_states(specimen_id)[source]
ipfx.lims_queries.project_specimen_ids(project, passed_only=True)[source]
ipfx.lims_queries.query(query, parameters=None)[source]

ipfx.logging_utils module

ipfx.logging_utils.configure_logger(cell_dir)[source]
ipfx.logging_utils.log_pretty_header(header, level=1, top_line_break=True, bottom_line_break=True)[source]

Decorate logging message to make logging output more human readable

Parameters:
header: str

header message

level: int

1 or 2 as in markdown

top_line_break: bool (True)

add a blank line at the top

bottom_line_break: bool (True)

add a blank line at the bottom

ipfx.nwb_append module

ipfx.nwb_append.append_spike_times(input_nwb_path:Union[str, pathlib.Path], sweep_spike_times:Dict[int, List[float]], output_nwb_path:Union[str, pathlib.Path, NoneType]=None)[source]

Appends spiketimes to an nwb2 file

ipfx.plot_qc_figures module

ipfx.plot_qc_figures.display_features(qc_fig_dir, data_set, feature_data)[source]
Parameters:
qc_fig_dir: str

directory name for storing html pages

data_set: NWB data set
feature_data: dict

cell and sweep features

ipfx.plot_qc_figures.exp_curve(x, a, inv_tau, y0)[source]

Function used for tau curve fitting

ipfx.plot_qc_figures.get_features(sweep_features, sweep_number)[source]
ipfx.plot_qc_figures.get_spikes(sweep_features, sweep_number)[source]
ipfx.plot_qc_figures.get_time_string()[source]
ipfx.plot_qc_figures.load_sweep(data_set, sweep_number)[source]
ipfx.plot_qc_figures.make_cell_html(image_files, metadata, file_name, img_sub_dir, required_fields=('electrode_0_pa', 'seal_gohm', 'initial_access_resistance_mohm', 'input_resistance_mohm'))[source]
ipfx.plot_qc_figures.make_cell_page(data_set, feature_data, working_dir, save_cell_plots=True)[source]
ipfx.plot_qc_figures.make_sweep_html(sweep_files, file_name, img_sub_dir)[source]
ipfx.plot_qc_figures.make_sweep_page(data_set, working_dir)[source]
ipfx.plot_qc_figures.mask_nulls(data)[source]
ipfx.plot_qc_figures.plot_cell_figures(data_set, figure_data, image_dir, sizes)[source]
ipfx.plot_qc_figures.plot_fi_curve_figures(data_set, cell_features, lims_features, sweep_features, image_dir, sizes, cell_image_files)[source]
ipfx.plot_qc_figures.plot_hero_figures(data_set, cell_features, lims_features, sweep_features, image_dir, sizes, cell_image_files)[source]
ipfx.plot_qc_figures.plot_images(image_dir, sizes, image_sets)[source]
ipfx.plot_qc_figures.plot_instantaneous_threshold_thumbnail(data_set, sweep_numbers, cell_features, lims_features, sweep_features, color='red')[source]
ipfx.plot_qc_figures.plot_long_square_summary(data_set, cell_features, lims_features)[source]
ipfx.plot_qc_figures.plot_ramp_figures(data_set, cell_features, lims_features, sweep_features, image_dir, sizes, cell_image_files)[source]
ipfx.plot_qc_figures.plot_rheo_figures(data_set, cell_features, lims_features, sweep_features, image_dir, sizes, cell_image_files)[source]
ipfx.plot_qc_figures.plot_sag_figures(data_set, cell_features, lims_features, sweep_features, image_dir, sizes, cell_image_files)[source]
ipfx.plot_qc_figures.plot_short_square_figures(data_set, cell_features, lims_features, sweep_features, image_dir, sizes, cell_image_files)[source]
ipfx.plot_qc_figures.plot_single_ap_values(data_set, sweep_numbers, lims_features, sweep_features, cell_features, type_name)[source]
ipfx.plot_qc_figures.plot_subthreshold_long_square_figures(data_set, cell_features, lims_features, sweep_features, image_dir, sizes, cell_image_files)[source]
ipfx.plot_qc_figures.plot_sweep_figures(data_set, image_dir, sizes)[source]
ipfx.plot_qc_figures.plot_sweep_set_summary(data_set, highlight_sweep_number, sweep_numbers, highlight_color='#0779BE', background_color='#dddddd')[source]
ipfx.plot_qc_figures.plot_sweep_value_figures(sweeps, image_dir, sizes, cell_image_files)[source]
ipfx.plot_qc_figures.save_figure(fig, image_name, image_set_name, image_dir, sizes, image_sets, scalew=1, scaleh=1, ext='png')[source]

ipfx.qc_feature_evaluator module

ipfx.qc_feature_evaluator.evaluate_blowout(blowout_mv, blowout_mv_min, blowout_mv_max, fail_tags)[source]
ipfx.qc_feature_evaluator.evaluate_electrode_0(electrode_0_pa, electrode_0_pa_max, fail_tags)[source]
ipfx.qc_feature_evaluator.evaluate_input_and_access_resistance(input_access_resistance_ratio, input_vs_access_resistance_max, initial_access_resistance_mohm, access_resistance_mohm_min, access_resistance_mohm_max, fail_tags)[source]
ipfx.qc_feature_evaluator.evaluate_seal(seal_gohm, seal_gohm_min, fail_tags)[source]
ipfx.qc_feature_evaluator.load_default_qc_criteria()[source]
ipfx.qc_feature_evaluator.qc_cell(cell_data, qc_criteria=None)[source]

Evaluate cell state across different types of stimuli

Parameters:
cell_data : dict

cell features

qc_criteria : dict

qc criteria

Returns:
cell_state : dict

cell state including qc features

ipfx.qc_feature_evaluator.qc_current_clamp_sweep(sweep, is_ramp, qc_criteria=None)[source]

QC for the current-clamp sweeps

Parameters:
is_ramp: bool

True for Ramp otherwise False

sweep : dict

features of a sweep

qc_criteria : dict

qc criteria

Returns:
fails : int

number of fails

fail_tags : list of str

tags of the failed sweeps

ipfx.qc_feature_evaluator.qc_experiment(ontology, cell_features, sweep_features, qc_criteria=None)[source]
Parameters:
ontology: StimulusOntology object

stimulus ontology

cell_features : dict

cell features

sweep_features: list of dicts

sweep features

qc_criteria : dict

qc criteria

Returns:
cell_state : list

sweep_states : list

ipfx.qc_feature_evaluator.qc_sweeps(ontology, sweep_features, qc_criteria)[source]

ipfx.qc_feature_extractor module

ipfx.qc_feature_extractor.cell_qc_features(data_set, manual_values=None)[source]
Parameters:
data_set : EphysDataSet

dataset

manual_values : dict

default (manual) values that can be passed in through input.json.

Returns:
features : dict

cell qc features

tags : list

warning tags

ipfx.qc_feature_extractor.check_sweep_integrity(sweep, is_ramp)[source]
ipfx.qc_feature_extractor.compute_input_access_resistance_ratio(ir, sr)[source]
ipfx.qc_feature_extractor.current_clamp_sweep_qc_features(sweep, is_ramp)[source]
ipfx.qc_feature_extractor.current_clamp_sweep_stim_features(sweep)[source]
ipfx.qc_feature_extractor.extract_blowout(data_set, tags)[source]

Measure blowout voltage

Parameters:
data_set: EphysDataSet
tags: list

warning tags

Returns:
blowout_mv: float

blowout voltage in mV

ipfx.qc_feature_extractor.extract_clamp_seal(data_set, tags, manual_values=None)[source]
Parameters:
data_set: EphysDataSet
tags: list

warning tags

manual_values
ipfx.qc_feature_extractor.extract_electrode_0(data_set, tags)[source]

Measure electrode zero

Parameters:
data_set: EphysDataSet
tags: list

warning tags

Returns:
e0: float
ipfx.qc_feature_extractor.extract_initial_access_resistance(breakin_sweep, tags, manual_values)[source]
ipfx.qc_feature_extractor.extract_input_and_access_resistance(data_set, tags, manual_values=None)[source]
Measure input and series (access) resistance in two steps:
  1. finding the breakin sweep
  2. and then analyzing it

if the value is unavailable then check to see if it was set manually

Parameters:
data_set: EphysDataSet
tags: list

warning tags

manual_values: dict

manual/default values

Returns:
ir: float

input resistance

sr: float

access resistance

ipfx.qc_feature_extractor.extract_input_resistance(breakin_sweep, tags, manual_values)[source]
ipfx.qc_feature_extractor.extract_recording_date(data_set, tags)[source]
ipfx.qc_feature_extractor.sweep_qc_features(data_set)[source]

ipfx.qc_features module

ipfx.qc_features.get_r_from_peak_pulse_response(v, i, t)[source]
ipfx.qc_features.get_r_from_stable_pulse_response(v, i, t)[source]

Compute input resistance from the stable pulse response

Parameters:
v : float membrane voltage (V)
i : float input current (A)
t : time (s)
Returns:
ir: float input resistance
ipfx.qc_features.get_square_pulse_idx(v)[source]

Get up and down indices of the square pulse(s). Skipping the very first pulse (test pulse)

Parameters:
v: float

pulse trace

Returns:
up_idx, down_idx: list, list

up, down indices

ipfx.qc_features.measure_blowout(v, idx0)[source]
ipfx.qc_features.measure_electrode_0(curr, hz, t=0.005)[source]
ipfx.qc_features.measure_initial_access_resistance(v, curr, t)[source]
ipfx.qc_features.measure_input_resistance(v, curr, t)[source]
ipfx.qc_features.measure_seal(v, curr, t)[source]
ipfx.qc_features.measure_vm(vals)[source]
ipfx.qc_features.measure_vm_delta(mean_start, mean_end)[source]

ipfx.script_utils module

ipfx.script_utils.categorize_iclamp_sweeps(data_set, stimuli_names, sweep_qc_option='none', specimen_id=None)[source]
ipfx.script_utils.dataset_for_specimen_id(specimen_id, data_source, ontology, file_list=None)[source]
ipfx.script_utils.filter_results(specimen_ids, results)[source]
ipfx.script_utils.lims_nwb_information(specimen_id)[source]
ipfx.script_utils.organize_results(specimen_ids, results)[source]

Build dictionary of results, filling data from cells with appropriate-length nan arrays where needed

ipfx.script_utils.preprocess_long_square_sweeps(data_set, sweep_numbers, extra_dur=0.2, subthresh_min_amp=-100.0)[source]
ipfx.script_utils.preprocess_ramp_sweeps(data_set, sweep_numbers)[source]
ipfx.script_utils.preprocess_short_square_sweeps(data_set, sweep_numbers, extra_dur=0.2, spike_window=0.05)[source]
ipfx.script_utils.save_errors_to_json(error_set, output_dir, output_code)[source]
ipfx.script_utils.save_results_to_h5(specimen_ids, results_dict, output_dir, output_code)[source]
ipfx.script_utils.save_results_to_npy(specimen_ids, results_dict, output_dir, output_code)[source]
ipfx.script_utils.sdk_nwb_information(specimen_id)[source]
ipfx.script_utils.validate_sweeps(data_set, sweep_numbers, extra_dur=0.2)[source]

ipfx.spike_detector module

ipfx.spike_detector.check_thresholds_and_peaks(v, t, spike_indexes, peak_indexes, upstroke_indexes, start=None, end=None, max_interval=0.005, thresh_frac=0.05, filter=10.0, dvdt=None, tol=1.0, reject_at_stim_start_interval=0.0)[source]

Validate thresholds and peaks for set of spikes

Check that peaks and thresholds for consecutive spikes do not overlap Spikes with overlapping thresholds and peaks will be merged.

Check that peaks and thresholds for a given spike are not too far apart.

Parameters:
v : numpy array of voltage time series in mV
t : numpy array of times in seconds
spike_indexes : numpy array of spike indexes
peak_indexes : numpy array of indexes of spike peaks
upstroke_indexes : numpy array of indexes of spike upstrokes
start : start of time window for feature analysis (optional)
end : end of time window for feature analysis (optional)
max_interval : maximum allowed time between start of spike and time of peak in sec (default 0.005)
thresh_frac : fraction of average upstroke for threshold calculation (optional, default 0.05)
filter : cutoff frequency for 4-pole low-pass Bessel filter in kHz (optional, default 10)
dvdt : pre-calculated time-derivative of voltage (optional)
tol : tolerance for returning to threshold in mV (optional, default 1)
reject_at_stim_start_interval : duration of window after start to reject potential spikes (optional, default 0)
Returns:
spike_indexes : numpy array of modified spike indexes
peak_indexes : numpy array of modified spike peak indexes
upstroke_indexes : numpy array of modified spike upstroke indexes
clipped : numpy array of clipped status of spikes
ipfx.spike_detector.detect_putative_spikes(v, t, start=None, end=None, filter=10.0, dv_cutoff=20.0, dvdt=None)[source]

Perform initial detection of spikes and return their indexes.

Parameters:
v : numpy array of voltage time series in mV
t : numpy array of times in seconds
start : start of time window for spike detection (optional)
end : end of time window for spike detection (optional)
filter : cutoff frequency for 4-pole low-pass Bessel filter in kHz (optional, default 10)
dv_cutoff : minimum dV/dt to qualify as a spike in V/s (optional, default 20)
dvdt : pre-calculated time-derivative of voltage (optional)
Returns:
putative_spikes : numpy array of preliminary spike indexes
ipfx.spike_detector.filter_putative_spikes(v, t, spike_indexes, peak_indexes, min_height=2.0, min_peak=-30.0, filter=10.0, dvdt=None)[source]
Filter out events that are unlikely to be spikes based on:
  • Height (threshold to peak)
  • Absolute peak level
Parameters:
v : numpy array of voltage time series in mV
t : numpy array of times in seconds
spike_indexes : numpy array of preliminary spike indexes
peak_indexes : numpy array of indexes of spike peaks
min_height : minimum acceptable height from threshold to peak in mV (optional, default 2)
min_peak : minimum acceptable absolute peak level in mV (optional, default -30)
filter : cutoff frequency for 4-pole low-pass Bessel filter in kHz (optional, default 10)
dvdt : pre-calculated time-derivative of voltage (optional)
Returns:
spike_indexes : numpy array of threshold indexes
peak_indexes : numpy array of peak indexes
ipfx.spike_detector.find_clipped_spikes(v, t, spike_indexes, peak_indexes, end_index, tol)[source]

Check that last spike was not cut off too early by end of stimulus by checking that the membrane potential returned to at least the threshold voltage - otherwise, drop it

Parameters:
v : numpy array of voltage time series in mV
t : numpy array of times in seconds
spike_indexes : numpy array of spike indexes
peak_indexes : numpy array of indexes of spike peaks
end_index: int index of the end of time window for feature analysis
tol: float tolerance to returning to threshold
Returns:
clipped: Boolean np.array
ipfx.spike_detector.find_downstroke_indexes(v, t, peak_indexes, trough_indexes, clipped=None, filter=10.0, dvdt=None)[source]

Find indexes of minimum voltage (troughs) between spikes.

Parameters:
v : numpy array of voltage time series in mV
t : numpy array of times in seconds
peak_indexes : numpy array of spike peak indexes
trough_indexes : numpy array of threshold indexes
clipped: boolean array - False if spike not clipped by edge of window
filter : cutoff frequency for 4-pole low-pass Bessel filter in kHz (optional, default 10)
dvdt : pre-calculated time-derivative of voltage (optional)
Returns:
downstroke_indexes : numpy array of downstroke indexes
ipfx.spike_detector.find_peak_indexes(v, t, spike_indexes, end=None)[source]

Find indexes of spike peaks.

Parameters:
v : numpy array of voltage time series in mV
t : numpy array of times in seconds
spike_indexes : numpy array of preliminary spike indexes
end : end of time window for spike detection (optional)
ipfx.spike_detector.find_trough_indexes(v, t, spike_indexes, peak_indexes, clipped=None, end=None)[source]

Find indexes of minimum voltage (trough) between spikes.

Parameters:
v : numpy array of voltage time series in mV
t : numpy array of times in seconds
spike_indexes : numpy array of spike indexes
peak_indexes : numpy array of spike peak indexes
end : end of time window (optional)
Returns:
trough_indexes : numpy array of threshold indexes
ipfx.spike_detector.find_upstroke_indexes(v, t, spike_indexes, peak_indexes, filter=10.0, dvdt=None)[source]

Find indexes of maximum upstroke of spike.

Parameters:
v : numpy array of voltage time series in mV
t : numpy array of times in seconds
spike_indexes : numpy array of preliminary spike indexes
peak_indexes : numpy array of indexes of spike peaks
filter : cutoff frequency for 4-pole low-pass Bessel filter in kHz (optional, default 10)
dvdt : pre-calculated time-derivative of voltage (optional)
Returns:
upstroke_indexes : numpy array of upstroke indexes
ipfx.spike_detector.refine_threshold_indexes(v, t, upstroke_indexes, thresh_frac=0.05, filter=10.0, dvdt=None)[source]

Refine threshold detection of previously-found spikes.

Parameters:
v : numpy array of voltage time series in mV
t : numpy array of times in seconds
upstroke_indexes : numpy array of indexes of spike upstrokes (for threshold target calculation)
thresh_frac : fraction of average upstroke for threshold calculation (optional, default 0.05)
filter : cutoff frequency for 4-pole low-pass Bessel filter in kHz (optional, default 10)
dvdt : pre-calculated time-derivative of voltage (optional)
Returns:
threshold_indexes : numpy array of threshold indexes

ipfx.spike_features module

ipfx.spike_features.analyze_trough_details(v, t, spike_indexes, peak_indexes, clipped=None, end=None, filter=10.0, heavy_filter=1.0, term_frac=0.01, adp_thresh=0.5, tol=0.5, flat_interval=0.002, adp_max_delta_t=0.005, adp_max_delta_v=10.0, dvdt=None)[source]

Analyze trough to determine if an ADP exists and whether the reset is a ‘detour’ or ‘direct’

Parameters:
v : numpy array of voltage time series in mV
t : numpy array of times in seconds
spike_indexes : numpy array of spike indexes
peak_indexes : numpy array of spike peak indexes
end : end of time window (optional)
filter : cutoff frequency for 4-pole low-pass Bessel filter in kHz (default 1)
heavy_filter : lower cutoff frequency for 4-pole low-pass Bessel filter in kHz (default 1)
thresh_frac : fraction of average upstroke for threshold calculation (optional, default 0.05)
adp_thresh: minimum dV/dt in V/s to exceed to be considered to have an ADP (optional, default 1.5)
tol : tolerance for evaluating whether Vm drops appreciably further after end of spike (default 1.0 mV)
flat_interval: if the trace is flat for this duration, stop looking for an ADP (default 0.002 s)
adp_max_delta_t: max possible ADP delta t (default 0.005 s)
adp_max_delta_v: max possible ADP delta v (default 10 mV)
dvdt : pre-calculated time-derivative of voltage (optional)
Returns:
isi_types : numpy array of isi reset types (direct or detour)
fast_trough_indexes : numpy array of indexes at the start of the trough (i.e. end of the spike)
adp_indexes : numpy array of adp indexes (np.nan if there was no ADP in that ISI
slow_trough_indexes : numpy array of indexes at the minimum of the slow phase of the trough

(if there wasn’t just a fast phase)

ipfx.spike_features.estimate_adjusted_detection_parameters(v_set, t_set, interval_start, interval_end, filter=10)[source]

Estimate adjusted values for spike detection by analyzing a period when the voltage changes quickly but passively (due to strong current stimulation), which can result in spurious spike detection results.

Parameters:
v_set : list of numpy arrays of voltage time series in mV
t_set : list of numpy arrays of times in seconds
interval_start : start of analysis interval (sec)
interval_end : end of analysis interval (sec)
Returns:
new_dv_cutoff : adjusted dv/dt cutoff (V/s)
new_thresh_frac : adjusted fraction of avg upstroke to find threshold
ipfx.spike_features.find_widths(v, t, spike_indexes, peak_indexes, trough_indexes, clipped=None)[source]

Find widths at half-height for spikes.

Widths are only returned when heights are defined

Parameters:
v : numpy array of voltage time series in mV
t : numpy array of times in seconds
spike_indexes : numpy array of spike indexes
peak_indexes : numpy array of spike peak indexes
trough_indexes : numpy array of trough indexes
Returns:
widths : numpy array of spike widths in sec
ipfx.spike_features.fit_prespike_time_constant(t, v, start, spike_time, dv_limit=-0.001, tau_limit=0.3)[source]

Finds the dominant time constant of the pre-spike rise in voltage

Parameters:
v : numpy array of voltage time series in mV
t : numpy array of times in seconds
start : start of voltage rise (seconds)
spike_time : time of first spike (seconds)
dv_limit : dV/dt cutoff (default -0.001)

Shortens fit window if rate of voltage drop exceeds this limit

tau_limit : upper bound for slow time constant (seconds, default 0.3)

If the slower time constant of a double-exponential fit is twice that of the faster and exceeds this limit, the faster one will be considered the dominant one

Returns:
tau : dominant time constant (seconds)

ipfx.spike_train_features module

ipfx.spike_train_features.adaptation_index(isis)[source]

Calculate adaptation index of isis.

ipfx.spike_train_features.average_rate(t, spikes, start, end)[source]

Calculate average firing rate during interval between start and end.

Parameters:
t : numpy array of times in seconds
spikes : numpy array of spike indexes
start : start of time window for spike detection
end : end of time window for spike detection
Returns:
avg_rate : average firing rate in spikes/sec
ipfx.spike_train_features.basic_spike_train_features(t, spikes_df, start, end, exclude_clipped=False)[source]
ipfx.spike_train_features.burst(t, spikes_df, tol=0.5, pause_cost=1.0)[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
ipfx.spike_train_features.delay(t, v, spikes_df, start, end)[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
ipfx.spike_train_features.detect_bursts(isis, isi_types, fast_tr_v, fast_tr_t, slow_tr_v, slow_tr_t, thr_v, tol=0.5, pause_cost=1.0)[source]

Detect bursts in spike train.

Parameters:
isis : numpy array of n interspike intervals
isi_types : numpy array of n interspike interval types
fast_tr_v : numpy array of fast trough voltages for the n + 1 spikes of the train
fast_tr_t : numpy array of fast trough times for the n + 1 spikes of the train
slow_tr_v : numpy array of slow trough voltages for the n + 1 spikes of the train
slow_tr_t : numpy array of slow trough times for the n + 1 spikes of the train
thr_v : numpy array of threshold voltages for the n + 1 spikes of the train
tol : tolerance for the difference in slow trough voltages and thresholds (default 0.5 mV)

Used to identify “delay” interspike intervals that occur within a burst

Returns:
bursts : list of bursts

Each item in list is a tuple of the form (burst_index, start, end) where burst_index is a comparison index between the highest instantaneous rate within the burst vs the highest instantaneous rate outside the burst. start is the index of the first ISI of the burst, and end is the ISI index immediately following the burst.

ipfx.spike_train_features.detect_pauses(isis, isi_types, cost_weight=1.0)[source]

Determine which ISIs are “pauses” in ongoing firing.

Pauses are unusually long ISIs with a “detour reset” among “direct resets”.

Parameters:
isis : numpy array of interspike intervals
isi_types : numpy array of interspike interval types (‘direct’ or ‘detour’)
cost_weight : weight for cost function for calling an ISI a pause

Higher cost weights lead to fewer ISIs identified as pauses. The cost function also depends on the difference between the duration of the “pause” ISIs and the average duration and standard deviation of “non-pause” ISIs.

Returns:
pauses : numpy array of indices corresponding to pauses in isis
ipfx.spike_train_features.fit_fi_slope(stim_amps, avg_rates)[source]

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

ipfx.spike_train_features.get_isis(t, spikes)[source]

Find interspike intervals in sec between spikes (as indexes).

ipfx.spike_train_features.latency(t, spikes, start)[source]

Calculate time to the first spike.

ipfx.spike_train_features.norm_diff(a)[source]

Calculate average of (a[i] - a[i+1]) / (a[i] + a[i+1]).

ipfx.spike_train_features.norm_sq_diff(a)[source]

Calculate average of (a[i] - a[i+1])^2 / (a[i] + a[i+1])^2.

ipfx.spike_train_features.pause(t, spikes_df, start, end, cost_weight=1.0)[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

ipfx.stim_features module

ipfx.stim_features.find_stim_interval(idx0, stim, hz)[source]
ipfx.stim_features.get_stim_characteristics(i, t, test_pulse=True)[source]

Identify the start time, duration, amplitude, start index, and end index of a general stimulus.

ipfx.stimulus module

class ipfx.stimulus.Stimulus(tag_sets)[source]

Bases: object

Methods

has_tag  
tags  
has_tag(self, tag, tag_type=None)[source]
tags(self, tag_type=None, flat=False)[source]
class ipfx.stimulus.StimulusOntology(stim_ontology_tags=None)[source]

Bases: object

Methods

System Message: WARNING/2 (/home/docs/checkouts/readthedocs.org/user_builds/ipfx/checkouts/latest/ipfx/stimulus.py:docstring of ipfx.stimulus.StimulusOntology, line 19)

toctree references unknown document ‘ipfx.stimulus.StimulusOntology.default’

System Message: WARNING/2 (/home/docs/checkouts/readthedocs.org/user_builds/ipfx/checkouts/latest/ipfx/stimulus.py:docstring of ipfx.stimulus.StimulusOntology, line 19)

toctree references unknown document ‘ipfx.stimulus.StimulusOntology.find’

System Message: WARNING/2 (/home/docs/checkouts/readthedocs.org/user_builds/ipfx/checkouts/latest/ipfx/stimulus.py:docstring of ipfx.stimulus.StimulusOntology, line 19)

toctree references unknown document ‘ipfx.stimulus.StimulusOntology.stimulus_has_any_tags’
default() Construct an ontology object using default tags
find(self, tag[, tag_type]) Find stimuli matching a given tag Parameters ———- tag: str tag_type: str
stimulus_has_any_tags(self, stim, tags[, …]) Find stimulus based on a tag stim and then check if it has any tags Parameters ———- stim: str tag to find stimulus tags: str tags to check in any belong to the stimulus tag_type
find_one  
stimulus_has_all_tags  
DEFAULT_STIMULUS_ONTOLOGY_FILE = '/home/docs/checkouts/readthedocs.org/user_builds/ipfx/checkouts/latest/ipfx/defaults/stimulus_ontology.json'
classmethod default()[source]

Construct an ontology object using default tags

find(self, tag, tag_type=None)[source]

Find stimuli matching a given tag Parameters ———- tag: str tag_type: str

Returns:
matching_stims: list of Stimuli objects
find_one(self, tag, tag_type=None)[source]
stimulus_has_all_tags(self, stim, tags, tag_type=None)[source]
stimulus_has_any_tags(self, stim, tags, tag_type=None)[source]

Find stimulus based on a tag stim and then check if it has any tags Parameters ———- stim: str

System Message: ERROR/3 (/home/docs/checkouts/readthedocs.org/user_builds/ipfx/checkouts/latest/ipfx/stimulus.py:docstring of ipfx.stimulus.StimulusOntology.stimulus_has_any_tags, line 6)

Unexpected indentation.
tag to find stimulus

System Message: WARNING/2 (/home/docs/checkouts/readthedocs.org/user_builds/ipfx/checkouts/latest/ipfx/stimulus.py:docstring of ipfx.stimulus.StimulusOntology.stimulus_has_any_tags, line 7)

Block quote ends without a blank line; unexpected unindent.
tags: str
tags to check in any belong to the stimulus

System Message: WARNING/2 (/home/docs/checkouts/readthedocs.org/user_builds/ipfx/checkouts/latest/ipfx/stimulus.py:docstring of ipfx.stimulus.StimulusOntology.stimulus_has_any_tags, line 9)

Definition list ends without a blank line; unexpected unindent.

tag_type

Returns:
bool: True if any tags match, otherwise False
class ipfx.stimulus.StimulusType[source]

Bases: enum.Enum

An enumeration.

BATH = 'bath'
BLOWOUT = 'blowout'
BREAKIN = 'breakin'
CHIRP = 'chirp'
COARSE_LONG_SQUARE = 'coarse_long_square'
EXTP = 'extp'
LONG_SQUARE = 'long_square'
RAMP = 'ramp'
SEAL = 'seal'
SEARCH = 'search'
SHORT_SQUARE = 'short_square'
SHORT_SQUARE_TRIPLE = 'short_square_triple'
TEST = 'test'
ipfx.stimulus.get_stimulus_type(stimulus_name)[source]

ipfx.stimulus_protocol_analysis module

class ipfx.stimulus_protocol_analysis.LongSquareAnalysis(spx, sptx, subthresh_min_amp, tau_frac=0.1, require_subthreshold=True, require_suprathreshold=True)[source]

Bases: ipfx.stimulus_protocol_analysis.StimulusProtocolAnalysis

Methods

System Message: WARNING/2 (/home/docs/checkouts/readthedocs.org/user_builds/ipfx/checkouts/latest/ipfx/stimulus_protocol_analysis.py:docstring of ipfx.stimulus_protocol_analysis.LongSquareAnalysis, line 19)

toctree references unknown document ‘ipfx.stimulus_protocol_analysis.LongSquareAnalysis.mean_features_first_spike’
mean_features_first_spike(self, spikes_set) Compute mean feature values for the first spike in list of extractors
all_sweep_features  
analyze  
analyze_basic_features  
analyze_subthreshold  
analyze_suprathreshold  
as_dict  
find_hero_sweep  
find_rheobase_sweep  
reset_basic_features  
subthreshold_sweep_features  
suprathreshold_sweep_features  
HERO_MAX_AMP_OFFSET = 61.0
HERO_MIN_AMP_OFFSET = 39.0
SAG_TARGET = -100.0
SUBTHRESH_MAX_AMP = 0
analyze(self, sweep_set)[source]
analyze_subthreshold(self, sweep_set)[source]
analyze_suprathreshold(self, sweep_set)[source]
as_dict(self, features, extra_params=None)[source]
find_hero_sweep(self, rheo_amp, spiking_features, min_offset=39.0, max_offset=61.0)[source]
find_rheobase_sweep(self, spiking_features)[source]
class ipfx.stimulus_protocol_analysis.RampAnalysis(spx, sptx)[source]

Bases: ipfx.stimulus_protocol_analysis.StimulusProtocolAnalysis

Methods

System Message: WARNING/2 (/home/docs/checkouts/readthedocs.org/user_builds/ipfx/checkouts/latest/ipfx/stimulus_protocol_analysis.py:docstring of ipfx.stimulus_protocol_analysis.RampAnalysis, line 19)

toctree references unknown document ‘ipfx.stimulus_protocol_analysis.RampAnalysis.mean_features_first_spike’
mean_features_first_spike(self, spikes_set) Compute mean feature values for the first spike in list of extractors
all_sweep_features  
analyze  
analyze_basic_features  
as_dict  
reset_basic_features  
subthreshold_sweep_features  
suprathreshold_sweep_features  
analyze(self, sweep_set)[source]
as_dict(self, features, extra_params=None)[source]
class ipfx.stimulus_protocol_analysis.ShortSquareAnalysis(spx, sptx)[source]

Bases: ipfx.stimulus_protocol_analysis.StimulusProtocolAnalysis

Methods

System Message: WARNING/2 (/home/docs/checkouts/readthedocs.org/user_builds/ipfx/checkouts/latest/ipfx/stimulus_protocol_analysis.py:docstring of ipfx.stimulus_protocol_analysis.ShortSquareAnalysis, line 19)

toctree references unknown document ‘ipfx.stimulus_protocol_analysis.ShortSquareAnalysis.mean_features_first_spike’
mean_features_first_spike(self, spikes_set) Compute mean feature values for the first spike in list of extractors
all_sweep_features  
analyze  
analyze_basic_features  
as_dict  
reset_basic_features  
subthreshold_sweep_features  
suprathreshold_sweep_features  
analyze(self, sweep_set)[source]
as_dict(self, features, extra_params=None)[source]
class ipfx.stimulus_protocol_analysis.StimulusProtocolAnalysis(spx, sptx)[source]

Bases: object

Methods

System Message: WARNING/2 (/home/docs/checkouts/readthedocs.org/user_builds/ipfx/checkouts/latest/ipfx/stimulus_protocol_analysis.py:docstring of ipfx.stimulus_protocol_analysis.StimulusProtocolAnalysis, line 19)

toctree references unknown document ‘ipfx.stimulus_protocol_analysis.StimulusProtocolAnalysis.mean_features_first_spike’
mean_features_first_spike(self, spikes_set) Compute mean feature values for the first spike in list of extractors
all_sweep_features  
analyze  
analyze_basic_features  
as_dict  
reset_basic_features  
subthreshold_sweep_features  
suprathreshold_sweep_features  
MEAN_FEATURES = ['upstroke_downstroke_ratio', 'peak_v', 'peak_t', 'trough_v', 'trough_t', 'fast_trough_v', 'fast_trough_t', 'slow_trough_v', 'slow_trough_t', 'threshold_v', 'threshold_i', 'threshold_t', 'peak_v', 'peak_t']
all_sweep_features(self)[source]
analyze(self, sweep_set, extra_sweep_features=None, exclude_clipped=False)[source]
analyze_basic_features(self, sweep_set, extra_sweep_features=None, exclude_clipped=False)[source]
as_dict(self, features, extra_params=None)[source]
mean_features_first_spike(self, spikes_set, features_list=None)[source]

Compute mean feature values for the first spike in list of extractors

reset_basic_features(self)[source]
subthreshold_sweep_features(self, sweep_features=None)[source]
suprathreshold_sweep_features(self, sweep_features=None)[source]

ipfx.string_utils module

ipfx.string_utils.to_str(s:Union[str, bytes]) → str[source]

Convert bytes to string if not string

Parameters:
s (Union[str,bytes]): variable to convert
Returns:
str

ipfx.subthresh_features module

ipfx.subthresh_features.baseline_voltage(t, v, start, baseline_interval=0.1, baseline_detect_thresh=0.3, filter_frequency=1.0)[source]
ipfx.subthresh_features.fit_membrane_time_constant(t, v, start, end, rmse_max_tol=1.0)[source]

Fit an exponential to estimate membrane time constant between start and end

Parameters:
v : numpy array of voltages in mV
t : numpy array of times in seconds
start : start of time window for exponential fit
end : end of time window for exponential fit
rsme_max_tol: minimal acceptable root mean square error (default 1e-4)
Returns:
a, inv_tau, y0 : Coefficients of equation y0 + a * exp(-inv_tau * x)
returns np.nan for values if fit fails
ipfx.subthresh_features.input_resistance(t_set, i_set, v_set, start, end, baseline_interval=0.1)[source]

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

ipfx.subthresh_features.sag(t, v, i, start, end, peak_width=0.005, baseline_interval=0.03)[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
ipfx.subthresh_features.time_constant(t, v, i, start, end, max_fit_end=None, frac=0.1, baseline_interval=0.1, min_snr=20.0)[source]

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

Parameters:
v : numpy array of voltages in mV
t : numpy array of times in seconds
start : start of stimulus interval in seconds
end : end of stimulus interval in seconds
max_fit_end : maximum end of exponential fit window. If None, end of fit

window will always be the time of the peak hyperpolarizing deflection. If set, end of fit window will be max_fit_end if it is earlier than the time of peak deflection (default None)

frac : fraction of peak deflection (or deflection at present_fit_end if used)

to find to determine start of fit window. (default 0.1)

baseline_interval : duration before start for baseline Vm calculation
min_snr : minimum signal-to-noise ratio (SNR) to allow calculation of time constant.

If SNR is too low, np.nan will be returned. (default 20)

Returns:
tau : membrane time constant in seconds
ipfx.subthresh_features.voltage_deflection(t, v, i, start, end, 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

ipfx.sweep module

class ipfx.sweep.Sweep(t, v, i, clamp_mode, sampling_rate, sweep_number=None, epochs=None)[source]

Bases: object

Attributes:
i
t
v

Methods

System Message: WARNING/2 (/home/docs/checkouts/readthedocs.org/user_builds/ipfx/checkouts/latest/ipfx/sweep.py:docstring of ipfx.sweep.Sweep, line 29)

toctree references unknown document ‘ipfx.sweep.Sweep.detect_epochs’
detect_epochs(self) Detect epochs if they are not provided in the constructor
select_epoch  
set_time_zero_to_index  
detect_epochs(self)[source]

Detect epochs if they are not provided in the constructor

i
select_epoch(self, epoch_name)[source]
set_time_zero_to_index(self, time_step)[source]
t
v
class ipfx.sweep.SweepSet(sweeps)[source]

Bases: object

Attributes:
i
sampling_rate
sweep_number
t
v

Methods

align_to_start_of_epoch  
select_epoch  
align_to_start_of_epoch(self, epoch_name)[source]
i
sampling_rate
select_epoch(self, epoch_name)[source]
sweep_number
t
v

ipfx.sweep_props module

ipfx.sweep_props.assign_sweep_states(sweep_states, sweep_features)[source]

Assign sweep state to all sweeps

Parameters:
sweep_states: dict of sweep states
sweep_features: list of dics of sweep features
ipfx.sweep_props.count_sweep_states(sweep_states)[source]

Count passed and total sweeps

Parameters:
sweep_states: list of dicts
Sweep state dict has keys:

“reason”: list of strings “sweep_number”: int “passed”: True/False

Returns
——-
num_passed_sweeps: int

number of sweeps passed QC

num_sweeps: int

number of sweeps QCed

ipfx.sweep_props.create_sweep_state(sweep_number, fail_tags)[source]
ipfx.sweep_props.drop_failed_sweeps(sweep_features)[source]
ipfx.sweep_props.drop_tagged_sweeps(sweep_features)[source]
ipfx.sweep_props.extract_sweep_features_subset(feature_names, sweep_features)[source]
Parameters:
sweep_features: list of dicts of sweep features
feature_names: list of features to select
Returns:
sweep_features_subset: list of dicts including only a subset of features from feature_names
ipfx.sweep_props.modify_sweep_info_keys(sweep_list)[source]
ipfx.sweep_props.override_auto_sweep_states(manual_sweep_states, sweep_states)[source]
ipfx.sweep_props.remove_sweep_feature(feature_name, sweep_features)[source]

ipfx.time_series_utils module

ipfx.time_series_utils.average_voltage(v, t, start=None, end=None)[source]

Calculate average voltage between start and end.

Parameters:
v : numpy array of voltage time series in mV
t : numpy array of times in seconds
start : start of time window for spike detection (optional, default None)
end : end of time window for spike detection (optional, default None)
Returns:
v_avg : average voltage
ipfx.time_series_utils.calculate_dvdt(v, t, filter=None)[source]

Low-pass filters (if requested) and differentiates voltage by time.

Parameters:
v : numpy array of voltage time series in mV
t : numpy array of times in seconds
filter : cutoff frequency for 4-pole low-pass Bessel filter in kHz (optional, default None)
Returns:
dvdt : numpy array of time-derivative of voltage (V/s = mV/ms)
ipfx.time_series_utils.find_time_index(t, t_0)[source]

Find the index value of a given time (t_0) in a time series (t).

Parameters:
t : time array
t_0 : time point to find an index
Returns:
idx: index of t closest to t_0
ipfx.time_series_utils.flatnotnan(a)[source]

Returns indices that are non nan in a flattened version of a

Parameters:
a: np.array
Returns:
res: np.array

Output array containing indices of an array that are not nan

ipfx.time_series_utils.has_fixed_dt(t)[source]

Check that all time intervals are identical.

ipfx.utilities module

ipfx.utilities.drop_failed_sweeps(dataset:ipfx.dataset.ephys_data_set.EphysDataSet, stimulus_ontology:Union[ipfx.stimulus.StimulusOntology, NoneType]=None, qc_criteria:Union[Dict, NoneType]=None) → List[Dict][source]

A convenience which extracts and QCs sweeps in preparation for dataset feature extraction. This function: 1. extracts sweep qc features 2. removes sweeps tagged with failure messages 3. sets sweep states based on qc results

Parameters:
dataset : dataset from which to draw sweeps
Returns:
sweep_features : a list of dictionaries, each describing a sweep

Module contents

Top-level package for ipfx.