pyneuroml.analysis package#
- pyneuroml.analysis.analyse_spiketime_vs_dt(nml2_file, target, duration, simulator, cell_v_path, dts, verbose=False, spike_threshold_mV=0, show_plot_already=True, save_figure_to=None, num_of_last_spikes=None)#
- pyneuroml.analysis.generate_current_vs_frequency_curve(nml2_file: str, cell_id: str, start_amp_nA: float = -0.1, end_amp_nA: float = 0.1, step_nA: float = 0.01, custom_amps_nA: List[float] = [], analysis_duration: float = 1000, analysis_delay: float = 0, pre_zero_pulse: float = 0, post_zero_pulse: float = 0, dt: float = 0.05, temperature: str = '32degC', spike_threshold_mV: float = 0.0, plot_voltage_traces: bool = False, plot_if: bool = True, plot_iv: bool = False, xlim_if: List[float] | None = None, ylim_if: List[float] | None = None, xlim_iv: List[float] | None = None, ylim_iv: List[float] | None = None, label_xaxis: bool = True, label_yaxis: bool = True, show_volts_label: bool = True, grid: bool = True, font_size: int = 12, if_iv_color: str = 'k', linewidth: str = '1', bottom_left_spines_only: bool = False, show_plot_already: bool = True, save_voltage_traces_to: str | None = None, save_if_figure_to: str | None = None, save_iv_figure_to: str | None = None, save_if_data_to: str | None = None, save_iv_data_to: str | None = None, simulator: str = 'jNeuroML', num_processors: int = 1, include_included: bool = True, title_above_plot: bool = False, return_axes: bool = False, verbose: bool = False, segment_id: str | None = None, fraction_along: float | None = None)#
Generate current vs firing rate frequency curves for provided cell.
It runs a number of simulations of the cell with different input currents, and generates the following metrics/graphs:
sub-threshold potentials for all currents
F-I curve for the cell
membrane potential traces for each stimulus
Using the method arguments, these graphs and the data they are generated from may be enabled/disabled/saved.
When the I-F curve plotting is enabled, it also notes the spiking threshold current value in a file. Note that this value is simply the lowest input stimulus current at which spiking was detected, so should be taken as an approximate value. It does not, for example, implement a bisection based method to find the accurate spiking threshold current. This is also true for the I-F curves: the resolution is constrained by the values of the stimulus currents.
The various plotting related arguments to this method are passed on to
pyneuroml.plot.generate_plot()
- Parameters:
nml2_file (str) – name of NeuroML file containing cell definition
cell_id (str) – id of cell to analyse
start_amp_nA (float) – min current to use for analysis
end_amp_nA (float) – max current to use for analysis
step_nA (float) – step value to use to generate analysis currents between start_amp_nA and end_amp_nA
custom_amps_nA – list of currents in nA to use. Note that this overrides the list created using start_amp_nA, end_amp_nA, and step_nA) :type custom_amps_nA: list(float)
analysis_duration (float) – duration of analysis
analysis_delay (float) – delay period before analysis begins
pre_zero_pulse (float) – duration of pre-zero pulse
post_zero_pulse (float) – duration of post-zero pulse
dt (float) – integration time step
temperature (str) – temperature to use for analysis
spike_threshold_mV (float) – spike threshold potential
plot_voltage_traces (bool) – toggle plotting of voltage traces
plot_if (bool) – toggle whether to plot I-F graphs
plot_iv (bool) – toggle whether to plot I-V graphs
xlim_if ([min, max]) – x-limits of I-F curve
ylim_if ([min, max]) – y limits of I-F curve
xlim_iv ([min, max]) – x limits of I-V curve
ylim_iv ([min, max]) – y limits of I-V curve
label_xaxis (str) – label for x axis
label_yaxis (str) – label for y axis
show_volts_label (bool) – toggle whether voltage traces should have corresponding current values labelled in the plot
grid (bool) – toggle whether grid should be shown in plot
font_size (int) – font size for plot
if_iv_color (str) – color to use for I-F and I-V plots
linewidth (str) – line width for plotting
bottom_left_spines_only
show_plot_already (bool) – toggle whether generated plots should be shown
save_voltage_traces_to (str) – file to save membrane potential traces to
save_if_figure_to (str) – file to save I-F plot figure to
save_iv_figure_to (str) – file to save I-V plot figure to
save_if_data_to (str) – file to save I-F plot data to
save_iv_data_to (str) – file to save I-V plot data to
simulator (str) – simulator to use
num_processors (int) – number of processors to use for analysis This option is only used with NetPyNE which can use MPI for parallelising simulations. For other simulators, this is unused.
include_included (bool) – include included files
title_above_plot (str) – title to show above the plot
return_axes (bool) – toggle whether plotting axis should be returned. This is useful if one wants to overlay more graphs in the same plot.
segment_id (str) – segment id to attach input to
fraction_along (float) – fraction along on segment to attach to
verbose (bool) – toggle verbosity
pyneuroml.analysis.NML2ChannelAnalysis module#
- pyneuroml.analysis.NML2ChannelAnalysis.compute_iv_curve(channel, a, results, grid=True)#
- pyneuroml.analysis.NML2ChannelAnalysis.generate_lems_channel_analyser(channel_file: str, channel: str, min_target_voltage: float, step_target_voltage: float, max_target_voltage: float, clamp_delay: float, clamp_duration: float, clamp_base_voltage: float, duration: float, erev: float, gates: List[str], temperature: float, ca_conc: float, iv_curve: bool, scale_dt: float = 1, dat_suffix: str = '', verbose: bool = True)#
Generate analysis simulation LEMS file.
- Parameters:
channel_file (str) – path to channel file
channel (string) – name of channel
min_target_voltage (float) – magnitude of minimum target voltage in mV
max_target_voltage (float) – magnitude of maximum target voltage in mV
clamp_delay (float) – magnitude of delay for clamp in ms
clamp_duration – magnitude of duration of clamp in ms
clamp_base_voltage (float) – magnitude of base voltage of clamp in mV
duration (float) – magnitude of duration of simulation in ms
erev (float) – magnitude of reversal potential in mV
gates (list of str) – list of gates
temperature (float) – magnitude of temperature in degC
ca_conc (float) – magnitude of calcium concentration in mM
iv_curve (bool) – toggle whether to plot iv curve
scale_dt (float) – magnitude to scale dt by in ms
dat_suffix (str) – suffix of data file
verbose (bool) – toggle verbosity
- pyneuroml.analysis.NML2ChannelAnalysis.get_channel_gates(channel: IonChannel | IonChannelHH) List[GateHHUndetermined | GateHHRates | GateHHTauInf | GateHHInstantaneous] #
Get gates in a channel
- Parameters:
channel (neuroml.IonChannel, neuroml.IonChannelHH) – channel object
- Returns:
list of gates
- Return type:
list
- pyneuroml.analysis.NML2ChannelAnalysis.get_channels_from_channel_file(channel_file: str) List[IonChannelHH | IonChannel] #
Get IonChannelHH and IonChannel instances from a NeuroML channel file.
- Parameters:
channel_file (str) – complete path to a channel file
- Returns:
list of channels
- Return type:
list
- Raises:
ValueError – if no channels were found in the file
- pyneuroml.analysis.NML2ChannelAnalysis.get_conductance_expression(channel: IonChannel | IonChannelHH) str #
Get expression of conductance in channel.
- Parameters:
channel (neuroml.IonChannel, neuroml.IonChannelHH) – channel object
- Returns:
expression for conductance of channel.
- Return type:
str
- pyneuroml.analysis.NML2ChannelAnalysis.get_includes_from_channel_file(channel_file: str) List[IncludeType] #
Get includes from a NeuroML channel file
- Parameters:
channel_file (str) – complete path to a channel file
- Returns:
list of includes
- Return type:
list
- pyneuroml.analysis.NML2ChannelAnalysis.get_ks_channel_states(channel: IonChannelKS) Dict[str, List[str]] #
Get states for a kinetic state style ion channel
Added in version 1.2.15.
- Parameters:
channel (neuroml.IonChannelKS) – kinetic state style channel to get states from
- Returns:
dict with gate id as key, and list of states as value
- pyneuroml.analysis.NML2ChannelAnalysis.make_html_file(info)#
- pyneuroml.analysis.NML2ChannelAnalysis.make_iv_curve_fig(a, grid=True)#
- pyneuroml.analysis.NML2ChannelAnalysis.make_lems_file(channel, a)#
- pyneuroml.analysis.NML2ChannelAnalysis.make_md_file(info)#
- pyneuroml.analysis.NML2ChannelAnalysis.make_overview_dir()#
- pyneuroml.analysis.NML2ChannelAnalysis.merge_with_template(model: Dict[Any, Any], templfile: str) str #
Merge model information with airspeed template.
- Parameters:
model (dict) – model information
templfile (string) – name of airspeed template file
- Returns:
merged template string
- Return type:
str
- pyneuroml.analysis.NML2ChannelAnalysis.plot_channel(channel, a, results, iv_data=None, grid=True)#
- pyneuroml.analysis.NML2ChannelAnalysis.plot_iv_curve(a, hold_v, i, *plt_args, **plt_kwargs)#
A single IV curve
- pyneuroml.analysis.NML2ChannelAnalysis.plot_iv_curve_vm(channel, a, hold_v, times, currents, grid=True)#
- pyneuroml.analysis.NML2ChannelAnalysis.plot_iv_curves(channel, a, iv_data, grid=True)#
- pyneuroml.analysis.NML2ChannelAnalysis.plot_kinetics(channel, a, results, grid=True)#
- pyneuroml.analysis.NML2ChannelAnalysis.plot_steady_state(channel, a, results, grid=True)#
- pyneuroml.analysis.NML2ChannelAnalysis.process_channel_file(channel_file: str, a) List[Any] #
Process the channel file.
- Parameters:
channel_file (str) – complete path to channel file
a (argparse.Namsepace) – argparse.Namespace instance holding all arguments
- Returns:
list of channel information
- Return type:
list
- Raises:
IOError – if channel file could not be found
- pyneuroml.analysis.NML2ChannelAnalysis.run(a=None, **kwargs)#
- pyneuroml.analysis.NML2ChannelAnalysis.run_lems_file(lems_file, verbose)#
- pyneuroml.analysis.NML2ChannelAnalysis.save_fig(name)#
pyneuroml.analysis.ChannelDensityPlot module#
- pyneuroml.analysis.ChannelDensityPlot.add_text(row, text)#
- pyneuroml.analysis.ChannelDensityPlot.channel_density_plotter_cli(args=None)#
- pyneuroml.analysis.ChannelDensityPlot.channel_density_plotter_process_args()#
Parse command-line arguments.
- Returns:
None
- pyneuroml.analysis.ChannelDensityPlot.channel_density_plotter_runner(a=None, **kwargs)#
- pyneuroml.analysis.ChannelDensityPlot.format_float(dens)#
- pyneuroml.analysis.ChannelDensityPlot.generate_channel_density_plots(nml2_file, text_densities=False, passives_erevs=False, target_directory=None)#
- pyneuroml.analysis.ChannelDensityPlot.get_channel_densities(nml_cell: Cell) Dict[str, List[ChannelDensity | ChannelDensityGHK | ChannelDensityGHK2 | ChannelDensityVShift | ChannelDensityNernst | ChannelDensityNernstCa2 | ChannelDensityNonUniform | ChannelDensityNonUniformGHK | ChannelDensityNonUniformNernst]] #
Get channel densities from a NeuroML Cell.
- Parameters:
nml_cell (neuroml.Cell) – a NeuroML cell object
- Returns:
ordered dictionary of channel densities on cell with the ion channel id as the key, and list of channel density objects as the value
- pyneuroml.analysis.ChannelDensityPlot.get_conductance_density_for_segments(cell: Cell, channel_density: ChannelDensity | ChannelDensityGHK | ChannelDensityGHK2 | ChannelDensityVShift | ChannelDensityNernst | ChannelDensityNernstCa2 | ChannelDensityNonUniform | ChannelDensityNonUniformGHK | ChannelDensityNonUniformNernst, seg_ids: str | List[str] | None = None) Dict[int, float] #
Get conductance density for provided segments to be able to generate a morphology plot.
If no segment ids are provided, provide values for all segments that the channel density is present on.
For uniform channel densities, the value is reported in SI units, but for non-uniform channel densities, for example ChannelDensityNonUniform, where the conductance density can be a function of an arbitrary variable, like distance from soma, the conductance density can be provided by an arbitrary function. In this case, the units of the conductance are not reported since the arbitrary function only provides a magnitude.
For non-uniform channel densities, we evaluate the provided expression using sympy.sympify.
- Parameters:
cell (Cell) – a NeuroML Cell
seg_ids (None or str or list(str)) – segment id or list of segment ids to report, if None, report on all segments that channel density is present
channel_density (ChannelDensityGHK or ChannelDensityGHK2 or ChannelDensityVShift or ChannelDensityNernst or ChannelDensityNernstCa2 or ChannelDensityNonUniform or ChannelDensityNonUniformGHK or ChannelDensityNonUniformNernst,) – a channel density object
- Returns:
dictionary with keys as segment ids and the conductance density for that segment as the value
Added in version 1.0.10.
- pyneuroml.analysis.ChannelDensityPlot.plot_channel_densities(cell: Cell, channel_density_ids: str | List[str] | None = None, ion_channels: str | List[str] | None = None, ymin: float | None = None, ymax: float | None = None, colormap_name: str = 'autumn_r', plane2d: str = 'xy', distance_plots: bool = False, show_plots_already: bool = True, morph_plot_type: str = 'constant', morph_min_width: float = 2.0, target_directory=None)#
Plot channel densities on a Cell on morphology plots.
You can either provide a list of channel densities where it’ll generate one plot per channel density. Or, you can provide a list of ions, and it’ll generate one plot per ion—adding up the conductance densities of the different channel densities for that ion. If neither are provided, plots for all ion channels on the cell are generated.
Added in version 1.0.10.
- Parameters:
cell (neuroml.Cell) – a NeuroML cell object
channel_density_ids (str or list(str)) – a channel density id or list of ids
ion_channels (str or list(str)) – an ion channel or list of ions channels
ymin (float or None) – min y value for plots, if None, automatically calculated
ymax (float or None) – max y value for plots, if None, automatically calculated
plane2d (str "xy" or "yz" or "zx") – plane to plot morphology plot in, passed on to the :py:function::plot_2D_cell_morphology function
morph_plot_type (str) – plot type for morphology plot passed on to plot_2D_cell_morphology
morph_min_width (float) – min width for morphology plot passed on to plot_2D_cell_morphology
distance_plots (bool) – also generate plots showing conductance densities at distances from the soma
colormap_name (str) –
name of matplotlib colormap to use for morph plot. Note that if there’s only one overlay value, the colormap is modified to only show the max value of the colormap to indicate this.
See: https://matplotlib.org/stable/users/explain/colors/colormaps.html
- Returns:
None
pyneuroml.analysis.ChannelHelper module#
- pyneuroml.analysis.ChannelHelper.evaluate_HHExpLinearRate(rate, midpoint, scale, v)#
Helper for putting values into HHExpLinearRate, see also https://docs.neuroml.org/Userdocs/Schemas/Channels.html#hhexplinearrate
- pyneuroml.analysis.ChannelHelper.evaluate_HHExpRate(rate, midpoint, scale, v)#
Helper for putting values into HHExpRate, see also https://docs.neuroml.org/Userdocs/Schemas/Channels.html#hhexprate
- pyneuroml.analysis.ChannelHelper.evaluate_HHSigmoidRate(rate, midpoint, scale, v)#
Helper for putting values into HHSigmoidRate, see also https://docs.neuroml.org/Userdocs/Schemas/Channels.html#hhsigmoidrate