Issue stimulating cells that I imported

Moderator: tom_morse

Post Reply
bwjmbb17
Posts: 16
Joined: Mon Apr 10, 2017 10:09 am

Issue stimulating cells that I imported

Post by bwjmbb17 » Thu Jun 15, 2017 4:58 pm

Hey all,

I am trying to recreate a model from hoc that is of the Lateral Amygdala. I am having a few issues that I would like to discuss with you.

The first issue is that my model doesn't seem like the cells are being imported properly due to them not spiking when given an input, other than the PN_A cells. The weird thing is that the cells I create come from the same template called LA_Template.py. I am stimulating them via another cell in this case Thal_Tone_D, Cort_Tone_V, and Shock. These three cells are connected to PN_A cells and then the PN_A, PN_B, PN_B are all interconnected. I would expect for the spikes from the PN_A cells to cause spikes in the other cells which does not happen.

Second issue which also makes me think that the cells are not created properly is that when I try to graph a PN_B, PN_C, or INT cell I get a blank graph.

Third issue is that when I try to connect background noise via stimulation the stimulation only connects to PN_A cells and not the rest.

I have attached my code with all my mod files and the main file called 100_Cell_LA.py and the LA_Template.py. I have tried many things (changing many variable names, converting my template file, etc.) to fix this and I can't seem to get it figured out. I think all these issues are tied together starting from the importing the cells but not sure how to fix the problem. Any help would be much appreciated.

Code: Main File

Code: Select all

from netpyne import specs, sim, analysis
from random import randint

# Varible Definitions
simTime = 276000
toneTrial = 44
shockTrials = 16
toneD_Num = [8, 24]
toneV_Num = [13, 24]
noise_freq_pyr = 3
noise_freq_int = 5
noise_tot_length = simTime
totNumCells = 100
numInter = 20
numAType = int((totNumCells - numInter) * 0.5)
numBType = int((totNumCells - numInter) * 0.3)
numCType = int((totNumCells - numInter) * 0.2)
toneStimD_List = []
toneStimV_List = []
shockStim_List = []

# Create list of toneStimD and toneStimV
for i in range(0, toneTrial):
	if i < toneD_Num[0]:
		interval = 50
		number = 10+1
		start = 3500+4000*i
		for i in range(0, number):
			toneStimD_List.append(start+interval*i)
	elif i >= toneD_Num[0] and i < toneD_Num[1]:
		interval = 50/2
		number = 10*2+1
		start = 3500+4000*i
		for i in range(0, number):
			toneStimD_List.append(start+interval*i)
	elif i >= toneD_Num[1]:
		interval = 50/2
		number = 10*2+1
		start = 100000+3500+4000*i
		for i in range(0, number):
			toneStimD_List.append(start+interval*i)

for i in range(0, toneTrial):
	if i < toneV_Num[0]:
		interval = 50
		number = 10+1
		start = 3500+4000*i
		for i in range(0, number):
			toneStimV_List.append(start+interval*i)
	elif i >= toneV_Num[0] and i < toneV_Num[1]:
		interval = 50/2
		number = 10*2+1
		start = 3500+4000*i
		for i in range(0, number):
			toneStimV_List.append(start+interval*i)
	elif i >= toneV_Num[1]:
		interval = 50/2
		number = 10*2+1
		start = 100000+3500+4000*i
		for i in range(0, number):
			toneStimV_List.append(start+interval*i)
			
for i in range(0, shockTrials):
		interval = 5
		number = 20+1
		start = 35900+4000*i
		for i in range(0, number):
			shockStim_List.append(start+interval*i)

# Network Parameters
netParams = specs.NetParams()
netParams.sizeX = 130		# Horizontal Axis
netParams.sizeY = 50		# Vertical Axis
netParams.sizeZ = 100		# Horizontal Axis

# Cell Property Value
netParams.importCellParams(label='Type_A_Rule', conds={'cellType': 'PYR_A', 'cellModel': 'LA_Mod'}, fileName='LA_Template.py', cellName='Cell_A')
netParams.importCellParams(label='Type_B_Rule', conds={'cellType': 'PYR_B', 'cellModel': 'LA_Mod'}, fileName='LA_Template.py', cellName='Cell_B')
netParams.importCellParams(label='Type_C_Rule', conds={'cellType': 'PYR_C', 'cellModel': 'LA_Mod'}, fileName='LA_Template.py', cellName='Cell_C')
netParams.importCellParams(label='Inter_Rule', conds={'cellType': 'Inter1', 'cellModel': 'LA_Mod'}, fileName='LA_Template.py', cellName='Inter')

# Population Parameters
netParams.popParams['PN_A'] = {'cellType': 'PYR_A', 'numCells': numAType,'xRange': [0,25], 'yRange': [0,50], 'cellModel': 'LA_Mod'}
netParams.popParams['PN_B'] = {'cellType': 'PYR_B', 'numCells': numBType, 'xRange': [25,50], 'yRange': [0,50], 'cellModel ': 'LA_Mod'}
netParams.popParams['PN_C'] = {'cellType': 'PYR_C', 'numCells': numCType, 'xRange': [50,75], 'yRange': [0,50], 'cellModel ': 'LA_Mod'}
netParams.popParams['INT'] = {'cellType': 'Inter1', 'numCells': numInter, 'xRange': [75,100], 'yRange': [0,50], 'cellModel ': 'LA_Mod'}

netParams.popParams['Thal_Tone_D'] = {'cellModel': 'VecStim', 'numCells': 1, 'xRange': [100,110], 'yRange': [0, 50], 'spkTimes': toneStimD_List}
netParams.popParams['Cort_Tone_V'] = {'cellModel': 'VecStim', 'numCells': 1, 'xRange': [110,120], 'yRange': [0, 50], 'spkTimes': toneStimV_List}
netParams.popParams['Shock'] = {'cellModel': 'VecStim', 'numCells': 1, 'xRange': [120,130], 'yRange': [0, 50], 'spkTimes': shockStim_List}

'''
#From Mainen Example that works basing synapses and stimulation parameters off it
netParams.synMechParams['AMPA'] = {'mod': 'Exp2Syn', 'tau1': 1.0, 'tau2': 5.0, 'e': 0}  # soma NMDA synapse
netParams.stimSourceParams['bkg'] = {'type': 'NetStim', 'rate': 50, 'noise': 0.5}
netParams.stimTargetParams['bg1'] = {'source': 'bkg', 'conds': {'cellType': 'PYR', 'cellModel': 'LA_Mod'}, 'weight': 0.1, 'delay': 5, 'sec': 'soma'}
'''

## Synaptic mechanism parameters
netParams.synMechParams['exc'] = {'mod': 'Exp2Syn', 'tau1': 1.0, 'tau2': 5.0, 'e': 0}  # soma NMDA synapse
netParams.synMechParams['interD2pyrD_STFD'] = {'mod': 'interD2pyrD_STFD'}	# Interneuron Cells to Pyramidal Cells GABA with local Ca2+ pool and read public soma Ca2+ pool
netParams.synMechParams['pyrD2interD_STFD'] = {'mod': 'pyrD2interD_STFD'} 	# Pyramidal Cells to Interneuron Cells AMPA+NMDA with local Ca2+ pool
netParams.synMechParams['pyrD2pyrD_STFD'] = {'mod': 'pyrD2pyrD_STFD'}		# Pyramidal Cells to Pyramidal Cells AMPA+NMDA with local Ca2+ pool
netParams.synMechParams['shock2interD'] = {'mod': 'shock2interD'}		# Shock to Interneuron Cells AMPA+NMDA with local Ca2+ pool
netParams.synMechParams['shock2pyrD'] = {'mod': 'shock2pyrD'}			# Shock to Pyramidal Cells AMPA+NMDA with local Ca2+ pool
netParams.synMechParams['tone2interD'] = {'mod': 'tone2interD'}			# Tone to Interneuron Cells AMPA+NMDA with local Ca2+ pool
netParams.synMechParams['tone2pyrD'] = {'mod': 'tone2pyrD'}			# Tone to Pyramidal Cells AMPA+NMDA with local Ca2+ pool
netParams.synMechParams['bg2inter'] = {'mod': 'bg2inter'}			# Background to Interneuron Cells AMPA+NMDA 
netParams.synMechParams['bg2pyr'] = {'mod': 'bg2pyr'}				# Background to Pyramidal Cells AMPA+NMDA 

# Stimulation parameters 
# Generate Background Noise (Sources and Targets)
netParams.stimSourceParams['bg2inter_stim'] = {'type': 'NetStim', 'interval': 1000/noise_freq_int, 'number': noise_tot_length*noise_freq_int/1000, 'start': 0, 'noise': 1}
netParams.stimSourceParams['bg2pyr_stim'] = {'type': 'NetStim', 'interval': 1000/noise_freq_pyr, 'number': noise_tot_length*noise_freq_pyr/1000, 'start': 0, 'noise': 1}
'''
netParams.stimTargetParams['bkg->inter'] = {'source': 'bg2inter_stim', 'conds': {'popLabel': 'INT'}, 'weight': 10, 'delay': 0, 'synMech': 'bg2inter'}
netParams.stimTargetParams['bkg->pyr_a'] = {'source': 'bg2pyr_stim', 'conds': {'popLabel': 'PN_A'}, 'weight': 10, 'delay': 0, 'synMech': 'bg2pyr'}
netParams.stimTargetParams['bkg->pyr_b'] = {'source': 'bg2pyr_stim', 'conds': {'popLabel': 'PN_B'}, 'weight': 10, 'delay': 0, 'synMech': 'bg2pyr'}
netParams.stimTargetParams['bkg->pyr_c'] = {'source': 'bg2pyr_stim', 'conds': {'popLabel': 'PN_C'}, 'weight': 10, 'delay': 0, 'synMech': 'bg2pyr'}
'''

## Cell Connectivity Rules
# Connectivity Between Pyramidal and Interneurons

netParams.connParams['PNs->PNs'] = {
	'preConds': {'popLabel': ['PN_A','PN_B','PN_C']},  		# connection from
	'postConds': {'popLabel': ['PN_A','PN_B','PN_C']},		# connnection to
	'probability': 1, 					# probability of connection (.25)
	'weight': 0.01, 						# synaptic weight 
	'delay': randint(10,20),				# transmission delay (ms) 
	'synMech': 'exc'}   				# target synaptic mechanism	

## Connectivity Between Cells and Tone/Shock
# Pyramidal Cells and Input

netParams.connParams['Thal->PNs'] = {
	'preConds': {'pop': 'Thal_Tone_D'}, 
	'postConds': {'pop': 'PN_A'}, 
	'probability': .53, 					# probability of connection
	'weight': 0.05, 					# synaptic weight 
	'delay': randint(10,20),				# transmission delay (ms) 
	'synMech': 'tone2pyrD'}   				# target synaptic mechanism

netParams.connParams['Cort->PNs'] = {
	'preConds': {'pop': 'Cort_Tone_V'}, 
	'postConds': {'pop': 'PN_A'},
	'probability': .53, 					# probability of connection
	'weight': 0.05, 					# synaptic weight 
	'delay': randint(10,20),				# transmission delay (ms) 
	'synMech': 'tone2pyrD'}   				# target synaptic mechanism

netParams.connParams['Shock->PNs'] = {
	'preConds': {'pop': 'Shock'}, 
	'postConds': {'pop': 'PN_A'},
	'probability': .70, 					# probability of connection
	'weight': 0.05, 					# synaptic weight 
	'delay': randint(10,20),				# transmission delay (ms) 
	'synMech': 'shock2pyrD'}   				# target synaptic mechanism

## Simulation options
simConfig = specs.SimConfig()					# object of class SimConfig to store simulation configuration
simConfig.duration = simTime/50					# Duration of the simulation, in ms
simConfig.dt = 0.025 						# Internal integration timestep to use
simConfig.verbose = 0						# Show detailed messages 
simConfig.recordTraces = {'V_soma':{'sec':'soma','loc':0.5,'var':'v'}}  # Dict with traces to record
simConfig.recordStep = 1 					# Step size in ms to save data (eg. V traces, LFP, etc)
simConfig.filename = 'model_output'  				# Set file output name
simConfig.savePickle = False 					# Save params, network and sim output to pickle file

simConfig.analysis['plotRaster'] = True #{'orderInverse': True, 'saveFig': 'tut_import_raster.png'}		# Plot a raster
#simConfig.analysis['plotTraces'] = {'include': [('PN_B', 40),('PN_C', 0),('Inter', 1)], 'overlay':True, 'oneFigPer':'trace'} 		# Plot recorded traces for this list of cells
#simConfig.analysis['plotTraces'] = {'include': [('PN_A', [4,5,6]),('PN_B', [4,5,6])], 'overlay':True} 		# Plot recorded traces for this list of cells
#simConfig.analysis['plotTraces'] = {'include': [('PN_B', [4,5,6])], 'overlay':True, 'oneFigPer':'trace'} 		# Plot recorded traces for this list of cells
#simConfig.analysis['plotTraces'] = {'include': [('PN_C', [4,5,6])], 'overlay':True, 'oneFigPer':'trace'} 		# Plot recorded traces for this list of cells
simConfig.analysis['plotTraces'] = {'include': [39, 45, 77]} 		# Plot recorded traces for this list of cells
simConfig.analysis['plot2Dnet'] = True           			# Plot 2D visualization of cell positions and connections

# Create network and run simulation
sim.createSimulateAnalyze(netParams = netParams, simConfig = simConfig)
Code: Template
This is how I create my cells in my template file, I included CellA

Code: Select all

class Cell_A:
    def __init__ (self):
        self.soma = soma = h.Section(name='soma',cell=self)
        self.initsoma()
    def initsoma (self):
        soma = self.soma
        soma.nseg = 1
        soma.diam = 24.75
        soma.L = 25
        soma.Ra = 200
        soma.cm = 2.5
        soma.insert('cadyn'); soma.gcabar_cadyn = 5.5e-4; soma.eca = 120;
        soma.insert('leak'); soma.glbar_leak = 5.5e-5; soma.el_leak = -72;
        soma.insert('hd'); soma.ghdbar_hd = 1.5e-5;
        soma.insert('na3'); soma.gbar_na3 = 0.03; soma.ena = 45; soma.ar2_na3 = 1;
        soma.insert('nap'); soma.gbar_nap = 0.000142;
        soma.insert('kdr'); soma.ek = -80; soma.gbar_kdr = 0.0035;
        soma.insert('capool'); soma.taucas_capool = 1000; soma.fcas_capool = 0.05;
        soma.insert('sAHP'); soma.gsAHPbar_sAHP = 3e-4;
        soma.insert('im'); soma.gbar_im = 6e-4;
        soma.insert('kap'); soma.gkabar_kap = 0.002;
Thanks,
Brenyn Jungmann

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

Re: Issue stimulating cells that I imported

Post by salvadord » Thu Jun 15, 2017 11:12 pm

Thanks for your message, Brenyn. Your code looks very good. I'm happy to say that in this case the error was due to a minor typo: for pops 'PN_B', 'PN_C' and 'INT' you used 'cellModel ' (with a space) instead of 'cellModel' -- this change fixes your issues.

This is the type of error that will be highlighted by the new "error checking" feature. You can activate it by upgrading to the latest version (netpyne 0.7.0) and setting simConfig.checkErrors = 1. Unfortunately, this feature is still in beta version. I tested it on your code and although it does point out the 'cellModel ' error, it also flags some issues which are NOT really errors (eg. doesn't recognize 'nseg' param). So use with caution for now. We hope to have most of these issues fixed in the next release.

Hope this helps, and please let me know if you have any other questions.

Salva

bwjmbb17
Posts: 16
Joined: Mon Apr 10, 2017 10:09 am

Re: Issue stimulating cells that I imported

Post by bwjmbb17 » Fri Jun 16, 2017 10:53 am

Thanks you. I should have caught that. Thanks for letting me know about the error checking, I may use that feature in the future.

Brenyn

Post Reply