Page 1 of 1

Save/load state

Posted: Sun Nov 19, 2017 10:53 am
by salvadord
Question received by email from Andrew Knox:

"One other question. Ideally I’d like to be able to run the model for ~10 seconds to let it come to steady state, then save that state and run a number of simulations with different parameters from that point in time. What’s the best way to do this?

I had written some code that essentially boils down to

Code: Select all

netParams = specs.NetParams() 
simConfig = specs.SimConfig()
if firstrun:
        {do a bunch of stuff to set up simulation}
        simConfig.filename = 'sim_data'

However, its giving me this error on the second run (ie when it’s trying to load sim_data.pkl):

Code: Select all

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "", line 88, in <module>
  File "C:\ProgramData\Anaconda2\lib\site-packages\netpyne\", line 82, in load
  File "C:\ProgramData\Anaconda2\lib\site-packages\netpyne\", line 244, in loadAll
    loadNet(filename, data=data)
  File "C:\ProgramData\Anaconda2\lib\site-packages\netpyne\", line 187, in loadNet
    cell.createNEURONObj(prop)  # use same syntax as when creating based on high-level specs
  File "C:\ProgramData\Anaconda2\lib\site-packages\netpyne\", line 451, in createNEURONObj
    setattr(sec['pointps'][pointpName]['hPointp'], pointpParamName, pointpParamValue)
LookupError: 'hPointp' is not a defined hoc variable name.

I wasn’t sure whether this was a bug, something specific that I’m doing wrong, or a more general misunderstanding of how load and save are supposed to be used.

Also, I thought about posting to the board, but then I couldn’t remember my login and it just became too much work…


Re: Save/load state

Posted: Sun Nov 19, 2017 8:26 pm
by salvadord
Hi Andrew,

Unfortunately, the save/load state feature in netpyne is still in the TO DO list, see here: -- if you have a nice code example from your model you can add it as a comment to the github issue and that might help with the implementation.

The netpyne save command is used to save the netParams, simConfig, net and [/i]simData[/i] objects, i.e. the high-level specifications, simulation configuration, instantiated network and output simulation data. You can use this to e.g. load an instantiated network, which is faster than recreating it by applying all the high-level specs (rules), and to load and plot saved data etc. The error you got during loading of the network is probably a bug -- I will try to fix it for the next released version.

Something you could try is to run the network using netpyne and then save and load the state using standard NEURON commands. But I have never tested this, so not sure if any issues might arise.

The other option is of course to just simulate the first 10 seconds every time. Since netpyne is implemented as parallel NEURON code you can use mpi straight away to run parallel simulations, either in computers with multiple cores or large HPCs/supercomputers (e.g. see NSG -- Also, you might consider if perhaps you don't need the full 10 secs to achieve steady state.