Skip to content

Commit

Permalink
Merge pull request #664 from apdavison/if_curr_delta
Browse files Browse the repository at this point in the history
Add `IF_curr_delta` model
  • Loading branch information
apdavison committed Jun 16, 2022
2 parents 2bd75ae + 65dac18 commit 99cb268
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 10 deletions.
32 changes: 24 additions & 8 deletions examples/synaptic_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,18 @@
initial_values={"v": [-65, -55]}, label="Exponential, conductance-based")
coba_alpha = sim.Population(2, sim.IF_cond_alpha(tau_m=10.0, i_offset=[0.0, 1.0]),
initial_values={"v": [-65, -55]}, label="Alpha, conductance-based")
v_step = sim.Population(2, sim.Izhikevich(i_offset=[0.0, 0.002]),
initial_values={"v": [-70, -67], "u": [-14, -13.4]}, label="Izhikevich")
v_step_izh = sim.Population(2, sim.Izhikevich(i_offset=[0.0, 0.002]),
initial_values={"v": [-70, -67], "u": [-14, -13.4]}, label="Izhikevich")

all_neurons = cuba_exp + cuba_alpha + coba_exp + coba_alpha + v_step_izh

try:
v_step_if = sim.Population(2, sim.IF_curr_delta(tau_m=10.0, i_offset=[0.0, 1.0]),
initial_values={"v": [-65, -55]}, label="Voltage step")
except NotImplementedError:
v_step_if = None
else:
all_neurons += v_step_if

# we next create a spike source, which will emit spikes at the specified times

Expand All @@ -56,13 +66,11 @@

# now we connect the spike source to each of the neuron populations, with differing synaptic weights

all_neurons = cuba_exp + cuba_alpha + coba_exp + coba_alpha + v_step

connections = [sim.Projection(stimulus, population,
connector=sim.AllToAllConnector(),
synapse_type=sim.StaticSynapse(weight=w, delay=2.0),
receptor_type="excitatory")
for population, w in zip(all_neurons.populations, [1.6, 4.0, 0.03, 0.12, 1.0])]
for population, w in zip(all_neurons.populations, [1.6, 4.0, 0.03, 0.12, 2.0, 4.0])]

# finally, we set up recording of the membrane potential

Expand Down Expand Up @@ -96,7 +104,7 @@
if options.plot_figure:
from pyNN.utility.plotting import Figure, Panel
figure_filename = filename.replace("pkl", "png")
Figure(
panels = [
Panel(cuba_exp.get_data().segments[0].filter(name='v')[0],
ylabel="Membrane potential (mV)",
data_labels=[cuba_exp.label], yticks=True, ylim=(-66, -50)),
Expand All @@ -106,9 +114,17 @@
data_labels=[coba_exp.label], yticks=True, ylim=(-66, -50)),
Panel(coba_alpha.get_data().segments[0].filter(name='v')[0],
data_labels=[coba_alpha.label], yticks=True, ylim=(-66, -50)),
Panel(v_step.get_data().segments[0].filter(name='v')[0],
Panel(v_step_izh.get_data().segments[0].filter(name='v')[0],
xticks=True, xlabel="Time (ms)",
data_labels=[v_step.label], yticks=True, ylim=(-71, -65)),
data_labels=[v_step_izh.label], yticks=True, ylim=(-71, -65))
]
if v_step_if:
panels.insert(-1,
Panel(v_step_if.get_data().segments[0].filter(name='v')[0],
data_labels=[v_step_if.label], yticks=True, ylim=(-66, -50)),
)
Figure(
*panels,
title="Responses of standard neuron models to synaptic input",
annotations="Simulated with %s" % options.simulator.upper()
).save(figure_filename)
Expand Down
16 changes: 15 additions & 1 deletion pyNN/brian2/standardmodels/cells.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@
tau_syn_i : second
''')

voltage_step_synapses = brian2.Equations('''
i_syn = 0 * amp : amp
''')

leaky_iaf_translations = build_translations(
('v_rest', 'v_rest', lambda **p: p["v_rest"] * mV, lambda **p: p["v_rest"] / mV),
('v_reset', 'v_reset', lambda **p: p["v_reset"] * mV, lambda **p: p["v_reset"] / mV),
Expand Down Expand Up @@ -156,7 +160,6 @@
('gsyn_exc', 'ge', lambda p: p * uS, lambda p: p/ uS),
('gsyn_inh', 'gi', lambda p: p * uS, lambda p: p/ uS))
current_based_variable_translations = build_translations(

('v', 'v', lambda p: p * mV, lambda p: p/ mV), #### change p by p["v"]
('isyn_exc', 'ie', lambda p: p * nA, lambda p: p/ nA),
('isyn_inh', 'ii', lambda p: p * nA, lambda p: p/ nA))
Expand All @@ -182,6 +185,17 @@ class IF_curr_exp(cells.IF_curr_exp):
brian2_model = ThresholdNeuronGroup


class IF_curr_delta(cells.IF_curr_delta):
__doc__ = cells.IF_curr_delta.__doc__
eqs = leaky_iaf + voltage_step_synapses
translations = deepcopy(leaky_iaf_translations)
state_variable_translations = build_translations(
('v', 'v', lambda p: p * mV, lambda p: p/ mV),
)
post_synaptic_variables = {'excitatory': 'v', 'inhibitory': 'v'}
brian2_model = ThresholdNeuronGroup


class IF_cond_alpha(cells.IF_cond_alpha):
__doc__ = cells.IF_cond_alpha.__doc__
eqs = leaky_iaf + conductance_based_alpha_synapses
Expand Down
23 changes: 23 additions & 0 deletions pyNN/nest/standardmodels/cells.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,29 @@ class IF_curr_exp(cells.IF_curr_exp):
standard_receptor_type = True


class IF_curr_delta(cells.IF_curr_delta):

__doc__ = cells.IF_curr_delta.__doc__

translations = build_translations(
('v_rest', 'E_L'),
('v_reset', 'V_reset'),
('cm', 'C_m', 1000.0), # C_m is in pF, cm in nF
('tau_m', 'tau_m'),
('tau_refrac', 't_ref'),
('v_thresh', 'V_th'),
('i_offset', 'I_e', 1000.0), # I_e is in pA, i_offset in nA
)
# extra parameters in the NEST model
# V_min mV Absolute lower value for the membrane potenial
# refractory_input boolean If true, do not discard input during
# refractory period. Default: false
nest_name = {"on_grid": 'iaf_psc_delta',
"off_grid": 'iaf_psc_delta_ps'}
standard_receptor_type = True
receptor_scale = 1e-3 # synaptic weight is in mV, so need to undo usual weight scaling


class IF_cond_alpha(cells.IF_cond_alpha):

__doc__ = cells.IF_cond_alpha.__doc__
Expand Down
6 changes: 5 additions & 1 deletion pyNN/neuron/standardmodels/cells.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"""

from pyNN.standardmodels import cells as base_cells, build_translations
from pyNN.standardmodels import ModelNotAvailable, cells as base_cells, build_translations
from pyNN.neuron.cells import (StandardIF, SingleCompartmentTraub,
RandomSpikeSource, VectorSpikeSource,
RandomGammaSpikeSource,
Expand Down Expand Up @@ -59,6 +59,10 @@ class IF_curr_exp(base_cells.IF_curr_exp):
'syn_shape': 'exp'}


class IF_curr_delta(ModelNotAvailable):
pass


class IF_cond_alpha(base_cells.IF_cond_alpha):

__doc__ = base_cells.IF_cond_alpha.__doc__
Expand Down
33 changes: 33 additions & 0 deletions pyNN/standardmodels/cells.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,39 @@ class IF_curr_exp(StandardCellType):
}


class IF_curr_delta(StandardCellType):
"""
Leaky integrate and fire model with fixed threshold.
Synaptic inputs produce step changes in membrane potential.
"""

default_parameters = {
'v_rest': -65.0, # Resting membrane potential in mV.
'cm': 1.0, # Capacity of the membrane in nF
'tau_m': 20.0, # Membrane time constant in ms.
'tau_refrac': 0.1, # Duration of refractory period in ms.
'i_offset': 0.0, # Offset current in nA
'v_reset': -65.0, # Reset potential after a spike in mV.
'v_thresh': -50.0, # Spike threshold in mV.
}
recordable = ['spikes', 'v']
conductance_based = False
voltage_based_synapses = True
default_initial_values = {
'v': -65.0,
}
units = {
'v': 'mV',
'v_rest': 'mV',
'cm': 'nF',
'tau_m': 'ms',
'tau_refrac': 'ms',
'i_offset': 'nA',
'v_reset': 'mV',
'v_thresh': 'mV',
}


class IF_cond_alpha(StandardCellType):
"""
Leaky integrate and fire model with fixed threshold and alpha-function-
Expand Down

0 comments on commit 99cb268

Please sign in to comment.