Skip to content

Clamping of Synapse: Following Synapse might also be clamped #485

@deezer257

Description

@deezer257

If I create a network where cells are connected via RibbonSynapses, and I apply a data clamp to one of the RibbonSynapses, not only is the current synapse clamped to the defined value, but also the next synapse in sequence (with an incremented index). Further, it doesn't matter which method I use to index the synapses (so if I use the pre or post synapsing indexing or the indexing via the edges). An example is attatched:

Jax version: 0.4.35

import matplotlib.pyplot as plt
import jaxley as jx
import jax
from jaxley_mech.synapses.ribbon import RibbonSynapse
from jaxley.connect import  connect
from jaxley_mech.channels.hodgkin52 import Leak, Na, K
import jax.numpy as jnp
import numpy as np


from jax import config
config.update("jax_enable_x64", True)
config.update("jax_platform_name", "gpu")

# Create a new dummy network
comp_opt = jx.Compartment()
branch_opt = jx.Branch(comp_opt, nseg=1)
cell_opt = jx.Cell([branch_opt], [-1])
net_opt = jx.Network(cells=[cell_opt] * 4)


# Insert the leak channel into the cell
net_opt.insert(Leak())
net_opt.insert(Na())
net_opt.insert(K())

v_rest = -70

# Set the resting potential of the cell and also to equilibrium of the
# leak channel to the resting potential, so that the overall resting
# potential of the cell is the resting potential
net_opt.set('v', v_rest)
net_opt.set('Leak_eLeak', v_rest)



# Define the pre, middle and post cell
first = net_opt.cell(0)
second = net_opt.cell(1)
third = net_opt.cell(2)
fourth = net_opt.cell(3)

# Connect the cells with the ribbon synapse
connect(first, second, RibbonSynapse(solver = "newton"))
connect(second, third, RibbonSynapse(solver = "newton"))
connect(third, fourth, RibbonSynapse(solver = "newton"))

net_opt.cell([0,1]).set('RibbonSynapse_V_half', v_rest/2)
net_opt.cell([1,2]).set('RibbonSynapse_V_half', v_rest/2)
net_opt.cell([2,3]).set('RibbonSynapse_V_half', v_rest/2)
net_opt.cell('all').set('RibbonSynapse_gS', 0)

# Parameters
time_max = 1000
dt = 1
time_steps = int((time_max + dt)  / dt)

# Time vector
time_vec = jnp.arange(0.0, time_max, dt)

# Generate a base signal with a Gaussian function
mean = (time_max / 2) - 100  # Center of the Gaussian
std_dev = 100  # Standard deviation of the Gaussian
base_signal = (np.exp(-0.5 * ((time_vec - mean) / std_dev) ** 2)) * 3 +2

# Get a 2d array of inputs by putting the base signal in the first column
# and the base signal shifted by 1 in the second column
inputs = jnp.array([time_vec, base_signal]).T

# Integrate the network without using vmap and jit
net_opt.delete_recordings()
net_opt.delete_stimuli()

#net_opt.cell([0,1]).record("RibbonSynapse_exo")
#net_opt.cell([1,2]).record("RibbonSynapse_exo")
#net_opt.cell([2,3]).record("RibbonSynapse_exo")

net_opt.RibbonSynapse.edge(0).record("RibbonSynapse_exo", verbose = False)
net_opt.RibbonSynapse.edge(1).record("RibbonSynapse_exo", verbose = False)
net_opt.RibbonSynapse.edge(2).record("RibbonSynapse_exo", verbose = False)

net_opt.cell(0).record("v")
net_opt.cell(1).record("v")
net_opt.cell(2).record("v")
net_opt.cell(3).record("v")

data_clamps = None
# Input are the y-values of the inputs
#data_clamps = net_opt.cell([0,1]).data_clamp("RibbonSynapse_exo", inputs[:,1], data_clamps = data_clamps)
data_clamps = net_opt.edge(0).data_clamp("RibbonSynapse_exo", inputs[:,1], data_clamps = data_clamps)

# Integrate the network
s = jx.integrate(net_opt, 
                data_clamps = data_clamps,
                solver = "bwd_euler")

fig, ax = plt.subplots(s.shape[0], 1, figsize=(10, 20))
# Increase space between subplots
plt.subplots_adjust(hspace=1)

# Loop over the subplots and plot each synapse
for i in range(s.shape[0]):
    ax[i].plot(s[i, :])
    if i < 3:
        ax[i].set_title(f"Synapse {i + 1}")
    else:
        ax[i].set_title(f"Mmebrance Voltage Cell {i - 3}")
        

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions