periodic stimulation?

Anything that doesn't fit elsewhere.
Post Reply
ee171
Posts: 2
Joined: Fri Jul 29, 2005 2:51 pm

periodic stimulation?

Post by ee171 » Tue Aug 02, 2005 4:15 am

hi,

do you know if there is an alternative of creating a periodic current stimulation effectively? the current way i have is, if i want to create a periodic 3 pulses current stimulation i have to create three IClamp objects. is that a good idea?

ted
Site Admin
Posts: 5704
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Post by ted » Tue Aug 02, 2005 8:32 pm

Whatever works.

But the most flexible approach is to use a mechanism that takes advantage
of NEURON's event delivery system. Here's the NMODL code for Ipulse1
and Ipulse2, which can deliver one or more pulses at regular intervals. Both
use self-events to govern switching the current on and off. Although these
mechanisms have NET_RECEIVE blocks, they will not respond to external
events, so it won't do any good to try to attach them to an event source such
as a NetStim.

The chief difference between Ipulse1 and Ipulse2 is how you specify the stimulus
train. Ipulse1 needs ton (duration of current pulse) and toff (interpulse interval),
while Ipulse2 needs dur (same as Ipulse1's ton) and per (the period of the
stimlus train, which is the same as Ipulse1's ton+toff). A bit of code in ipulse2.mod
forces per to be longer than dur.

To learn more about NEURON's event delivery system (at least the stuff that is
relevant to these models), see chapter 10 of The NEURON Book
http://www.neuron.yale.edu/ftp/ted/book ... xedref.pdf

Code: Select all

COMMENT
  ipulse1.mod
  Generates a train of current pulses
  User specifies duration of pulse, interpulse interval (ton and toff),
  and number of pulses.
  1/24/2002 NTC
ENDCOMMENT

NEURON {
	POINT_PROCESS Ipulse1
	RANGE del, ton, toff, num, amp, i
	ELECTRODE_CURRENT i
}

UNITS {
	(nA) = (nanoamp)
}

PARAMETER {
	del (ms)
	ton (ms) <0, 1e9>	: duration of ON phase
	toff (ms) <0, 1e9>	: duration of OFF phase
	num			: how many to deliver
	amp (nA)		: how big
}

ASSIGNED {
	ival (nA)
	i (nA)
	on
	tally			: how many more to deliver
}

INITIAL {
	i = 0
	ival = 0
	tally = num
	if (tally > 0) {
		net_send(del, 1)
		on = 0
		tally = tally - 1
	}
}

BREAKPOINT {
: printf("%g\n", t)
	i = ival
}

NET_RECEIVE (w) {
	: ignore any but self-events with flag == 1
	if (flag == 1) {
		if (on == 0) {
			: turn it on
			ival = amp
			on = 1
			: prepare to turn it off
			net_send(ton, 1)
		} else {
			: turn it off
			ival = 0
			on = 0
			if (tally > 0) {
				: prepare to turn it on again
				net_send(toff, 1)
				tally = tally - 1
			}
		}
	}
}

Code: Select all

COMMENT
  ipulse2.mod
  Generates a train of current pulses
  User specifies dur (pulse duration), per (period, i.e. interval between pulse onsets),
  and number of pulses.
  Ensures that period is longer than pulse duration.
  2/6/2002 NTC
ENDCOMMENT

NEURON {
	POINT_PROCESS Ipulse2
	RANGE del, dur, per, num, amp, i
	ELECTRODE_CURRENT i
}

UNITS {
	(nA) = (nanoamp)
}

PARAMETER {
	del (ms)
	dur (ms) <0, 1e9>	: duration of ON phase
	per (ms) <0, 1e9>	: period of stimuls, i.e. interval between pulse onsets
	num			: how many to deliver
	amp (nA)		: how big
}

ASSIGNED {
	ival (nA)
	i (nA)
	on
	tally			: how many more to deliver
}

INITIAL {
	if (dur >= per) {
		per = dur + 1 (ms)
		printf("per must be longer than dur\n")
UNITSOFF
		printf("per has been increased to %g ms\n", per)
UNITSON
	}
	i = 0
	ival = 0
	tally = num
	if (tally > 0) {
		net_send(del, 1)
		on = 0
		tally = tally - 1
	}
}

BREAKPOINT {
	i = ival
}

NET_RECEIVE (w) {
	: ignore any but self-events with flag == 1
	if (flag == 1) {
		if (on == 0) {
			: turn it on
			ival = amp
			on = 1
			: prepare to turn it off
			net_send(dur, 1)
		} else {
			: turn it off
			ival = 0
			on = 0
			if (tally > 0) {
				: prepare to turn it on again
				net_send(per - dur, 1)
				tally = tally - 1
			}
		}
	}
}

Post Reply