Page 2 of 3
Re: Extracellular Stimulation (2d)
Posted: Wed Jan 12, 2011 4:58 pm
by shilpa
Hello Ted,
I am trying to implement the extracellular stim and rec on Poirazi's model. I need to give a sinusoidal stimuli on selective segments, if possible could you post the mod file you mentioned earlier along with the instructions to link it to xtra's stimulus current variable.
ted wrote:For this, better than Vector play is to use a mod file that computes the waveform analytically. This works for any frequency and, since the function is computed for the actual time, also works for any dt--even with adaptive integration, in which dt may change in the course of simulation. Later today I'll send you a mod file that produces a sine wave with specified onset time, number of cycles, and amplitude, plus instructions for how to link its output to xtra's "stimulus current" variable.
thank you,
regards,
Shilpa
Re: Extracellular Stimulation (2d)
Posted: Thu Jan 13, 2011 1:01 pm
by ted
Re: Extracellular Stimulation (2d)
Posted: Thu Jan 13, 2011 2:11 pm
by shilpa
thank you Ted.
Re: Extracellular Stimulation (2d)
Posted: Thu Jan 13, 2011 9:47 pm
by ted
Good luck with your investigations, and thank you for using NEURON in your research.
Re: Extracellular Stimulation (2d)
Posted: Sun Jan 30, 2011 8:55 pm
by shilpa
Hello Ted,
I tried using the fsin.mod file to generate the sinwave to be used as input to the extracellular stimulus recording program using the initxstim.hoc. However I am not seeing a response. I cannot figure out where I am going wrong. I understand that Pointer "x" in fsin.mod passes the stimulus waveform to GLOBAL "is" of xtra.mod. I am new to using pointer syntax and I keep getting errors when I follow the instructions in the programmer's reference. I think I am missing something. I commented out stim.hoc and instead included the following code, there is no error but no response either.
Code: Select all
proc freq_stim() {
f_fsin=5
n_fsin=1000
amp_fsin=10
}
freq_stim()
forall if (ismembrane("xtra")) {
xf_fsin(&is_xtra)
}
could you please guide me?
thank you,
best
Re: Extracellular Stimulation (2d)
Posted: Sun Jan 30, 2011 9:40 pm
by shilpa
sorry a correction in the code:
Code: Select all
proc freq_stim() {
f_fsin=5
n_fsin=1000
amp_fsin=100
}
freq_stim()
forall if (ismembrane("xtra")) {
x_fsin(&is_xtra)
}
thanks,
regards
Re: Extracellular Stimulation (2d)
Posted: Mon Jan 31, 2011 1:40 pm
by ted
Suggest you examine the hoc code that accompanies xtra.mod. Start by reading setpointers.hoc.
Re: Extracellular Stimulation (2d)
Posted: Mon Feb 28, 2011 2:10 pm
by shilpa
I went through the hoc files along with xtra.mod including setpointer.hoc. I wish to know if fsin.mod is to be treated as a mechanism or point process? either way I keep getting syntax errors. I cannot figure out what I am missing yet.
thanks,
regards.
Re: Extracellular Stimulation (2d)
Posted: Tue Mar 01, 2011 10:52 am
by ted
I wish to know if fsin.mod is to be treated as a mechanism or point process?
Read the NEURON block. SUFFIX means it's a density mechanism, POINT_PROCESS means it's a point process.
I went through the hoc files along with xtra.mod including setpointer.hoc. . . . I keep getting syntax errors.
Pointers in hoc seem hard to deal with mostly because they're unfamiliar. This should get you going:
Code: Select all
objref fs
fs = new Fsin(0.5)
setpointer fs.x, is_xtra // is_xtra is a GLOBAL so this takes care of all sections with xtra
Re: Extracellular Stimulation (2d)
Posted: Mon Mar 07, 2011 4:01 pm
by shilpa
Hello Ted,
thanks for the clarification, they was some problem in compiling the mod file as a point process. Its been sorted out now. Still getting used to the some of the hoc syntax. Now am able to implement the extracellular stimulation and recording code to the CA1 neuron I am using for my experiments and its working well for now. Thanks again.
regards
Multiple statements in Before Breakpoint block of xtra
Posted: Wed Apr 06, 2011 2:34 pm
by shilpa
Hello Ted,
I wanted to create 2 instances of monopolar stimulating electrode and 1 instance of recording electrode. I modified the xtra.mod file as follows:
Code: Select all
NEURON {
SUFFIX xtra
RANGE rx, er, rxstim1, rxstim2
RANGE x, y, z
GLOBAL is, isap
POINTER im, ex, exap
}
PARAMETER {
: default transfer resistance between stim electrodes and axon
rx = 1 (megohm) : mV/nA
rxstim1 = 1 (megohm) : mV/nA
rxstim2 = 1 (megohm) : mV/nA
x = 0 (1) : spatial coords
y = 0 (1)
z = 0 (1)
}
ASSIGNED {
is (milliamp)
isap (milliamp)
v (millivolts)
ex (millivolts)
exap (millivolts)
im (milliamp/cm2)
er (microvolts)
area (micron2)
}
INITIAL {
ex = is*rxstim1*(1e6)
exap = isap*rxstim2*(1e6)
er = (10)*rx*im*area
: this demonstrates that area is known
: UNITSOFF
: printf("area = %f\n", area)
: UNITSON
}
: With NEURON 5.5 and later, abandon the BREAKPOINT block and PROCEDURE f(),
: and instead use BEFORE BREAKPOINT and AFTER BREAKPOINT
BEFORE BREAKPOINT { : before each cy' = f(y,t) setup
ex = is*rxstim1*(1e6)
exap = isap*rxstim2*(1e6)
}
AFTER SOLVE { : after each solution step
er = (10)*rx*im*area
}
I also changed calcrxc.hoc and setpointers.hoc
Code: Select all
proc setpointers() { local done
grindaway() // in interpxyz.hoc, determines interpolated locations of nodes
forall {
if (ismembrane("xtra")) {
for (x, 0) {
setpointer im_xtra(x), i_membrane(x)
setpointer ex_xtra(x), e_extracellular(x)
setpointer exap_xtra(x), e_extracellular(x)
}
}
}
}
print "After any change to cell geometry or nseg, be sure to invoke setpointers()"
setpointers()
My model runs correctly if I have just one stimulating electrode active i.e when either ex or exap statement is present in the Before Breakpoint block of xtra.mod. When both are present only the second statement in the Before Breakpoint block is executed irrespective of the order. For my model purpose I need both the statements to be executed at the same time so that I have two simultaneous stimuli. Could you please provide a solution?
thank you..
Re: Extracellular Stimulation (2d)
Posted: Thu Apr 07, 2011 10:41 am
by ted
Nice try but doomed to fail. Why? Because this
Code: Select all
setpointer ex_xtra(x), e_extracellular(x)
setpointer exap_xtra(x), e_extracellular(x)
cannot work. e_extracellular(x) can only have a single value. Linking it to two other variables only means that it will get its value from one of them--but which one? The second one to which a value is assigned, of course--as you discovered.
So you're going to have to accomplish superposition of the two stimuli inside the xtra mechanism itself, and then use a single setpointer statement to communicate the resulting value to e_extracellular(x).
Start by copying the original xtra.mod to a file called xtra2.mod, and edit xtra2.mod to make the following changes:
In the NEURON block change the SUFFIX, RANGE, and GLOBAL declarations that involve xtra, rx, er, and is to
SUFFIX xtra2 : so you won't ever confuse this with the original xtra.mod
RANGE rx1, rx2, er1, er2
GLOBAL is1, is2
Don't do anything to the declarations of x,y,z, im, or ex.
In the PARAMETER block replace
rx = 1 (megohm)
with
rx1 = 1 (megohm)
rx2 = 1 (megohm)
In the ASSIGNED block replace
er (microvolts)
with
er1 (microvolts)
er2 (microvolts)
Change the INITIAL block's contents to
ex = (is1*rx1 + is2*rx2)*(1e6) : superposition!
er1 = (10)*rx1*im*area
er2 = (10)*rx2*im*area
Change the BEFORE BREAKPOINT block's contents to
ex = (is1*rx1 + is2*rx2)*(1e6) : superposition!
Change the AFTER SOLVE block's contents to
er1 = (10)*rx1*im*area
er2 = (10)*rx2*im*area
Check with modlunit to make sure things are OK, and reexamine the NMODL code to make sure it makes sense.
Make appropriate revisions to all the hoc files that involve statements that refer to xtra and you should be good to go. But test with a toy model to make sure that simulation results make sense.
Re: Extracellular Stimulation (2d)
Posted: Fri Apr 08, 2011 5:20 pm
by shilpa
Hello Ted,
Thanks for your reply. The superposition worked, I can now get both stimuli working together. For after solve I used the same statement from xtra.mod as I had dissociated stimulation and recording electrodes. So a single recording electrode works for my purpose.
regards.
Re: Extracellular Stimulation (2d)
Posted: Wed Jul 01, 2015 3:55 pm
by Igoy
Hi -
Very new user here trying to learn how to model with Neuron.
Currently, I am working with the McIntyre-Richardson-Grill model (MRGaxon) and attempting to use it with the extracellular mechanism provided in the "extracellular_stim_and_rec" zip file previously mentioned in this thread.
I went through step-by-step as suggested in
viewtopic.php?f=8&t=1814#p6590.
1. I commented out "load_proc("nrnmainmenu") from MRGaxon.hoc
2. I commented out the intracellular currents and the xpanel associated with it from the MRGaxon.hoc file
3. I modified initxstim.hoc so it is now:
Code: Select all
// $Id: initxstim.hoc,v 1.2 2005/09/10 23:02:15 ted Exp $
// extracellular recording from model subjected to extracellular stimulation
load_file("nrngui.hoc")
load_file("MRGaxon.hoc") // load MRG model
forall insert xtra
define_shape()
load_file("anatscale.hoc") // show xyz scale bars
load_file("interpxyz.hoc") // only interpolates sections that have extracellular
load_file("setpointers.hoc") // automatically calls grindaway() in interpxyz.hoc
load_file("rigc.ses") // RunControl, graphs of v, vext, e_extracellular
load_file("rigxc.ses") // graph of er_xtra, just for diagnostic|development purposes
load_file("field.hoc") // computes extracellularly recorded potential vrec
load_file("vrecc.ses") // graph of vrec(t)
load_file("calcrxc.hoc") // computes transfer r between segments and recording electrodes
load_file("stim.hoc") // extracellular stimulus
load_file("msgxc.hoc") // minimal hints
I removed all elements of dend* from the rigxc and rigc files, and that appears to have taken care of the rebuilding of those files.
Now, when I run the simulation with extracellular stimulation (del=3,dur=1,amp=-0,5), I see two spikes. One at t=1 and the other at t=3. This suggests to me that the extracellular stimulation is working - however, when I turn the extracellular stimulation off (del=, dur=0, amp=0), instead of getting a steady state response where the membrane is at 0 the entire time, I still see the spike at t=1.
To check to see if this was in the MRG model, I removed the intracellular stimulation from the MRG model and as expected, it shows steady state behavior the entire simulation duration. This leads me to believe I am doing something wrong with the extracelluar stimulation or not understanding where the first spike is coming from.
Any suggestions on how to debug or what this may be are greatly appreciated.
Re: Extracellular Stimulation (2d)
Posted: Thu Jul 02, 2015 12:42 pm
by ted
Looks like you've done a lot of work. The problem with reusing code from ModelDB entry 3810 ("Spinal Motor Neuron (McIntyre et al 2002)") is that your first step must be to refactor their source code, which is written in a way that interlaces model specification (i.e. specification of how the anatomical and biophysical properties of the axon itself are represented) with instrumentation (stimulation, recording and/or display of results) and simulation control code (specification of dt, tstop, controls to launch simulations etc.). This is hard enough to do for one who is quite familiar with NEURON.
Fortunately, this is your lucky day--I have already done that, and tested the result to verify that the refactoring introduced no bugs. Pick up
https://www.neuron.yale.edu/ftp/ted/tmp/revMRGaxon.hoc
and in your own initxstim.hoc change
load_file("MRGaxon.hoc")
to
// load_file("MRGaxon.hoc")
load_file("revMRGaxon.hoc")
and see if that takes care of the problem.
By the way, unless you really want to see the extracellular field produced by the axon, you can comment out these two lines
load_file("field.hoc") // computes extracellularly recorded potential vrec
load_file("vrecc.ses") // graph of vrec(t)
I removed all elements of dend* from the rigxc and rigc files, and that appears to have taken care of the rebuilding of those files.
Yep, that's an effective way to fix a ses file that references nonexisting sections.