![]() |
|
Home | |
Manual
|
Simulating blocking channels: proceduresSuppose we would like to simulate the effects of blocking sodium channels in the soma. We could simply type: soma gnabar_hh = 0 to effectively block the sodium channels. To unblock the channels, we could type: soma gnabar_hh = 0.25 However, it would be nice if we could say something like "block sodium" or "unblock sodium". Procedures allow us to do this. A procedure is a block of code that we will probably want to use more than once. The syntax for defining a procedure is: proc procedure_name() { Once we have defined a procedure, we can execute it using procedure_name(). For the example of blocking sodium channels, we can define a procedure called block_sodium() like this: proc block_sodium() { soma gnabar_hh = 0 } Then we can use block_sodium() to block the sodium channels. Check that this works by rerunning the simulation after blocking sodium and looking at the same graphs as in the previous section. Similarly, we can define unblock_sodium(): proc unblock_sodium() { soma gnabar_hh = 0.25 } Suppose we would like to see the effect of a partial block on sodium. (For example, TTX blocks sodium channels to varying degrees of their normal strength.) Giving arguments to procedures is a convenient way to change the level of blocking. To do this we modify block_sodium() as follows: proc block_sodium() { soma gnabar_hh = $1 * 0.25 } The $1 refers to the first argument of the procedure. We pass argument to the the procedure as follows: block_sodium(0.15) This will block the sodium channels to 15% of their normal value. We can pass more than one argument to the procedure by using $2, $3 etc. (i.e. $1 is the first parameter, $2 is the second if there is one, $3 the third, if there is one, etc.). For example: proc block_sodium_potassium() { soma gnabar_hh = $1 * 0.25 soma gkbar_hh = $2 * 0.036 } will block sodium potassium channels to varying degrees when called with block_sodium_potassium(0.15, 0.25) We can make long procedures clearer by assigning $1 etc. to meaningful variable names at the start of the procedure. For example: proc block_sodium() { block_fraction = $1 soma gnabar_hh = block_fraction * 0.25 } is clearer than the previous version. However, the disadvantage with this is that the variable block_fraction is left hanging around after we've finished executing the procedure. This is messy and takes up memory. Instead we can use the local statement so that the variable block_fraction as used in the procedure is only defined and available in this procedure: proc block_sodium() { local block_fraction block_fraction = $1 soma gnabar_hh = block_fraction * 0.25 } It is good programming practice to use local variables |
AcknowledgementsLast modified on 10/29/04 by based on tutorial written by |