Electrophysiology

dendrotweaks.analysis.ephys_analysis.get_somatic_data(model)[source]

Get the somatic voltage, time, time step, and injected current.

Parameters:

model (Model) – The neuron model.

Returns:

A tuple containing the voltage, time, time step, and injected current.

Return type:

tuple

dendrotweaks.analysis.ephys_analysis.calculate_input_resistance(model)[source]

Calculate the input resistance of the neuron model.

This function determines the input resistance by calculating the ratio between the voltage change and the injected current. The voltage change is measured as the difference between the membrane potential at the onset and offset of the current injection.

Parameters:

model (Model) – The neuron model.

Returns:

A dictionary containing the onset and offset voltages, the input resistance, and the injected current.

Return type:

dict

dendrotweaks.analysis.ephys_analysis.calculate_time_constant(model)[source]

Estimate the passive membrane time constant (τm) by fitting a double exponential to the somatic voltage decay and selecting the slowest τ component.

Parameters:

model (Model) – The neuron model (assumes Ih is disabled).

Returns:

A dictionary with τm (slowest), both τs, and fit details.

Return type:

dict

dendrotweaks.analysis.ephys_analysis.calculate_passive_properties(model)[source]

Calculate the passive properties of the neuron model.

Parameters:

model (Model) – The neuron model.

Returns:

A dictionary containing the input resistance, time constant, and the exponential fit.

Return type:

dict

dendrotweaks.analysis.ephys_analysis.plot_passive_properties(data, ax=None)[source]
dendrotweaks.analysis.ephys_analysis.detect_somatic_spikes(model, **kwargs)[source]

Detect somatic spikes in the model and calculate spike amplitudes and widths.

Returns:

A dictionary containing spike metrics.

Return type:

dict

dendrotweaks.analysis.ephys_analysis.plot_somatic_spikes(data, ax=None, show_metrics=False)[source]

Plot detected spikes on the provided axis or create a new figure.

Parameters:
  • model – The neuron model

  • ax – Optional matplotlib axis for plotting

Returns:

The plot axis

Return type:

matplotlib.axes.Axes

dendrotweaks.analysis.ephys_analysis.calculate_fI_curve(model, duration=1000, prerun_time=0, min_amp=0, max_amp=1, n=5, **kwargs)[source]

Calculate the frequency-current (f-I) curve of the neuron model.

Parameters:
  • model (Model) – The neuron model.

  • duration (int) – Duration of the simulation in ms.

  • min_amp (float) – Minimum amplitude of the current injection in nA.

  • max_amp (float) – Maximum amplitude of the current injection in nA.

  • n (int) – Number of amplitudes to test.

Returns:

A dictionary containing the current amplitudes, firing rates, and voltages.

Return type:

dict

dendrotweaks.analysis.ephys_analysis.plot_fI_curve(data, ax=None, vshift=200, **kwargs)[source]

Plot the f-I curve and somatic voltage traces.

Parameters:
  • data (dict) – A dictionary containing the current amplitudes, firing rates, and voltages. Can be obtained from calculate_fI_curve.

  • ax (matplotlib.axes.Axes, optional) – The axes to plot on. If two axes are provided, the first will show the somatic voltage traces and the second will show the f-I curve. If a single axis is provided, it will show the f-I curve only. If None, a new figure will be created.

  • vshift (int, optional) – The vertical shift for the somatic voltage traces. Default is 200.

dendrotweaks.analysis.ephys_analysis.calculate_voltage_attenuation(model)[source]

Calculate the voltage attenuation along the dendrites.

Parameters:

model (Model) – The neuron model.

Returns:

A dictionary containing the path distances, minimum voltages, and voltage attenuations

Return type:

dict

dendrotweaks.analysis.ephys_analysis.plot_voltage_attenuation(data, ax=None)[source]
dendrotweaks.analysis.ephys_analysis.calculate_dendritic_nonlinearity(model, duration=1000, prerun_time=0, max_weight=None, n=None)[source]

Calculate the expected and observed voltage changes for a range of synaptic weights.

Parameters:
  • model (Model) – The neuron model.

  • duration (int) – Duration of the simulation in ms.

  • max_weight (int) – Maximum synaptic weight to test.

Returns:

A dictionary containing the expected and observed voltage changes.

Return type:

dict

dendrotweaks.analysis.ephys_analysis.plot_dendritic_nonlinearity(data, ax=None, vshift=200, **kwargs)[source]

Plot the dendritic nonlinearity based on expected and observed voltage changes.

Parameters:
  • data (dict) – A dictionary containing the expected and observed voltage changes. Can be obtained from calculate_dendritic_nonlinearity.

  • ax (matplotlib.axes.Axes, optional) – The axes to plot on. If two axes are provided, the first will show the voltage traces and the second will show the dendritic nonlinearity. If a single axis is provided, it will show the dendritic nonlinearity only. If None, a new figure will be created.

  • vshift (int, optional) – The vertical shift for the voltage traces.

dendrotweaks.analysis.ephys_analysis.calculate_sag_ratio(model)[source]

Calculate the sag ratio of the neuron model.

Parameters:

model (Model) – The neuron model.

Returns:

A dictionary containing the sag ratio and intermediate values.

Return type:

dict