Page 1 of 1

Best Way to Modify Stimulation Source

Posted: Tue Jun 27, 2017 1:09 pm
by astaylor
Hi guys,

I was wondering what would be the best way to modify a stimulation source param after the simulation has already been run once (essentially to get the functionality of the modifyStims function). I noticed that modifyStims hasn't been implemented yet so is this because it is currently impossible to do this? If anyone knows a way to do this directly please let me know! I get the same error when I try to directly update a stimulation source.

Thanks.

Error:

Code: Select all

Creating network of 13 cell populations on 1 hosts...
Traceback (most recent call last):
  File "100_Cell_LA.py", line 390, in <module>
    evaluateRates(4, 4, netParams)
  File "100_Cell_LA.py", line 67, in evaluateRates
    sim.createSimulate(netParams, simConfig)
  File "/Users/aliyahtaylor/anaconda/lib/python2.7/site-packages/netpyne/wrappers.py", line 58, in createSimulate
    (pops, cells, conns, stims, simData) = sim.create(netParams, simConfig, output=True)
  File "/Users/aliyahtaylor/anaconda/lib/python2.7/site-packages/netpyne/wrappers.py", line 27, in create
    cells = sim.net.createCells()                 # instantiate network cells based on defined populations
  File "/Users/aliyahtaylor/anaconda/lib/python2.7/site-packages/netpyne/network.py", line 73, in createCells
    newCells = ipop.createCells() # create cells for this pop using Pop method
  File "/Users/aliyahtaylor/anaconda/lib/python2.7/site-packages/netpyne/pop.py", line 56, in createCells
    cells = self.createCellsFixedNum()
  File "/Users/aliyahtaylor/anaconda/lib/python2.7/site-packages/netpyne/pop.py", line 126, in createCellsFixedNum
    cells.append(self.cellModelClass(gid, cellTags)) # instantiate Cell object
  File "/Users/aliyahtaylor/anaconda/lib/python2.7/site-packages/netpyne/cell.py", line 1197, in __init__
    self.createNEURONObj()  # create cell 
  File "/Users/aliyahtaylor/anaconda/lib/python2.7/site-packages/netpyne/cell.py", line 1210, in createNEURONObj
    if 'rate' in self.params and isinstance(self.params['rate'], list) and len(self.params['rate']) == 2:
TypeError: argument of type 'function' is not iterable
>>> quit()

Re: Best Way to Modify Stimulation Source

Posted: Fri Jul 07, 2017 10:59 pm
by salvadord
Sorry for the delayed response, for some reason I wasn't getting email notifications for the forum posts.

modifyStims should work for what you want to do, but please share your code and explain exactly what you want to modify and I'll check.

Also note that modify funcs only make sense if the network setup time is very large, otherwise its preferable to change the stim in the netParams.stimSourceParams directly and rerun the whole script. If you are trying to explore a set of parameter values you might want to try out the new batch sim module included in NetPyNE -- its still not properly documented but there is an example here: https://github.com/Neurosim-lab/netpyne ... /batchCell ; and I can help you set it up for your particular problem.

Re: Best Way to Modify Stimulation Source

Posted: Sun Jul 09, 2017 9:57 pm
by astaylor
So would this be the proper format, assuming that interval_inter and target_inter_rate are float values? bg2inter_stim is a stimulation source. I am running the simulation then using:

sim.net.modifyStims({'conds': {'label':'bg2inter_stim'}, 'interval' : interval_inter + 100*(inter_rate - target_inter_rate)})

and when I call sim.createSimulate(netParams, simConfig) after this, I get the error above.

Re: Best Way to Modify Stimulation Source

Posted: Sun Jul 09, 2017 9:58 pm
by astaylor
I also tried doing this directly using the same format in the tutorials for initially setting variables of a stimulation source, but I still get the same error.

Re: Best Way to Modify Stimulation Source

Posted: Mon Jul 10, 2017 11:08 am
by salvadord
The error you are getting seems to be happening during the creation of one of the Netstim/Vecstim populations, in particular something related to the 'rate' parameter. Note that after calling the modifyStims() func if you want to rerun the sim, you need to call sim.simulate() and not sim.createSimulate(); otherwise you'd be creating the network from scratch again based on the original netParams. In any case neither of those calls should generate an error; if you share the full code in 100_Cell_LA.py I can try to track it down.

I tried myself the modifyStims() using the 100_Cell_LA.py provided by Brenyn and it didn't generate any errors. Note that in your case, instead of {'conds': {'label':'bg2inter_stim'} you want to specify {'conds': {'source':'bg2inter_stim'} -- 'label' refers to keys in stimTargetParams where as source refers to keys in stimSourceParams.

Also, I noticed that although no errors were being generated, the interval of those stims wasn't changing. This was due to a small bug in the code, which I have now fixed. This will be included in the next release, but please clone the development version for now if you want to use (https://github.com/Neurosim-lab/netpyne ... evelopment).

Also, please consider using a batch simulation approach instead of modifying params interactively (https://github.com/Neurosim-lab/netpyne ... /batchCell) -- I can help you set it up.

Re: Best Way to Modify Stimulation Source

Posted: Mon Jul 10, 2017 12:33 pm
by astaylor
Hi, this solved my error. I seem to get the above error whenever I call sim.create() again. Changing the conditions and only simulating worked perfectly. Thank you for all the help once again!