bluepyemodel.emodel_pipeline.plotting_utils

Plotting utils functions.

Functions

binning(x, y[, n_bin])

Put x and y into bins.

create_protocol(amp_rel, amp, feature, ...)

Create a new protocol with adjusted stimulus amplitude based on a threshold.

extract_experimental_data_for_IV_curve(...)

Get experimental data to be plotted for IV curve from bluepyefe cells.

fill_in_IV_curve_evaluator(evaluator, ...[, ...])

Returns a copy of the evaluator, with missing features added for IV_curve computation.

find_matching_feature(evaluator, protocol_name)

get_experimental_FI_curve_for_plotting(...)

Get experimental FI curve data used in plotting.

get_impedance(time, voltage, current, ...)

Get impedance for plotting.

get_ordered_currentscape_keys(keys)

Get responses keys (also filename strings) ordered by protocols and locations.

get_original_protocol_name(prot_name, evaluator)

Retrieve the protocol name as defined by the user, preserving the original case

get_recording_names(protocol_config, stimuli)

Get recording names which traces are to be plotted.

get_simulated_FI_curve_for_plotting(...)

Get FI curve data from model used in plotting.

get_sinespec_evaluator(evaluator, ...)

Returns evaluator with pre-protocols (if threshold based) and sinespec protocol and impedance feature.

get_title(emodel, iteration, seed)

Returns 'emodel ; iteration={iteration} ; seed={seed}'

get_traces_names_and_float_responses(...)

Extract the names of the traces to be plotted, as well as the float responses values.

get_traces_ylabel(var)

Get ylabel for traces subplot.

get_voltage_currents_from_files(key_dict, ...)

Get time, voltage, currents and ionic concentrations from output files

plot_fi_curves(expt_data, sim_data, ...)

Plot and save the FI curves.

rel_to_abs_amplitude(rel_amp, responses)

Converts relative amplitude to absolute amplitude.

save_fig(figures_dir, figure_name[, dpi])

Save a matplotlib figure

update_evaluator(expt_amp_rel, prot_name, ...)

update evaluator with new simulation protocols.

binning(x, y, n_bin=5)

Put x and y into bins. Returns the binned x, binned y and std of binned y.

Parameters:
  • x (list) – x axis data points

  • y (list) – y axis data points corresponding to the x data points

  • n_bin (int) – number of bins to use

create_protocol(amp_rel, amp, feature, protocol, protocol_name)

Create a new protocol with adjusted stimulus amplitude based on a threshold.

Parameters:
  • amp_rel (float) – Relative amplitude as a percentage of the threshold current.

  • amp (float) – Absolute amplitude to use for recalculating the stimulus amplitude.

  • feature (eFELFeatureBPEM, optional) – Feature object used to retrieve the threshold

  • scaling. (current for)

  • protocol (BPEMProtocol) – The original protocol to modify.

  • protocol_name (str) – Name for the new protocol.

Returns:

A new protocol object with the adjusted threshold-based stimulus amplitude.

Return type:

BPEMProtocol

extract_experimental_data_for_IV_curve(cells, efel_settings, prot_name='iv', n_bin=5)

Get experimental data to be plotted for IV curve from bluepyefe cells. Use efel to extract missing features.

Parameters:
  • cells (list) – list of bluepyefe.cell.Cell object to get recordings from

  • efel_settings (dict) – efel settings to use during feature extraction

  • prot_name (str) – Only recordings from this protocol will be used.

  • n_bin (int) – number of bins to use for plotting

fill_in_IV_curve_evaluator(evaluator, efel_settings, prot_name='iv', new_amps=None)

Returns a copy of the evaluator, with missing features added for IV_curve computation.

Parameters:
  • evaluator (CellEvaluator) – cell evaluator

  • efel_settings (dict) – eFEL settings in the form {setting_name: setting_value}.

  • prot_name (str) – Only recordings from this protocol will be used.

  • new_amps (list) – List of amplitudes to extend the protocols with.

get_experimental_FI_curve_for_plotting(cells, prot_name, n_bin=5)

Get experimental FI curve data used in plotting.

Parameters:
  • cells (list) – list of bluepyefe.cell.Cell object to get recordings from

  • prot_name (str) – name of the protocol to use for the FI curve

  • n_bin (int) – number of bins to use

get_impedance(time, voltage, current, stim_start, stim_end, efel_settings)

Get impedance for plotting.

Parameters:
  • time (list) – time series

  • voltage (list) – voltage series

  • current (list) – injected current series

  • stim_start (float) – stimulus start time

  • stim_end (float) – stimulus end time

  • efel_settings (dict) – eFEL settings in the form {setting_name: setting_value}

get_ordered_currentscape_keys(keys)

Get responses keys (also filename strings) ordered by protocols and locations.

Parameters:

keys (list of str) – list of responses keys (or filename stems). Each item should have the shape protocol.location.current

Returns:

containing voltage key, ion current and ionic concentration keys,

and ion current and ionic concentration names. Should have the shape:

{
    "protocol_name": {
        "loc_name": {
            "voltage_key": str, "current_keys": [], "current_names": [],
            "ion_conc_keys": [], "ion_conc_names": [],
        }
    }
}

Return type:

dict

get_original_protocol_name(prot_name, evaluator)

Retrieve the protocol name as defined by the user, preserving the original case

get_recording_names(protocol_config, stimuli)

Get recording names which traces are to be plotted.

Does not return extra ion / current recordings.

Parameters:
  • protocol_config (list) – list of ProtocolConfiguration from FitnessCalculatorConfiguration

  • stimuli (list) – list of all protocols (protocols from configuration + pre-protocols)

get_simulated_FI_curve_for_plotting(evaluator, responses, prot_name)

Get FI curve data from model used in plotting.

Parameters:
  • evaluator (CellEvaluator) – cell evaluator

  • responses (dict) – responses of the cell model

  • prot_name (str) – name of the protocol to use for the FI curve

get_sinespec_evaluator(evaluator, sinespec_settings, efel_settings)

Returns evaluator with pre-protocols (if threshold based) and sinespec protocol and impedance feature.

Parameters:
  • evaluator (CellEvaluator) – cell evaluator

  • sinespec_settings (dict) – contains amplitude settings for the SineSpec protocol, with keys ‘amp’ and ‘threshold_based’. ‘amp’ should be in percentage of threshold if ‘threshold_based’ is True, e.g. 150, or in nA if ‘threshold_based’ if false, e.g. 0.1.

  • efel_settings (dict) – eFEL settings in the form {setting_name: setting_value}

get_title(emodel, iteration, seed)

Returns ‘emodel ; iteration={iteration} ; seed={seed}’

Parameters:
  • emodel (str) – emodel name

  • iteration (str) – githash

  • seed (int) – random number seed

get_traces_names_and_float_responses(responses, recording_names)

Extract the names of the traces to be plotted, as well as the float responses values.

get_traces_ylabel(var)

Get ylabel for traces subplot.

get_voltage_currents_from_files(key_dict, output_dir)

Get time, voltage, currents and ionic concentrations from output files

plot_fi_curves(expt_data, sim_data, figures_dir, emodel, write_fig)

Plot and save the FI curves.

rel_to_abs_amplitude(rel_amp, responses)

Converts relative amplitude to absolute amplitude.

Parameters:
  • rel_amp (float) – relative amplitude in percentage of threshold current

  • responses (dict) – should contain ‘bpo_threshold_current’ and ‘bpo_holding_current’

save_fig(figures_dir, figure_name, dpi=100)

Save a matplotlib figure

update_evaluator(expt_amp_rel, prot_name, evaluator)

update evaluator with new simulation protocols.