Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow stimuli to be non-threshold based #83

Merged
merged 2 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions bluepyemodel/ecode/dehyperpol.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ def depol_amplitude(self):
def instantiate(self, sim=None, icell=None):
"""Run stimulus"""

holding_current = self.holding_current if self.holding_current is not None else 0

icomp = self.location.instantiate(sim=sim, icell=icell)

self.iclamp = sim.neuron.h.IClamp(icomp.x, sec=icomp.sec)
Expand All @@ -114,28 +116,28 @@ def instantiate(self, sim=None, icell=None):
self.time_vec = sim.neuron.h.Vector()

self.time_vec.append(0.0)
self.current_vec.append(self.holding_current)
self.current_vec.append(holding_current)

self.time_vec.append(self.delay)
self.current_vec.append(self.holding_current)
self.current_vec.append(holding_current)

self.time_vec.append(self.delay)
self.current_vec.append(self.holding_current + self.depol_amplitude)
self.current_vec.append(holding_current + self.depol_amplitude)

self.time_vec.append(self.tmid)
self.current_vec.append(self.holding_current + self.depol_amplitude)
self.current_vec.append(holding_current + self.depol_amplitude)

self.time_vec.append(self.tmid)
self.current_vec.append(self.holding_current + self.amplitude)
self.current_vec.append(holding_current + self.amplitude)

self.time_vec.append(self.toff)
self.current_vec.append(self.holding_current + self.amplitude)
self.current_vec.append(holding_current + self.amplitude)

self.time_vec.append(self.toff)
self.current_vec.append(self.holding_current)
self.current_vec.append(holding_current)

self.time_vec.append(self.total_duration)
self.current_vec.append(self.holding_current)
self.current_vec.append(holding_current)

self.iclamp.delay = 0
self.current_vec.play(
Expand All @@ -149,8 +151,10 @@ def generate(self, dt=0.1):
"""Return current time series

WARNING: do not offset ! This is on-top of a holding stimulus."""
holding_current = self.holding_current if self.holding_current is not None else 0

t = numpy.arange(0.0, self.total_duration, dt)
current = numpy.full(t.shape, self.holding_current, dtype="float64")
current = numpy.full(t.shape, holding_current, dtype="float64")

ton = int(self.delay / dt)
tmid = int(self.tmid / dt)
Expand Down
21 changes: 12 additions & 9 deletions bluepyemodel/ecode/hyperdepol.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ def depol_amplitude(self):
def instantiate(self, sim=None, icell=None):
"""Run stimulus"""

holding_current = self.holding_current if self.holding_current is not None else 0

icomp = self.location.instantiate(sim=sim, icell=icell)

self.iclamp = sim.neuron.h.IClamp(icomp.x, sec=icomp.sec)
Expand All @@ -115,28 +117,28 @@ def instantiate(self, sim=None, icell=None):
self.time_vec = sim.neuron.h.Vector()

self.time_vec.append(0.0)
self.current_vec.append(self.holding_current)
self.current_vec.append(holding_current)

self.time_vec.append(self.delay)
self.current_vec.append(self.holding_current)
self.current_vec.append(holding_current)

self.time_vec.append(self.delay)
self.current_vec.append(self.holding_current + self.amplitude)
self.current_vec.append(holding_current + self.amplitude)

self.time_vec.append(self.tmid)
self.current_vec.append(self.holding_current + self.amplitude)
self.current_vec.append(holding_current + self.amplitude)

self.time_vec.append(self.tmid)
self.current_vec.append(self.holding_current + self.depol_amplitude)
self.current_vec.append(holding_current + self.depol_amplitude)

self.time_vec.append(self.toff)
self.current_vec.append(self.holding_current + self.depol_amplitude)
self.current_vec.append(holding_current + self.depol_amplitude)

self.time_vec.append(self.toff)
self.current_vec.append(self.holding_current)
self.current_vec.append(holding_current)

self.time_vec.append(self.total_duration)
self.current_vec.append(self.holding_current)
self.current_vec.append(holding_current)

self.iclamp.delay = 0
self.current_vec.play(
Expand All @@ -150,8 +152,9 @@ def generate(self, dt=0.1):
"""Return current time series

WARNING: do not offset ! This is on-top of a holding stimulus."""
holding_current = self.holding_current if self.holding_current is not None else 0
t = numpy.arange(0.0, self.total_duration, dt)
current = numpy.full(t.shape, self.holding_current, dtype="float64")
current = numpy.full(t.shape, holding_current, dtype="float64")

ton = int(self.delay / dt)
tmid = int(self.tmid / dt)
Expand Down
17 changes: 10 additions & 7 deletions bluepyemodel/ecode/idrest.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ def amplitude(self):
def instantiate(self, sim=None, icell=None):
"""Run stimulus"""

holding_current = self.holding_current if self.holding_current is not None else 0

icomp = self.location.instantiate(sim=sim, icell=icell)

self.iclamp = sim.neuron.h.IClamp(icomp.x, sec=icomp.sec)
Expand All @@ -97,22 +99,22 @@ def instantiate(self, sim=None, icell=None):
self.time_vec = sim.neuron.h.Vector()

self.time_vec.append(0.0)
self.current_vec.append(self.holding_current)
self.current_vec.append(holding_current)

self.time_vec.append(self.delay)
self.current_vec.append(self.holding_current)
self.current_vec.append(holding_current)

self.time_vec.append(self.delay)
self.current_vec.append(self.holding_current + self.amplitude)
self.current_vec.append(holding_current + self.amplitude)

self.time_vec.append(self.stim_end)
self.current_vec.append(self.holding_current + self.amplitude)
self.current_vec.append(holding_current + self.amplitude)

self.time_vec.append(self.stim_end)
self.current_vec.append(self.holding_current)
self.current_vec.append(holding_current)

self.time_vec.append(self.total_duration)
self.current_vec.append(self.holding_current)
self.current_vec.append(holding_current)

self.iclamp.delay = 0
self.current_vec.play(
Expand All @@ -124,9 +126,10 @@ def instantiate(self, sim=None, icell=None):

def generate(self, dt=0.1):
"""Return current time series"""
holding_current = self.holding_current if self.holding_current is not None else 0

t = numpy.arange(0.0, self.total_duration, dt)
current = numpy.full(t.shape, self.holding_current, dtype="float64")
current = numpy.full(t.shape, holding_current, dtype="float64")

ton_idx = int(self.stim_start / dt)
toff_idx = int(self.stim_end / dt)
Expand Down
27 changes: 15 additions & 12 deletions bluepyemodel/ecode/negcheops.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ def amplitude(self):
def instantiate(self, sim=None, icell=None):
"""Run stimulus"""

holding_current = self.holding_current if self.holding_current is not None else 0

icomp = self.location.instantiate(sim=sim, icell=icell)

self.iclamp = sim.neuron.h.IClamp(icomp.x, sec=icomp.sec)
Expand All @@ -120,33 +122,33 @@ def instantiate(self, sim=None, icell=None):
self.time_vec = sim.neuron.h.Vector()

self.time_vec.append(0.0)
self.current_vec.append(self.holding_current)
self.current_vec.append(holding_current)

self.time_vec.append(self.delay)
self.current_vec.append(self.holding_current)
self.current_vec.append(holding_current)
self.time_vec.append(self.delay + self.ramp1_duration)
self.current_vec.append(self.holding_current + self.amplitude)
self.current_vec.append(holding_current + self.amplitude)
self.time_vec.append(self.delay + 2.0 * self.ramp1_duration)
self.current_vec.append(self.holding_current)
self.current_vec.append(holding_current)

start_cheops2 = self.delay + 2.0 * self.ramp1_duration + self.inter_delay
self.time_vec.append(start_cheops2)
self.current_vec.append(self.holding_current)
self.current_vec.append(holding_current)
self.time_vec.append(start_cheops2 + self.ramp2_duration)
self.current_vec.append(self.holding_current + self.amplitude)
self.current_vec.append(holding_current + self.amplitude)
self.time_vec.append(start_cheops2 + 2.0 * self.ramp2_duration)
self.current_vec.append(self.holding_current)
self.current_vec.append(holding_current)

start_cheops3 = start_cheops2 + 2.0 * self.ramp2_duration + self.inter_delay
self.time_vec.append(start_cheops3)
self.current_vec.append(self.holding_current)
self.current_vec.append(holding_current)
self.time_vec.append(start_cheops3 + self.ramp3_duration)
self.current_vec.append(self.holding_current + self.amplitude)
self.current_vec.append(holding_current + self.amplitude)
self.time_vec.append(start_cheops3 + 2.0 * self.ramp3_duration)
self.current_vec.append(self.holding_current)
self.current_vec.append(holding_current)

self.time_vec.append(self.total_duration)
self.current_vec.append(self.holding_current)
self.current_vec.append(holding_current)

self.iclamp.delay = 0
self.current_vec.play(
Expand All @@ -160,9 +162,10 @@ def generate(self, dt=0.1):
"""Return current time series

WARNING: do not offset ! This is on-top of a holding stimulus."""
holding_current = self.holding_current if self.holding_current is not None else 0

t = numpy.arange(0.0, self.total_duration, dt)
current = numpy.full(t.shape, self.holding_current, dtype="float64")
current = numpy.full(t.shape, holding_current, dtype="float64")

idx_ton = int(self.delay / dt)
idx_inter_delay = int(self.inter_delay / dt)
Expand Down
3 changes: 2 additions & 1 deletion bluepyemodel/ecode/noise.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,11 @@ def stim_end(self):

def generate(self, dt=0.1):
"""Return current time series"""
holding_current = self.holding_current if self.holding_current is not None else 0

if dt != 0.1:
raise ValueError(f"For eCode {self.name}, dt has to be 0.1ms.")

current = self.holding_current + self.current_series * (self.mu / 2.0) + self.mu
current = holding_current + self.current_series * (self.mu / 2.0) + self.mu

return self.time_series, current
27 changes: 15 additions & 12 deletions bluepyemodel/ecode/poscheops.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ def amplitude(self):
def instantiate(self, sim=None, icell=None):
"""Run stimulus"""

holding_current = self.holding_current if self.holding_current is not None else 0

icomp = self.location.instantiate(sim=sim, icell=icell)

self.iclamp = sim.neuron.h.IClamp(icomp.x, sec=icomp.sec)
Expand All @@ -123,33 +125,33 @@ def instantiate(self, sim=None, icell=None):
self.time_vec = sim.neuron.h.Vector()

self.time_vec.append(0.0)
self.current_vec.append(self.holding_current)
self.current_vec.append(holding_current)

self.time_vec.append(self.delay)
self.current_vec.append(self.holding_current)
self.current_vec.append(holding_current)
self.time_vec.append(self.delay + self.ramp1_duration)
self.current_vec.append(self.holding_current + self.amplitude)
self.current_vec.append(holding_current + self.amplitude)
self.time_vec.append(self.delay + 2.0 * self.ramp1_duration)
self.current_vec.append(self.holding_current)
self.current_vec.append(holding_current)

start_cheops2 = self.delay + 2.0 * self.ramp1_duration + self.inter_delay
self.time_vec.append(start_cheops2)
self.current_vec.append(self.holding_current)
self.current_vec.append(holding_current)
self.time_vec.append(start_cheops2 + self.ramp2_duration)
self.current_vec.append(self.holding_current + self.amplitude)
self.current_vec.append(holding_current + self.amplitude)
self.time_vec.append(start_cheops2 + 2.0 * self.ramp2_duration)
self.current_vec.append(self.holding_current)
self.current_vec.append(holding_current)

start_cheops3 = start_cheops2 + 2.0 * self.ramp2_duration + self.inter_delay
self.time_vec.append(start_cheops3)
self.current_vec.append(self.holding_current)
self.current_vec.append(holding_current)
self.time_vec.append(start_cheops3 + self.ramp3_duration)
self.current_vec.append(self.holding_current + self.amplitude)
self.current_vec.append(holding_current + self.amplitude)
self.time_vec.append(start_cheops3 + 2.0 * self.ramp3_duration)
self.current_vec.append(self.holding_current)
self.current_vec.append(holding_current)

self.time_vec.append(self.total_duration)
self.current_vec.append(self.holding_current)
self.current_vec.append(holding_current)

self.iclamp.delay = 0
self.current_vec.play(
Expand All @@ -163,9 +165,10 @@ def generate(self, dt=0.1):
"""Return current time series

WARNING: do not offset ! This is on-top of a holding stimulus."""
holding_current = self.holding_current if self.holding_current is not None else 0

t = numpy.arange(0.0, self.total_duration, dt)
current = numpy.full(t.shape, self.holding_current, dtype="float64")
current = numpy.full(t.shape, holding_current, dtype="float64")

idx_ton = int(self.delay / dt)
idx_inter_delay = int(self.inter_delay / dt)
Expand Down
15 changes: 9 additions & 6 deletions bluepyemodel/ecode/ramp.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ def amplitude(self):
def instantiate(self, sim=None, icell=None):
"""Run stimulus"""

holding_current = self.holding_current if self.holding_current is not None else 0

icomp = self.location.instantiate(sim=sim, icell=icell)

self.iclamp = sim.neuron.h.IClamp(icomp.x, sec=icomp.sec)
Expand All @@ -101,19 +103,19 @@ def instantiate(self, sim=None, icell=None):
self.time_vec = sim.neuron.h.Vector()

self.time_vec.append(0.0)
self.current_vec.append(self.holding_current)
self.current_vec.append(holding_current)

self.time_vec.append(self.delay)
self.current_vec.append(self.holding_current)
self.current_vec.append(holding_current)

self.time_vec.append(self.stim_end)
self.current_vec.append(self.holding_current + self.amplitude)
self.current_vec.append(holding_current + self.amplitude)

self.time_vec.append(self.stim_end)
self.current_vec.append(self.holding_current)
self.current_vec.append(holding_current)

self.time_vec.append(self.total_duration)
self.current_vec.append(self.holding_current)
self.current_vec.append(holding_current)

self.iclamp.delay = 0
self.current_vec.play(
Expand All @@ -125,9 +127,10 @@ def instantiate(self, sim=None, icell=None):

def generate(self, dt=0.1):
"""Return current time series"""
holding_current = self.holding_current if self.holding_current is not None else 0

t = numpy.arange(0.0, self.total_duration, dt)
current = numpy.full(t.shape, self.holding_current, dtype="float64")
current = numpy.full(t.shape, holding_current, dtype="float64")

ton_idx = int(self.stim_start / dt)
toff_idx = int((self.stim_end) / dt)
Expand Down
6 changes: 4 additions & 2 deletions bluepyemodel/ecode/random_square_inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ def amplitude(self):
def instantiate(self, sim=None, icell=None):
"""Run stimulus"""

holding_current = self.holding_current if self.holding_current is not None else 0

# Holding current
icomp = self.location.instantiate(sim=sim, icell=icell)

Expand All @@ -107,10 +109,10 @@ def instantiate(self, sim=None, icell=None):
self.time_vec = sim.neuron.h.Vector()

self.time_vec.append(0.0)
self.current_vec.append(self.holding_current)
self.current_vec.append(holding_current)

self.time_vec.append(self.total_duration)
self.current_vec.append(self.holding_current)
self.current_vec.append(holding_current)

self.iclamp.delay = 0
self.current_vec.play(
Expand Down
Loading