|
| 1 | +TITLE svclmp.mod |
| 2 | +COMMENT |
| 3 | +Single electrode Voltage clamp with three levels. |
| 4 | +Clamp is on at time 0, and off at time |
| 5 | +dur1+dur2+dur3. When clamp is off the injected current is 0. |
| 6 | +The clamp levels are amp1, amp2, amp3. |
| 7 | +i is the injected current, vc measures the control voltage) |
| 8 | +Do not insert several instances of this model at the same location in order to |
| 9 | +make level changes. That is equivalent to independent clamps and they will |
| 10 | +have incompatible internal state values. |
| 11 | +The electrical circuit for the clamp is exceedingly simple: |
| 12 | +vc ---'\/\/`--- cell |
| 13 | + rs |
| 14 | + |
| 15 | +Note that since this is an electrode current model v refers to the |
| 16 | +internal potential which is equivalent to the membrane potential v when |
| 17 | +there is no extracellular membrane mechanism present but is v+vext when |
| 18 | +one is present. |
| 19 | +Also since i is an electrode current, |
| 20 | +positive values of i depolarize the cell. (Normally, positive membrane currents |
| 21 | +are outward and thus hyperpolarize the cell) |
| 22 | +ENDCOMMENT |
| 23 | + |
| 24 | +INDEPENDENT {t FROM 0 TO 1 WITH 1 (ms)} |
| 25 | + |
| 26 | +DEFINE NSTEP 3 |
| 27 | + |
| 28 | +NEURON { |
| 29 | + POINT_PROCESS SEClamp |
| 30 | + ELECTRODE_CURRENT i |
| 31 | + RANGE dur1, amp1, dur2, amp2, dur3, amp3, rs, vc, i |
| 32 | +} |
| 33 | + |
| 34 | +UNITS { |
| 35 | + (nA) = (nanoamp) |
| 36 | + (mV) = (millivolt) |
| 37 | + (uS) = (microsiemens) |
| 38 | +} |
| 39 | + |
| 40 | + |
| 41 | +PARAMETER { |
| 42 | + rs = 1 (megohm) <1e-9, 1e9> |
| 43 | + dur1 (ms) amp1 (mV) |
| 44 | + dur2 (ms) <0,1e9> amp2 (mV) |
| 45 | + dur3 (ms) <0,1e9> amp3 (mV) |
| 46 | +} |
| 47 | + |
| 48 | +ASSIGNED { |
| 49 | + v (mV) : automatically v + vext when extracellular is present |
| 50 | + i (nA) |
| 51 | + vc (mV) |
| 52 | + tc2 (ms) |
| 53 | + tc3 (ms) |
| 54 | + on |
| 55 | +} |
| 56 | + |
| 57 | +INITIAL { |
| 58 | + tc2 = dur1 + dur2 |
| 59 | + tc3 = tc2 + dur3 |
| 60 | + on = 0 |
| 61 | +} |
| 62 | + |
| 63 | +BREAKPOINT { |
| 64 | + SOLVE icur METHOD after_cvode |
| 65 | + vstim() |
| 66 | +} |
| 67 | + |
| 68 | +PROCEDURE icur() { |
| 69 | + if (on) { |
| 70 | + i = (vc - v)/rs |
| 71 | + }else{ |
| 72 | + i = 0 |
| 73 | + } |
| 74 | +} |
| 75 | + |
| 76 | +COMMENT |
| 77 | +The SOLVE of icur() in the BREAKPOINT block is necessary to compute |
| 78 | +i=(vc - v(t))/rs instead of i=(vc - v(t-dt))/rs |
| 79 | +This is important for time varying vc because the actual i used in |
| 80 | +the implicit method is equivalent to (vc - v(t)/rs due to the |
| 81 | +calculation of di/dv from the BREAKPOINT block. |
| 82 | +The reason this works is because the SOLVE statement in the BREAKPOINT block |
| 83 | +is executed after the membrane potential is advanced. |
| 84 | + |
| 85 | +It is a shame that vstim has to be called twice but putting the call |
| 86 | +in a SOLVE block would cause playing a Vector into vc to be off by one |
| 87 | +time step. |
| 88 | +ENDCOMMENT |
| 89 | + |
| 90 | +PROCEDURE vstim() { |
| 91 | + on = 1 |
| 92 | + if (dur1) {at_time(dur1)} |
| 93 | + if (dur2) {at_time(tc2)} |
| 94 | + if (dur3) {at_time(tc3)} |
| 95 | + if (t < dur1) { |
| 96 | + vc = amp1 |
| 97 | + }else if (t < tc2) { |
| 98 | + vc = amp2 |
| 99 | + }else if (t < tc3) { |
| 100 | + vc = amp3 |
| 101 | + }else { |
| 102 | + vc = 0 |
| 103 | + on = 0 |
| 104 | + } |
| 105 | + icur() |
| 106 | +} |
| 107 | + |
0 commit comments