Problem in using TMS pulse (defined as tms2.mod) in netpyne

80 views
Skip to first unread message

Mohammadreza V.Farahani

unread,
Nov 17, 2021, 4:06:44 AM11/17/21
to NetPyNE Q&A forum

Hi everyone,

I am going to use a TMS pulse (defined as tms2.mod) in netpyne, but it's parameters seem unchangeable trough netParams.stimSourceParams.

I mean when I use below code to define a stimulation source, result do not change by changing it's parameters (for example 'onset')

netParams.stimSourceParams['Input_1'] = {'type': 'TMSpulse_bi','onset': 50, 'decay': 0.08, 'imax':40}

actually just below code is enough to make a stimulation

netParams.stimSourceParams['Input_1'] = {'type': 'TMSpulse_bi'}

would you please help me solve this issue and use  tms2.mod  in netpyne?

My operation system is Ms Widows 10 and I am using latest version of spyder(GUI), python, NetPyNE and Neuron. 

thanks


Source of  tms2.mod file: https://github.com/trieschlab/tms_model/tree/master/code/mechanisms

 tms2.mod as txt:

COMMENT
Monophasic current induced by a TMS stimulation. Positive values of i depolarize the cell.
ENDCOMMENT

NEURON {
POINT_PROCESS TMSpulse_bi
RANGE onset,decay,imax
ELECTRODE_CURRENT i
}

UNITS {
(nA) = (nanoamp)
(uS) = (microsiemens)
}

PARAMETER {
onset = 10 (ms)
decay = 0.08 (ms)
imax = 40 (nA)
}

ASSIGNED {
i (nA)
}

INITIAL {
i = 40 (nA)
}
BREAKPOINT {
if (imax) {
at_time(onset)
}

if ((t - onset) < 0 || (t - onset) > 20) {
i = 0
} else {
i = imax*sin (30*(t - onset)) * exp ( -(t - onset)/decay)
}


}

FUNCTION alpha(x) {
if (x < 0 || x > 20) {
alpha = 0
}else{
alpha = exp(1 - x) - x * exp(1 - x)
}
}

Joe Graham

unread,
Nov 30, 2021, 10:23:25 PM11/30/21
to NetPyNE Q&A forum
Hello,

I'd be happy to take a look if you could include a minimal example that demonstrates the problem.  A simple sim with two cells with your stim mechanism set to different onset times which generates a plot of traces showing no change would do the job.

Cheers,
Joe
Message has been deleted
Message has been deleted

Mohammadreza V.Farahani

unread,
Dec 5, 2021, 8:41:23 AM12/5/21
to NetPyNE Q&A forum
Dear Joe,
Thank you for your kind response
Blew is a simple sample that shows the problem. No matter which of highlighted lines is used, the result is the same. attachment include the code, .mod and .dll files.
 
from netpyne import specs, sim

# Network parameters
netParams = specs.NetParams()  # object of class NetParams to store the network parameters

## Cell types
PYRcell = {'secs': {}}

PYRcell['secs']['soma'] = {'geom': {}, 'mechs': {}}
PYRcell['secs']['soma']['geom'] = {'diam': 18.8, 'L': 18.8, 'Ra': 123.0}
PYRcell['secs']['soma']['mechs']['hh'] = {'gnabar': 0.12, 'gkbar': 0.036, 'gl': 0.003, 'el': -70}

PYRcell['secs']['dend'] = {'geom': {}, 'topol': {}, 'mechs': {}}
PYRcell['secs']['dend']['geom'] = {'diam': 5.0, 'L': 150.0, 'Ra': 150.0, 'cm': 1}
PYRcell['secs']['dend']['topol'] = {'parentSec': 'soma', 'parentX': 1.0, 'childX': 0}
PYRcell['secs']['dend']['mechs']['pas'] = {'g': 0.0000357, 'e': -70}

netParams.cellParams['PYR'] = PYRcell

## Population parameters
netParams.popParams['S'] = {'cellType': 'PYR', 'numCells': 1}
netParams.popParams['M'] = {'cellType': 'PYR', 'numCells': 1}

## Synaptic mechanism parameters
netParams.synMechParams['exc'] = {'mod': 'Exp2Syn', 'tau1': 1.0, 'tau2': 5.0, 'e': 0}  # excitatory synaptic mechanism

# Stimulation parameters

netParams.stimSourceParams['Input_1'] = {'type': 'TMSpulse_bi'}
# netParams.stimSourceParams['Input_1'] = {'type': 'TMSpulse_bi','onset': 40, 'decay': 0.08, 'imax':40}
# netParams.stimSourceParams['Input_1'] = {'type': 'TMSpulse_bi','onset': 60, 'decay': 0.08, 'imax':40}
# netParams.stimSourceParams['Input_1'] = {'type': 'TMSpulse_bi','onset': 60, 'decay': 0.08, 'imax':10}
netParams.stimTargetParams['Input_1->S'] = {'source': 'Input_1', 'sec':'dend', 'loc': 0.5,'conds': {'pop':'S'}}

## Cell connectivity rules
netParams.connParams['S->M'] = {'preConds': {'pop': 'S'}, 'postConds': {'pop': 'M'},  #  S -> M
    'probability': 1,         # probability of connection
    'weight': 0.1,             # synaptic weight
    # 'delay': 5,                 # transmission delay (ms)
    'sec': 'dend',              # section to connect to
    'loc': 1.0,                 # location of synapse
    'synMech': 'exc'}           # target synaptic mechanism

# Simulation options
simConfig = specs.SimConfig()       # object of class SimConfig to store simulation configuration

simConfig.duration = 0.1*1e3        # Duration of the simulation, in ms
simConfig.dt = 0.025                # Internal integration timestep to use
simConfig.verbose = False           # Show detailed messages
simConfig.recordTraces = {'V_soma':{'sec':'soma','loc':0.5,'var':'v'}}  # Dict with traces to record

simConfig.recordStep = 0.1            # Step size in ms to save data (eg. V traces, LFP, etc)
simConfig.filename = 'test'         # Set file output name
simConfig.savePickle = False        # Save params, network and sim output to pickle file

simConfig.analysis['plotRaster'] = {'saveFig': True}                    # Plot a raster
simConfig.analysis['plotTraces'] = {'include': [0,1], 'saveFig': True}  # Plot recorded traces for this list of cells
simConfig.analysis['plot2Dnet'] = {'saveFig': True}                     # plot 2D cell positions and connections

# Create network and run simulation
sim.createSimulateAnalyze(netParams = netParams, simConfig = simConfig)

Question-TMS.py
tms2.mod

Joe Graham

unread,
Dec 6, 2021, 11:23:20 AM12/6/21
to NetPyNE Q&A forum
Hello,

I had to do a little digging, but I figured out the problem.  While your mod file seems like a perfectly reasonable stimulation point process, it turns out that only builtin NEURON stimulation point processes can be specified using `stimSourceParams`.  The builtins: NetStim, IClamp, VClamp, SEClamp, and AlphaSynapse.

To use a point process other than those, you need to specify it in your cell model, rather than in stimSourceParams. I have attached a file showing how to do that, which does change the stim parameters.

It seems like NetPyNE should accept generic point process stimulations, so I have submitted a feature request: https://github.com/Neurosim-lab/netpyne/issues/637

It should be possible to set up a generic stimulation in a future NetPyNE release, but for now you can get the same results with the attached file.

Good luck, and don't hesitate to reach out.

Cheers,
Joe
Question-TMS_joe.py

Mohammadreza V.Farahani

unread,
Dec 7, 2021, 3:04:51 AM12/7/21
to NetPyNE Q&A forum
Dear Joe,
Thank you very much. I learned a lot from the solution. I am looking forward to seeing the possibility to set up a generic stimulation in a future NetPyNE release.

Joe Graham

unread,
Dec 7, 2021, 12:15:18 PM12/7/21
to NetPyNE Q&A forum
Hello,

Well, as it turns out, NetPyNE does already allow generic stimulations, but there was a bug in loading the exotic stimulation parameters/values.  I have fixed the bug, and your original model file runs correctly now (stim param values get changed as they should).

You can already use the updated code from our development branch (https://github.com/Neurosim-lab/netpyne/tree/development), or the fix will also be included in our next release, which should happen within a week.  

Best wishes,
Joe

Mohammadreza V.Farahani

unread,
Dec 11, 2021, 2:30:44 AM12/11/21
to NetPyNE Q&A forum
Hello,
I suggest improving the netParams.stimSourceParams in the new update to accept stimulation time series instead of just one stimulation time. that will make netpyne very convenient to be used for modeling train of stimulation, which is used in rTMS and other repetitive stimulation technics.
Regards
Mohammadreza V.Farahani
Reply all
Reply to author
Forward
0 new messages