-
Notifications
You must be signed in to change notification settings - Fork 2
/
ImpedanceFM.mod
138 lines (105 loc) · 3.76 KB
/
ImpedanceFM.mod
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
TITLE Frequency-dependent impedance
COMMENT
----------------------------------------------------------------------
This mod files calculates the impedance of the extracellular medium
for the whole frequency range.
There is no parameter to pass to the MOD file; but the procedure
"calc_impedances" is callable from HOC. The parameters of this
procedure are:
- fmax = max frequency at which the impedance must be calculated
- df = frequency step to calculate impedances
- rext = distance between the source and the electrode
- rmax = max distance to integrate
- dr = integration step for distance
- R = diameter of the current source
- sigma1 = extracellular conductivity close to the source (high)
(normalized value - normally equal to 1)
- sigma2 = "mean" extracellular conductivity far away (low)
(normalized value, fraction of the conductivity at the source)
- lambda = space constant of the exponential decay of conductivity
- epsilon = permittivity (normalized)
- sigmaR = absolute value of conductivity in S/um
(all distances are in um)
The resulting impedances Z are written in the 2 vector vec1 and
vec2, with vec1=real part of Z, vec2=imaginary part of Z. These
impedances constitute the "filter" of the extracellular space in
this model.
See details in:
Bedard C, Kroger H & Destexhe A. Modeling extracellular field
potentials and the frequency-filtering properties of extracellular
space. Biophysical Journal 86: 1829-1842, 2004.
A. Destexhe, CNRS
destexhe@iaf.cnrs-gif.fr
see http://cns.iaf.cnrs-gif.fr
----------------------------------------------------------------------
ENDCOMMENT
NEURON {
POINT_PROCESS ImpedanceFM
POINTER vec1
POINTER vec2
}
ASSIGNED {
vec1
vec2
}
VERBATIM
#include <stdlib.h>
// calculate impedance for the whole range of frequencies
void calc_impedances(double Zr[], double Zi[], double fmax, double df, double rext, double rmax, double dr, double R, double sigma1, double sigma2, double lambda,double epsilon, double sigmaR)
// vector Z is impedance, Z[0]=real part, Z[1]=imaginary part
{
double epsR,sigR,w,w2,sig,eps,den,ReZ,ImZ,r,f;
float *sigmatab;
double PI = 3.1415927;
int j,k,siz;
// printf("%s\n%g %g %g %g %g %g %g %g %g %g %g\n",\
// "fmax,df,rext,rmax,dr,R,sigma1,sigma2,lambda,epsilon,sigmaR = ",\
// fmax,df,rext,rmax,dr,R,sigma1,sigma2,lambda,epsilon,sigmaR);
// tabulate all values of sigma in a table "sigmatab",
// which avoids calculating them several times
siz = fmax/df + 1;
sigmatab = (float *) malloc(sizeof(float) * siz);
k = 0;
for(r=rext; r<=rmax; r=r+dr) {
sigmatab[k] = sigma2 + (sigma1-sigma2) * exp(-(r-R)/lambda);
k++;
}
// calculate the impedances for each frequency
sigR = sigma1;
epsR = epsilon;
j=0;
for(f=0; f<=fmax; f=f+df) { // loop on frequencies
w = 2*PI*f;
w2 = w*w;
ReZ=0;
ImZ=0;
k=0;
for(r=rext; r<=rmax; r=r+dr) { // compute integral
/* sig = sigmaF(r,R,sigma1,sigma2,lambda); */
sig = sigmatab[k]; // tabulated sigma
eps = epsilon;
den = r*r * (sig*sig + w2 * eps*eps);
ReZ = ReZ + (sig*sigR + w2*eps*epsR) / den;
ImZ = ImZ + (sig*epsR - sigR*eps) / den;
k++;
}
Zr[j] = dr/(4*PI*sigmaR) * ReZ; // impedance (UNITS: Ohm)
Zi[j] = w * dr/(4*PI*sigmaR) * ImZ;
j++;
/* printf("last sigma = %g\n",sig); */
}
free(sigmatab);
}
ENDVERBATIM
:
: procedure callable from hoc, and which calls the mutual information
: algorithm. The address of the pointed vecors are passed to the
: C procedure above.
:
PROCEDURE impedance(fmax,df,rext,rmax,dr,R,sigma1,sigma2,lambda,epsilon,sigmaR) {
VERBATIM
/* printf("argument passed in procedure : f = %g\n",_lf); */
calc_impedances(&vec1,&vec2,_lfmax,_ldf,_lrext,_lrmax,_ldr,_lR,_lsigma1,\
_lsigma2,_llambda,_lepsilon,_lsigmaR);
ENDVERBATIM
}