Hey there! I’m hoping I could get some help on the following in terms of 1) debugging and 2) understanding.
I have the following code and it errors on the following line: neu.v_ext = v_ext
with Quantities can only be created from numerical data.
. v_ext
is defined as
_start = 0
_stop = 1_000 * ms
_step = 0.2 * ms
times = np.linspace(_start, _stop, int((_stop - _start) / _step + 1))
values = external_input ones(len(times)) # Initialize with zeros
# Create a TimedArray
v_ext = TimedArray(values, dt=_step)
which, I think is numerical? Unless it meansthat it wants a scalar value(?).
My end goal is a follow up from Modeling an external input voltage to the circuit? - #2 by mstimberg
The following is what I have so far: I create my “current injections”, define my circuit, and apply my current to all neurons in the circuit. Obviously, my understanding is breaking down somewhere
external_input = 1 * mV
print(f"INFO: Applying {} at every time-step")
_start = 0
_stop = 1_000 * ms
_step = 0.2 * ms
times = np.linspace(_start, _stop, int((_stop - _start) / _step + 1))
values = external_input ones(len(times)) # Initialize with zeros
# Create a TimedArray
v_ext = TimedArray(values, dt=_step)
eqs = """
dv/dt = (v_0 - v + g + v_ext) / t_mbr : volt (unless refractory)
dg/dt = -g / tau : volt (unless refractory)
rfc : second
v_ext : volt (constant)
"""
neu = NeuronGroup( # create neurons
N=len(connectivity_matrix),
model=eqs,
method="linear",
threshold= "v > v_th",
reset='v = v_rst; w = 0; g = 0 * mV',
name="default_neurons",
)
neu.v_ext = v_ext
neu.v = -52 * mV
neu.g = 0
neu.rfc = 0.275 * mV
################################################
# Then, populate the synapses
################################################
sources, targets = connectivity_matrix.nonzero()
syn = Synapses(
neu, neu, "w : volt", on_pre="g += w", delay=-1.8 * ms, name="default_synapses"
)
syn.connect(i=sources, j=targets)
weight_per_synapse = 0.275 * mV
syn.w[:] = connectivity_matrix[(sources, targets)] * weight_per_synapse
spike_monitor = SpikeMonitor(neu
Some followup questions:
what if I wanted to apply this injected current only to a subset of the neurons? Would I manually access them by doing something like
neu[i].v_ext = some_time_array
?