Hi @mstimberg. Thanks for your kind advice.
After changing read_only_variables
to False
it ran, and I can reproduce the problem now.
Sorry about the typo. This is indeed False
.
For this specific scenario, you can correct these values with something like:
The problem has been resolved with your code. For my simulation with more complicated neuron models, I resolved it with v-=1*ksecond
(v-=100*ms cannot). However, for neurons that have long refractory periods, this remedy will be inapplicable/inaccurate because a neuron will fire spikes ahead of expected time moments. And I have two questions about it.
-
The neuron is only refractory from lastspike
to lastspike + refractory
. In the minimal working example, lastspike=97.2*ms, refractory=5*ms
. So the neuron is only refractory from 97.2*ms
to 102.2*ms
. When I restarted the simulation, it is reasonable that the neuron didn’t fire spikes from 100*ms
to 102.2*ms
. But why couldn’t it fire after 102.2*ms
, which has already passed the refractory period?
-
Modifying lastspike
does not influence SpikeMonitor
, does it?
Can you explain in more detail why you cannot use store
and restore
?
Hmm, the reasons are rather complex and multi-faceted:
set_states
are very flexible for users. For example, I can modify some states like lastspike
, and I can remove some states if I delete a variable (restore
will report errors).
- I’m currently coupling brian2 with another library (LAMMPS) to obtain the stimulus to the neurons. LAMMPS is running using MPICH. Brian2 is running in the main process and LAMMPS is running in 24 processes. I did use
store
and restore
before. However, weeks ago, I found that the file written by Network.store
cannot be read normally on my PC (Windows 10) during post-processing (in serial). But the problem would be resolved if I ran the simulation in serial so that the stored file is obtained in the serial mode. Then I guess Brian2 is not compatible with MPICH. The error is as follows:
ERROR Brian 2 encountered an unexpected error. If you think this is a bug in Brian 2, please report this issue either to the discourse forum at <http://brian.discourse.group/>, or to the issue tracker at <https://github.com/brian-team/brian2/issues>. Please include this file with debug information in your report: C:\Users\13372\AppData\Local\Temp\brian_debug_hend29pl.log Additionally, you can also include a copy of the script that was run, available at: C:\Users\13372\AppData\Local\Temp\brian_script_t7rc8j5o.py Thanks! [brian2]
Traceback (most recent call last):
File "E:\EntericNervousSystem\my_work\postprocess\visualize_network.py", line 24, in <module>
net.restore(filename=f'{path}/{case_name}/store/net_{read_step}.store')
File "D:\Anaconda3\envs\enteric_new\lib\site-packages\brian2\core\base.py", line 346, in device_override_decorated_function
return func(*args, **kwds)
File "D:\Anaconda3\envs\enteric_new\lib\site-packages\brian2\core\network.py", line 705, in restore
obj._restore_from_full_state(state[obj.name])
File "D:\Anaconda3\envs\enteric_new\lib\site-packages\brian2\synapses\synapses.py", line 452, in _restore_from_full_state
self.queue._restore_from_full_state(queue_state)
File "brian2\\synapses\\cythonspikequeue.pyx", line 63, in brian2.synapses.cythonspikequeue.SpikeQueue._restore_from_full_state
File "<stringsource>", line 178, in pair.from_py.__pyx_convert_pair_from_py_int__and_std_3a__3a_vector_3c_std_3a__3a_vector_3c_int32_t_3e____3e___
ValueError: too many values to unpack (expected 2)
I did not report this error in this Brian2 community at that time because I think it might be more flexible if I used get_states
and set_states
. Also, I reckoned that brian2 might give low priority to this issue because most users would choose multiprocessing
for parallel simulation. The reason why LAMMPS chooses MPI is that it is suitable for space decomposition, which is not applicable to computational neuroscience. Anyway, I switched to set_states
finally.