File: ipulse2.mod

package info (click to toggle)
neuron 8.2.6-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 34,760 kB
  • sloc: cpp: 149,571; python: 58,465; ansic: 50,329; sh: 3,510; xml: 213; pascal: 51; makefile: 35; sed: 5
file content (78 lines) | stat: -rw-r--r-- 1,359 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
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
  }
  on = 0
  i = 0
  ival = 0
  tally = num
  if (tally > 0) {
    net_send(del, 1)
    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
      }
    }
  }
}