Spike source and target sections

A Python package that facilitates development and use of models of biological neural networks

Moderator: tom_morse

salvadord
Posts: 76
Joined: Tue Aug 18, 2015 3:49 pm

Spike source and target sections

Post by salvadord » Mon Nov 27, 2017 12:03 pm

Question received by email:

"Hi Salvador.

I have just started using your Netpyne framework, to test the possibility to build a network with "particular characteristics".

I was able to import two of my Python/neuron HH models and to define the code to see their basic behaviour, with or without a current injection.
So far so good.

To procede further, i need to know if this approch is feasible with your framework:

1) Is it possibile to define a section as the source of the action potential to pass from cell A to cell B?
I need to send action potentials times, recorded at the end of a long axon, from cell A to cell B. The last axonal section is part of a python list, containing the NEURON sections.

2) Based on the previous point, i need to send that information to a specific list of dendritic sections of cell B. The Python list containes NEURON sections selected with specific criteria.

Is it possibile?

Best regards

Stefano Masoli PhD"

salvadord
Posts: 76
Joined: Tue Aug 18, 2015 3:49 pm

Re: Spike source and target sections

Post by salvadord » Mon Nov 27, 2017 12:20 pm

Hi Stefano,

Thanks for for your question, and for trying out NetPyNE. Yes, it is possible to do what you are asking:

1) you can set the source of the action potential by simply adding the 'spikeGenLoc' ("spike generation location") to that section in the cell rule; e.g. say you want it at a section called "axon_5" and location 0.9 within that section, you can write:

Code: Select all

cellRule['secs']['axon_5']['spikeGenLoc'] = 0.9 
See these documentation links for more details: http://www.neurosimlab.org/netpyne/refe ... erty-rules and http://www.neurosimlab.org/netpyne/adva ... rt-friesen

2) You can set the target section of a current injection (IClamp) using the 'sec' property in 'stimTargetParams'; and similarly if you are creating connections between cells.

See the tutorial for some examples: http://www.neurosimlab.org/netpyne/tutorial.html and the reference for more details: http://www.neurosimlab.org/netpyne/refe ... timulation ; http://www.neurosimlab.org/netpyne/refe ... vity-rules

If you have a specific example you are having issues with, please feel free to share your code -- pasted here if short, or with a link to repo if long -- and I'll be more than happy to guide you.

Salva

bremen
Posts: 26
Joined: Mon Apr 24, 2017 8:15 am
Location: Italy

Re: Spike source and target sections

Post by bremen » Mon Nov 27, 2017 4:53 pm

Hi Salvador,
thank you.

1) I have added the axonal section to the "cellRule" and recorded a voltage trace from it. It works perfectly.

2) Based on the tutorial i was able to set a "synMechParams" for an AMPA syn mechanism and a "connParams":

Code: Select all

netParams.connParams['A_pop->B_pop'] = {'preConds': {'pop': 'A_pop'}, 'postConds': {'pop': 'B_pop'}, 
	'probability': 1, 		# probability of connection
	'weight': 1, 			# synaptic weight 
	'delay': 1,					# transmission delay (ms) 
	'sec': 'list_of_sections?',				# section to connect to
	'loc': 0.5,					# location of synapse
	'synMech': 'AMPA'}   		# target synaptic mechanism
In my case i would like to pass to 'sec' a specific list composed by 105 dendritic sections.
I have to define each section in the cellRule before using it? (cellRule['secs']['dend1','dend2',etc])
If this is the way is there a way to iterate on the "connParams" to used the same parameters every time, of course with a different section?

Edit.
I have just found that you answered a question like mine on another topic. Tomorrow i'll try this approach.
viewtopic.php?f=45&t=3714

Stefano

salvadord
Posts: 76
Joined: Tue Aug 18, 2015 3:49 pm

Re: Spike source and target sections

Post by salvadord » Tue Nov 28, 2017 10:13 am

Stefano,

The sections must exist in the cell rule in order to be able to connect to them. But if you are importing an existing cell I assume these section will already exist.

To target these sections in the connParams rule, you can just use a list of strings e.g.

Code: Select all

netParams.connParams['A_pop->B_pop'] = {
	'sec': ['dend1', 'dend2', 'dend3'],
	...
Of course you can create this list before and then pass the variable, e.g.:

Code: Select all

targetSecs = ['dend1', 'dend2', 'dend3']
netParams.connParams['A_pop->B_pop'] = {
	'sec': targetSecs,
	...
A 3rd method would be to create a named section list within the cellRule (of the target cell) and then pass that as a string, e.g.

Code: Select all

cellRule['secLists']['allDend'] = ['dend1', 'dend2', 'dend3']
netParams.connParams['A_pop->B_pop'] = {
	'sec': 'allDend',
	...
Hope this helps!

bremen
Posts: 26
Joined: Mon Apr 24, 2017 8:15 am
Location: Italy

Re: Spike source and target sections

Post by bremen » Fri Dec 01, 2017 3:45 am

Hi Salvador.
Thank you. I tried your suggestions but i get a "list index out of range":

Code: Select all

synMechs = [self.addSynMech(synLabel=params['synMech'], secLabel=synMechSecs[i], loc=synMechLocs[i]) for i in range(synsPerConn)] 
IndexError    synMechs = [self.addSynMech(synLabel=params['synMech'], secLabel=synMechSecs[i], loc=synMechLocs[i]) for i in range(synsPerConn)] 
IndexError: list index out of range
>>> : list index out of range
The code:

Code: Select all

cf_dend = ['dend_0', 'dend_1', 'dend_2'] #it is 105 sections long in the code but i get the error even with 3 sections
 
netParams.synMechParams['AMPA'] = {'mod': 'Ampa_syn', 'tau_facil': 1, 'tau_rec': 150, 'tau_1':3, 'gmax':3000, 'U':0.5}

netParams.connParams['A_pop->B_pop'] = {'preConds': {'pop': 'A_pop'}, 'postConds': {'pop': 'B_pop'}, 
	'probability': 1, 		
	'weight': 1, 			
	'delay': 1,					
	'sec': cf_dend,				
	'loc': 0.5,					
	'synMech': 'AMPA'}

The entire error report.

Code: Select all

    sim.createSimulateAnalyze(netParams = netParams, simConfig = simConfig)    
  File "/usr/local/lib/python2.7/dist-packages/netpyne/wrappers.py", line 69, in createSimulateAnalyze
    (pops, cells, conns, stims, simData) = sim.create(netParams, simConfig, output=True)
  File "/usr/local/lib/python2.7/dist-packages/netpyne/wrappers.py", line 28, in create
    conns = sim.net.connectCells()                # create connections between cells based on params
  File "/usr/local/lib/python2.7/dist-packages/netpyne/network.py", line 533, in connectCells
    connFunc(preCellsTags, postCellsTags, connParam)  # call specific conn function
  File "/usr/local/lib/python2.7/dist-packages/netpyne/network.py", line 814, in probConn
    self._addCellConn(connParam, preCellGid, postCellGid) # add connection
  File "/usr/local/lib/python2.7/dist-packages/netpyne/network.py", line 961, in _addCellConn
    postCell.addConn(params=params)
  File "/usr/local/lib/python2.7/dist-packages/netpyne/cell.py", line 692, in addConn
    synMechs, synMechSecs, synMechLocs = self._setConnSynMechs(params, secLabels)
  File "/usr/local/lib/python2.7/dist-packages/netpyne/cell.py", line 1141, in _setConnSynMechs
    synMechs = [self.addSynMech(synLabel=params['synMech'], secLabel=synMechSecs[i], loc=synMechLocs[i]) for i in range(synsPerConn)] 
IndexError: list index out of range

salvadord
Posts: 76
Joined: Tue Aug 18, 2015 3:49 pm

Re: Spike source and target sections

Post by salvadord » Sun Dec 03, 2017 9:13 pm

Perhaps the cell is not being imported correctly and those sections don't exist?

Can you share your full code? Either as a link to a repo (eg. github) or zip file to salvadordura@gmail.com

Thanks

bremen
Posts: 26
Joined: Mon Apr 24, 2017 8:15 am
Location: Italy

Re: Spike source and target sections

Post by bremen » Mon Dec 04, 2017 7:38 am

My bad. I changed the numbering scheme in my main trunk, instead of changing it in the branch i am using for these tests.

Now it reports:
"Number of connections on node 3: 5"
For the moment, there are 5 cellA to each cellB even thou the final connectivity will be 1:1.
I can see a very small variation in the voltage trace, so the synapses are working, but with an impact of just 5 syn and not 5*105.

salvadord
Posts: 76
Joined: Tue Aug 18, 2015 3:49 pm

Re: Spike source and target sections

Post by salvadord » Mon Dec 04, 2017 10:58 am

With a probability of 1, you should be getting Npre*Npost connections, where Npre,Npost is the number of cells in the presyn,postsyn populations. If you only got 5 conns, it might be you have Npre=5, Npost=1 ?

Also, if you want more that 1 synapse per connection use the 'synsPerConn' argument -- see http://www.neurosimlab.org/netpyne/refe ... vity-rules

bremen
Posts: 26
Joined: Mon Apr 24, 2017 8:15 am
Location: Italy

Re: Spike source and target sections

Post by bremen » Wed Dec 06, 2017 5:13 am

'synsPerConn' solved the problem. Thank you.

To complete this part i have a last question:
1) {'preConds': {'pop': 'A_pop'}, 'postConds': {'pop': 'B_pop'}
Is it possibile to define a certain member of the A_pop to connect to a certain member of B_pop?
A_pop = 5cells and B_pop = 5cells
For example to connect A_pop cell 0 to B_pop cell 5?
Or A_pop cell 1 to connect B_pop 3 and 4?

salvadord
Posts: 76
Joined: Tue Aug 18, 2015 3:49 pm

Re: Spike source and target sections

Post by salvadord » Wed Dec 06, 2017 3:12 pm

Yes, you can select any arbitrary conn pattern using the 'connList' argument: http://neurosimlab.org/netpyne/referenc ... vity-rules

bremen
Posts: 26
Joined: Mon Apr 24, 2017 8:15 am
Location: Italy

Re: Spike source and target sections

Post by bremen » Fri Dec 08, 2017 6:10 am

Thank you.
After defining some custom code for the connectivity to be passed to 'connList', everything runs great, in a small scale net of 40 neurons.
I'll have to add another neuronal type but my AMD 1800x is starting to be too small for the scale i need to reach.

I have tried to install netpyne, on two distinct clusters, but without much success. I'll open a dedicated topic about this.

bremen
Posts: 26
Joined: Mon Apr 24, 2017 8:15 am
Location: Italy

Re: Spike source and target sections

Post by bremen » Sat Dec 09, 2017 8:15 am

I have found a strange behavior with the somatic section.

I have imported the C_cell population and placed some synapses directly on the soma, as seen in experiments.
It generates no errors if the C_cell template somatic section is named 'soma'.

If i change that to 'soma_C' or any other combination, it generates an error:

Code: Select all

sim.createSimulateAnalyze(netParams = netParams, simConfig = simConfig)    
  File "/usr/local/lib/python2.7/dist-packages/netpyne/wrappers.py", line 73, in createSimulateAnalyze
    (pops, cells, conns, stims, simData) = sim.create(netParams, simConfig, output=True)
  File "/usr/local/lib/python2.7/dist-packages/netpyne/wrappers.py", line 28, in create
    conns = sim.net.connectCells()                # create connections between cells based on params
  File "/usr/local/lib/python2.7/dist-packages/netpyne/network.py", line 544, in connectCells
    connFunc(preCellsTags, postCellsTags, connParam)  # call specific conn function
  File "/usr/local/lib/python2.7/dist-packages/netpyne/network.py", line 940, in fromListConn
    self._addCellConn(connParam, preCellGid, postCellGid) # add connection
  File "/usr/local/lib/python2.7/dist-packages/netpyne/network.py", line 1000, in _addCellConn
    postCell.addConn(params=params)
  File "/usr/local/lib/python2.7/dist-packages/netpyne/cell.py", line 720, in addConn
    synMechs, synMechSecs, synMechLocs = self._setConnSynMechs(params, secLabels)
  File "/usr/local/lib/python2.7/dist-packages/netpyne/cell.py", line 1182, in _setConnSynMechs
    synMechSecs, synMechLocs = self._distributeSynsUniformly(secList=secLabels, numSyns=synsPerConn)
  File "/usr/local/lib/python2.7/dist-packages/netpyne/cell.py", line 1197, in _distributeSynsUniformly
    if 'L' in self.secs[secList[0]]['geom']:
IndexError: list index out of range
Edit:
The same behaviors can be obtained passing section names with [] in them.
For example:
'dend_0' works.
'dend[0]' no.
The second name is the result of a morphology imported and instantiated with import3D.

Best regards
Stefano

salvadord
Posts: 76
Joined: Tue Aug 18, 2015 3:49 pm

Re: Spike source and target sections

Post by salvadord » Tue Dec 12, 2017 10:33 am

Where exactly did you change the label 'soma' to 'soma_C''? in the original imported file? in the netpyne netParams? I just tried replacing 'soma' with 'soma_C' in another example, and worked ok. So it might be that you are not replacing the label consistently, or some other bug. Feel free to send me the code.

Regarding, dend[0] -- section labels that consist of a list are automatically converted to that format (ie. 'name_index') since netpyne requires section names to be strings. You can inspect the netParams.cellParams object to check the section labels. Let me know if you have other issues in this respect.

bremen
Posts: 26
Joined: Mon Apr 24, 2017 8:15 am
Location: Italy

Re: Spike source and target sections

Post by bremen » Tue Dec 12, 2017 11:01 am

Where exactly did you change the label 'soma' to 'soma_C''? in the original imported file? in the netpyne netParams? I just tried replacing 'soma' with 'soma_C' in another example, and worked ok. So it might be that you are not replacing the label consistently, or some other bug. Feel free to send me the code.
Inside the template of each imported model, i define the somatic section in this way.
self.soma = h.Section(name='soma')

The problem arise when i try to use the section in the connParams.
If i have the name = 'soma' in the template and i use it in the sec, inside the connParams, it works:

Code: Select all

netParams.connParams['A_pop->B_pop'] = {'preConds': {'pop': 'A_pop'}, 'postConds': {'pop': 'B_pop'}, 
        'sec': ['soma','soma','soma']}
If i change the name in the template, and then in the netConn, to 'soma1' or 'soma[0]'

Code: Select all

        'sec': ['soma1','soma1','soma1']

than it generates the error of my precious post.
You can inspect the netParams.cellParams object to check the section labels. Let me know if you have other issues in this respect.
I'll try that.

bremen
Posts: 26
Joined: Mon Apr 24, 2017 8:15 am
Location: Italy

Re: Spike source and target sections

Post by bremen » Tue Dec 12, 2017 3:33 pm

section labels that consist of a list are automatically converted to that format (ie. 'name_index') since netpyne requires section names to be strings.
This was the missing key element.
In my main model, i have full control on the name of each dendritic section which, coincidentally, was the same used by netpyne. 'dend_10', 'dend_20'.

In the other model, instead, i'm using a Python module to load the morphology from an swc and the resulting sections are named, by import3D, as dend[10], dend[200]...

I was missing the fact that dend_x was an internal representation valid for all models.
The same for the soma.

Thank you.

Post Reply