Page 1 of 1

Stimulating current similar to a half wave rectification

Posted: Wed Aug 21, 2013 6:32 am
by srene
Hello,

I have a working network of 500 cells. I want to test synchrony of firing in the network. For that I want to stimulate about 20 % (100 cells) ore more to test the network. I already can do this by putting an IClamp on a random chosen cells, stimulating with a square pulse (see example above).

Code: Select all

nStimuli = 5    // number of stimulations of each cell
nStim = 100        // number of stimulated cells
delay = 100      // begin of stimulation (ms)
duration = 2     // Duration of stimulation (ms)
amplitude = 50   // amplitude of stimulation (mA)

for j = 0, nStimuli-1 {
	for i = 0, nStim-1 Zellen[i].soma{
		stim[i+j*nStim] = new IClamp(0.5)
		stim[i+j*nStim].dur = duration
		stim[i+j*nStim].del = delay + 110*j
		stim[i+j*nStim].amp = amplitude
	}
}
My question is now, can you help me change this stimulus so that I can get a current over time which is similar to a half wave rectification, see also here:

Half wave rectification

I would need to modify the same parameters as in the existing stimuli.

Best regards,

srene

Re: Stimulating current similar to a half wave rectification

Posted: Wed Aug 21, 2013 9:36 pm
by ted
Download http://www.neuron.yale.edu/ftp/ted/neuron/ihalfwave.zip
Expand it, then use nrnivmodl (mknrndll for OS X and MSWin users) to compile the ihw.mod
Use NEURON to execute hwdemo.hoc (that's a session file that creates a single passive compartment with 100 um2 surface area, a RunControl panel, an instance of the Ihw class, and graphs of soma.v and Ihw.i).

Ihw is a point process class, like IClamp, but instead of a current step it delivers a half-wave rectified sinusoidal current. The current is

Code: Select all

i = amp*hw(f*(t - del))
where
amp is peak ampltude (may be + or -)
f is frequency in radians/s
hw(theta) = sin(theta) if sin(theta)>=0
            0 if sin(theta)<0
The current starts at t==del and ends at t==del+dur.

Re: Stimulating current similar to a half wave rectification

Posted: Sun Aug 25, 2013 8:46 am
by srene
Hello Ted,

thank you very much for responding that early. I thought I would get an email whenever someone answers so I´m late. I will try it.

Re: Stimulating current similar to a half wave rectification

Posted: Sun Aug 25, 2013 1:17 pm
by ted
Next time you enter a message, examine the "Options" (below the text entry area) and see if the box next to "Notify me when a reply is posted" is checked.

Re: Stimulating current similar to a half wave rectification

Posted: Wed Sep 04, 2013 6:02 am
by srene
Thanks again,

it´s checked now...

Is it possible to change the gap between two pulses of ihw? Like in the example i can change the distance between two square pulses by adding s.th. to the delay and multiplying it with the control variable j:

Code: Select all

for j = 0, nStimuli-1 {
   for i = 0, nStim-1 Zellen[i].soma{
      stim[i+j*nStim] = new IClamp(0.5)
      stim[i+j*nStim].dur = duration
      stim[i+j*nStim].del = delay + 110*j
      stim[i+j*nStim].amp = amplitude
   }
I know it wouldn´t be a HW anymore.

Re: Stimulating current similar to a half wave rectification

Posted: Wed Sep 04, 2013 2:43 pm
by ted
srene wrote:Like in the example
Like in what example, where?

It doesn't take much to revise the Ihw mechanism so that it can be activated at a fixed onset time, or driven by external events. That means you can use a NetStim to generate events at preferred times, connect that NetStim to an Ihw with a NetCon, and voila--each time the Ihw receives an event, it produces one or more halfwave rectified sines. The necessary hoc code is much cleaner and easier to maintain. The revised mechanism and demonstration code is now available
http://www.neuron.yale.edu/ftp/ted/neuron/ihalfwave.zip

Re: Stimulating current similar to a half wave rectification

Posted: Tue Sep 24, 2013 5:01 am
by srene
Thank you again.

Now there is one more thing...

I want to use a control variable j. j is the number of stimuli or the peaks of current. Therefore I need Pi π to do s.th. like this....

Code: Select all

dur = 200       // Duration of Stimulation  (ms)
Frequenz= 30  // frequency (Hz)
f= Frequenz*(2*???Pi???) // frequency (radians/s)
T = (1/Frequenz)*1000      //period of Ihw  (ms)
nStimuli = dur/T   // number of peaks problem is nStimuli is not an int


for j=0, nStimuli-1{
....

}
My questions would be how can I use Pi π in the hoc language and how could I round up /off the fraction nstimuli to get it as an integer and finally use it as a control variable j. The question marks in the code means I don´t know how to use π.

Re: Stimulating current similar to a half wave rectification

Posted: Tue Sep 24, 2013 5:53 pm
by ted
hoc has several built in "constants." Read about them in the Programmer's Reference.
http://www.neuron.yale.edu/neuron/stati ... #Constants

You might want to browse in the Programmer's Reference to see what else you might find that would be good to know about. I like the old "quick reference"
http://www.neuron.yale.edu/neuron/stati ... rence.html
because it's so easy to navigate, and it has links to many important things, like Geometry and Section, that, for some reason or other, the new sphinx-generated reference pages
http://www.neuron.yale.edu/neuron/stati ... index.html
seem to ignore.

Re: Stimulating current similar to a half wave rectification

Posted: Wed Dec 11, 2013 8:13 am
by srene
Hello Ted,

there is another question. My stim is now Ihw.. is there a possibility to change the amp but of course keeping the frequency? When i use an IClamp I can use this:

Code: Select all

nStimuli= 3 // would give me three stim
nStim = 30 //  would stimulate 30 cells each three times
Frequenz = 80 // Hz
T=(1/Frequenz)*1000
amplitude = 10 // nA
duration = T/2
for j = 0, nStimuli-1 {
	for i = 0, nStim-1 Zellen[i].soma{
		stim[i+j*nStim] = new IClamp(0.5)
		stim[i+j*nStim].dur = duration
		stim[i+j*nStim].del = delay + T*j
		stim[i+j*nStim].amp = amplitude - abs(j-1)              //abs(j-1) gives me an change of amp like 9,10,9 or I can use other functions
	}
}
Can I do s.th. similar with Ihw because I dont want a square pulse.

Or another question if I connect the IHW with NetCon to a NetStim can i change amps of the NetStim?


srene

Re: Stimulating current similar to a half wave rectification

Posted: Wed Dec 11, 2013 2:54 pm
by ted
ted wrote:
srene wrote:Like in the example
It doesn't take much to revise the Ihw mechanism so that it can be activated at a fixed onset time, or driven by external events. That means you can use a NetStim to generate events at preferred times, connect that NetStim to an Ihw with a NetCon, and voila--each time the Ihw receives an event, it produces one or more halfwave rectified sines. The necessary hoc code is much cleaner and easier to maintain. The revised mechanism and demonstration code is now available
http://www.neuron.yale.edu/ftp/ted/neuron/ihalfwave.zip
Except that the demo program had a bug (rig.ses included a graph that tried to plot istim.i _before_ the istim.i variable existed). I have now fixed that and the demo program now works correctly.

Re: Stimulating current similar to a half wave rectification

Posted: Wed Dec 11, 2013 4:17 pm
by ted
srene wrote:there is another question. My stim is now Ihw.. is there a possibility to change the amp but of course keeping the frequency? When i use an IClamp I can use this
Now that I see how you are using IClamp, it is clear that my original implementation of Ihw was not as convenient as it should have been. If your primary stimulus parameters are "sine wave frequency" and "number of half cycles" it is best for the stimulus generator to be controlled by the same parameters, without requiring you to do any arithmetic. This zip file
http://www.neuron.yale.edu/ftp/ted/neuron/ihalfwave.zip
contains an updated version of ihw.mod and a demonstration program that you can launch by executing the init.hoc file.
is there a possibility to change the amp
Does this mean that you want each half cycle of current to have a different peak amplitude?