<h2>
Annihilation of action potentials induces electrical coupling between neurons
</h2>
This repository contains the code behind our publication
**Please cite as:**
> Schlötter Moritz, Maret Georg, Kleineidam Christoph J (2023) Annihilation of action potentials induces electrical coupling between neurons eLife 12:RP88335
> [doi.org/10.7554/eLife.88335](https://doi.org/10.7554/eLife.88335)
<img src="https://raw.githubusercontent.com/moritz-s/Pyoelectricity/main/collision1.png?raw=true" alt="Colliding Action Potentials"/>
$$
$$
We analyze colliding Action Potentials (APs) in detail to test and refine
models of excitable membranes. The results validate the Tasaki-Matsumoto (TM)
model and confirm its behavior upon collision. The TM model predicts the
extracellular current generated when APs annihilate, such as at synaptic
terminals. This calculation enables the estimation of electric (ephaptic)
coupling with neighboring neurons. Our findings show that neighboring neurons
are especially influenced when Action Potentials annihilate at axon terminals
or when they collide. These predictions align well with experimental observations of
lateral inhibition in Purkinje cells (e.g. [BB2014](https://doi.org/10.1038/nn.3624)).
The code is based on the Python library [brian](https://briansimulator.org/).
We modeled excitation using the
[Tasaki-Matsumoto](https://doi.org/10.1006/bulm.2002.0310) (TM) model and
extended it with a repolarization phase, which we call the Relaxing
Tasaki-Matsumoto (RTM) model. Additionally, we incorporated the effects of
extracellular electric fields through the _Generalized Activating Function_ (see e.g. [here](https://doi.org/10.1007/978-3-030-63355-4)), enabling the calculation of ephaptic interactions.
The source code is available at [osf.io/duyn3/](https://osf.io/duyn3/) and
[moritz-s/Pyoelectricity](https://github.com/moritz-s/Pyoelectricity) and is
explained in our [publication](https://doi.org/10.7554/eLife.88335).
## Examples
- [_test-ExternalField.ipynb_](https://osf.io/9vbxp) Test cases for extracellular fields via pyoelectricity.
- [_standalone-ExternalField.ipynb_](https://osf.io/a746b) How to implement extracellular fields with the _generalized activating function_ in brian.
- [_Example1.ipynb_](https://osf.io/ca4b7) A simple example demonstrating the use of our script to calculate ephaptic interactions (also shown below).
## Source code files
**General**
- [_pyoelectricity.py_](https://osf.io/ztuv2) A collection of functions to calculate propagating and colliding APs, the generated extracellular field, and its influence on surrounding cells.
**Code used in the publication**
- [_ExperimentAnalysis.ipynb_](https://osf.io/8wdrf) Analysis of experimental data. (_data_ folder is deposited in OSF Storage)
- [_end-end.py_](https://osf.io/dpg8u) Calculates the examples of ephaptic coupling at end-end synapses.
- [_end-end-plots.ipynb_](https://osf.io/vgyxz) Generates the figures for end-end synapses.
- [_end-shaft.py_](https://osf.io/p8dma) Calculates the examples of ephaptic coupling at end-shaft synapses.
- [_end-shaft-plots.ipynb_](https://osf.io/bsq4x) Generates the figures for end-shaft synapses.
- [_Pinceau.ipynb_](https://osf.io/wechf) Calculation and plot of the pinceau synapse.
**Dependencies**: brian2 scipy tables tqdm matplotlib jupyter pandas
# Code Example
The following code is available as [_Example1.ipynb_](https://osf.io/ca4b7).
A simple example demonstrating the use of our script to calculate ephaptic interactions.
```python
from brian2 import *
from matplotlib import pyplot as plt
import pyoelectricity as pel
```
# Define and run model
```python
# Define the source morphology
source_morpho = Cylinder(x=[0, 0.5]*cm, diameter=10*um, n=1000)
# Add a bouton at the end with a diameter three times the nominal size
source_morpho.diameter[source_morpho.x>(source_morpho.x[-1]-30*um)] = 30*um
# Define the source model
#source_neuron = pel.make_tasaki_neuron(morpho=source_morpho)
source_neuron = pel.make_repolarizing_neuron(morpho=source_morpho)
#source_neuron = pel.make_hh_neuron(morpho=source_morpho)
# run the source simulation
source_simulation = pel.run_cable(source_neuron,
defaultclock_dt=1*us,
record_dt=1*us,
I_stimulation=0.5*uamp,
post_stim_duration=4*ms)
```
# Check the source AP
```python
v, lambd = pel.get_velocity(source_simulation, is_collision=False)
plt.tight_layout()
```
Theory: 3.41m/s, 0.146mm
Simulation: 3.32m/s, 0.090mm
<img src="https://raw.githubusercontent.com/moritz-s/Pyoelectricity/main/Example1/output_5_1.png?raw=true" alt="Colliding Action Potentials"/>
# Define target and calculate ephaptic effect
```python
# Define the target
target_morpho = Cylinder(x=[0.25, 0.75]*cm, y=[10, 10]*um, diameter=10*um, n=500)
# calculate electric potential at the target
t_ext, v_ext = pel.calculate_V_e_Parallel(source_recording=source_simulation,
target=target_morpho,
sigma=1/(100*ohm*meter))
```
```python
# calculate the impact upon the target
target_simulation = pel.runImpactSimulation(t_ext,
v_ext,
morphology=target_morpho,
Cm=0.01*farad/meter**2,
Ri=1*ohm*meter)
```
```python
plt.figure(figsize=(12, 5))
extent = [target_simulation.t[0]/ms,target_simulation.t[-1]/ms,
(target_morpho.x[0]-target_morpho.x.min())/mm,
(target_morpho.x[-1]-target_morpho.x.min())/mm]
plt.imshow(target_simulation.v/mV, aspect='auto', extent=extent)
plt.colorbar(label='membrane potential [mV]')
plt.xlabel('time [ms]')
plt.ylabel('position [mm]')
plt.setp(plt.gca(), xlim = (1.2, 1.7), ylim=(2, 3))
```
<img src="https://raw.githubusercontent.com/moritz-s/Pyoelectricity/main/Example1/output_9_1.png?raw=true" alt="Colliding Action Potentials"/>
```python
plt.figure(figsize=(12, 5))
plt.plot(target_morpho.x/mm, np.min(target_simulation.v/mV, axis=1), label='Peak hyperpolarization')
plt.plot(target_morpho.x/mm, np.max(target_simulation.v/mV, axis=1), label='Peak depolarization')
plt.legend()
plt.title('Maximal effect along the target')
plt.xlabel("position [mm]")
plt.ylabel("membrane potential [mV]")
```
<img src="https://raw.githubusercontent.com/moritz-s/Pyoelectricity/main/Example1/output_10_1.png?raw=true" alt="Colliding Action Potentials"/>