Page 1 of 1

Stimulating network using spike trains

Posted: Wed Jun 07, 2017 11:49 am
by bll5z6
Hello all,

I am using NetPyNe to convert some old hoc code to the standardized Python form which NetPyNe facilitates (great project!). I have a 500 cell model of the rodent central nucleus of the amygdala (Ce) which receives input from other nuclei in the amygdala. We model these inputs separately and then feed them into the Ce model as spike trains saved in text files.

My question is how does one provide these spike times as stimuli into the network? Your help is appreciated and thank you for developing this important project, I'll be spreading the word!


Re: Stimulating network using spike trains

Posted: Thu Jun 08, 2017 1:11 pm
by salvadord
Hi Ben,

Thanks for your kind comments and feedback. To provide a list of predefined spike times as stimuli to the network you can create a population of VecStim and provide the list of spk times directly, e.g.:

Code: Select all

netParams.popParams['bkg'] = {'cellModel': 'VecStim', 'numCells': 1, 'spkTimes': [1,10,20,30,40,50]} 
I just updated the documentation to provide more details and explain the different options available: ... parameters

Your project sounds very interesting, please let us know if you have any more questions/comments!


Re: Stimulating network using spike trains

Posted: Thu Jun 08, 2017 5:30 pm
by bll5z6

Thanks for the quick reply. I created the artificial cell but cannot seem to get the spikes to show up:

Code: Select all

from netpyne import specs, sim

netParams = specs.NetParams()

#Create artificial cell with spike times
netParams.popParams['bkg'] = {'cellModel' : 'VecStim', 'numCells': 5, 'spkTimes': [100, 200, 300, 400, 500]}

#Create cell type
netParams.popParams['S'] = {'cellType': 'PYR', 'numCells': 20, 'cellModel': 'HH'}

#Define cell characteristics
cellRule = {'conds': {'cellType': 'PYR'},  'secs': {}} 	# cell rule dict
cellRule['secs']['soma'] = {'geom': {}, 'mechs': {}}  											# soma params dict
cellRule['secs']['soma']['geom'] = {'diam': 18.8, 'L': 18.8, 'Ra': 123.0}  									# soma geometry
cellRule['secs']['soma']['mechs']['hh'] = {'gnabar': 0.12, 'gkbar': 0.036, 'gl': 0.003, 'el': -70}  		# soma hh mechanisms
cellRule['secs']['dend'] = {'geom': {}, 'topol': {}, 'mechs': {}}  								# dend params dict
cellRule['secs']['dend']['geom'] = {'diam': 5.0, 'L': 150.0, 'Ra': 150.0, 'cm': 1}							# dend geometry
cellRule['secs']['dend']['topol'] = {'parentSec': 'soma', 'parentX': 1.0, 'childX': 0}						# dend topology 
cellRule['secs']['dend']['mechs']['pas'] = {'g': 0.0000357, 'e': -70} 										# dend mechanisms
netParams.cellParams['PYRrule'] = cellRule
#Import synaptic mechanism
netParams.synMechParams['exc'] = {'mod': 'Exp2Syn', 'tau1': 0.1, 'tau2': 5.0, 'e': 0}

#Connect artificial cell to regular cells with 100% probability
netParams.connParams['bkg->S'] = {'preConds': {'popLabel': 'bkg'}, 
	'postConds': {'popLabel': 'S'},
	'probability': 1, 			# probability of connection
	'weight': 2, 			# synaptic weight 
	'delay': 5,					# transmission delay (ms) 
	'sec': 'adend',				# section to connect to
	'loc': 0.5,					# location of synapse
	'synMech': 'exc'}   		# target synaptic mechanism
simConfig = specs.SimConfig()		# object of class SimConfig to store simulation configuration

simConfig.duration = 1*1e3 			# Duration of the simulation, in ms
simConfig.dt = 0.025 				# Internal integration timestep to use
simConfig.recordStep = 0.25 			# Step size in ms to save data (eg. V traces, LFP, etc)

simConfig.analysis['plotRaster'] = True			# Plot a raster
simConfig.analysis['plot2Dnet']  = True          # plot 2D visualization of cell positions and connections

# Create network and run simulation
sim.createSimulateAnalyze(netParams = netParams, simConfig = simConfig)    
import pylab;  # this line is only necessary in certain systems where figures appear empty
No spikes seem to get generated. Thank you in advance for your help!


Re: Stimulating network using spike trains

Posted: Fri Jun 09, 2017 9:58 pm
by salvadord
Sorry Ben, didn't realize that feature was in the development branch. I will release a new netpyne version (0.7.0) today, so you just have to upgrade to that one and it should work.

Re: Stimulating network using spike trains

Posted: Mon Jun 12, 2017 10:50 am
by bll5z6
No problem. So we updated to the new Netpyne version (0.7.0) and still the above code generates the message "No spikes available to plot raster". We looked through the source code a bit and it seems like it should work but we haven't had any luck. We will keep digging but any thoughts you have in the meantime are appreciated!


Re: Stimulating network using spike trains

Posted: Mon Jun 12, 2017 11:39 am
by salvadord
Works for me using your code, so please check that you are not accidentally using an older version (happens often). You can check the version via sys.version() and can check where the files are located using import netpyne; print netpyne.__file__

In theory, to upgrade you should just need to do pip install netpyne -U or git pull (from the repo, if you cloned via github). However, in some cases, and not sure exactly why, the system may keep using an older version. So you can first do pip uninstall netpyne and/or try to locate the files manually and remove them, and then install from scratch.

If you have the correct version but still doesn't work, let me know and we'll figure it out.

Hope this helps.

Re: Stimulating network using spike trains

Posted: Mon Jun 12, 2017 1:55 pm
by bll5z6
Thanks so much for the help. We tried on Windows, Ubuntu, and Mac to no avail. The cells get created and connected but still "No spikes available to plot raster".

Re: Stimulating network using spike trains

Posted: Mon Jun 12, 2017 2:03 pm
by salvadord
Aah I know what it can be! You need to have the vecevent.mod file which contains the VecStim mechanism compiled in the folder where you are running the sim. Sorry, in the next version I will modify netpyne so it gives a warning if the mod mechanism is not available.

Re: Stimulating network using spike trains

Posted: Mon Jun 12, 2017 2:26 pm
by bll5z6
That was it! Thank you so much for your help!

Re: Stimulating network using spike trains

Posted: Wed Sep 18, 2019 9:11 pm
by asb
Hi Salvador,

I have just started using netpyne and have a question about network stimulation. Apologies if this is obvious or tackled elsewhere.

To get started I want to create a network of I&F neurons which all receive independent random (poisson) external stimuli. I'm trying to find the most efficient way to achieve this in netpyne. I don't think 'stimSourceParams' works with point processes (I receive the error: addstim not supported). Therefore, for a population of N neurons the 3 options I can think of are:

1) Create N netstim objects and specify 1-to-1 connections to each neuron

2) Create 1 netstim object, connect to all N neurons, with random synaptic delays (although this may introduce input correlations)

3) Implement the I&F neuron within a compartment and use 'stimSourceParams'. However, I'm unsure if it's possible to create independent stimuli using this approach.

Do have any recommendations for the best (efficient) approach for large population simulations?

Thanks in advance

Re: Stimulating network using spike trains

Posted: Thu Dec 26, 2019 2:04 pm
by salvadord
Hi, sorry for the delay. We plan to add support so you can add stims to point processes. In the meantime, you are quite right that those are the main possible approaches:

1) This is the one we've used in the past; you can see an example here: ...

2) Agree that it might result in correlations.

3) This should work ok too, and stimSourceParams / stimTargetParams will create independent stimuli (NetStims) for each target cell. You can see an example of implementing the Izhikevich I&F within a compartment here:

If you already solved the issue, please let us know what approach you followed. Thanks

ps. I usually monitor the Google groups forum more closely:

Re: Stimulating network using spike trains

Posted: Thu Jan 02, 2020 12:56 am
by asb
Hi Salvador, thanks for your reply. I ended up using option 3 with single compartment models which works perfectly. It also seems more efficient than option 1.

Thanks for letting me know about the google group - I'll post here in future.