00001 #include "GABA_BResponse.h" 00002 00003 GABA_BResponse::GABA_BResponse() 00004 { 00005 k1 = 9.0*10e4; // [M^-1 s^-1] 00006 k2 = 1.2; // [s^-1] 00007 k3 = 180.0; // [s^-1] 00008 k4 = 34.0; // [s^-1] 00009 00010 kd = 100.0; 00011 dead_time = 1e-3; 00012 Cdur = 0.3e-3; 00013 Cmax = 0.5; 00014 n = 4; 00015 00016 g_max = 1.0; 00017 } 00018 00019 int GABA_BResponse::reset( double dt ) 00020 { 00021 r=0.0; 00022 s=0.0; 00023 00024 time_count = -dead_time-dt; 00025 00026 double A=k1*Cmax; 00027 double B_on=k1*Cmax+k2; 00028 double B_off=k2; 00029 00030 C1_on=exp(-B_on*dt); 00031 C1_off=exp(-B_off*dt); 00032 C2_on=A/B_on*(1-C1_on); 00033 00034 C3=exp(-k4*dt); 00035 C4=1/k4*(1-C3); 00036 00037 return FiniteSpikeResponse::reset(dt); 00038 } 00039 00040 00041 int GABA_BResponse::advance(AdvanceInfo const &ai) 00042 { 00043 time_count -= ai.dt.in_sec(); 00044 00045 if(time_count > 0.0) 00046 r = r*C1_on + C2_on; 00047 else 00048 r = r*C1_off; 00049 00050 s = s*C3 + k3*r*C4; 00051 00052 psr = g_max / ( 1.0 + kd / pow(s, n) ); 00053 00054 return advanceReturn(); 00055 } 00056 00057 int GABA_BResponse::spikeHit( spikeport_t port, SpikeEvent const& spike ) 00058 { 00059 if( port == 0 ) { 00060 if(time_count < -dead_time) { 00061 time_count = Cdur; 00062 // g_max=spike.weight; 00063 } 00064 else { 00065 cerr << "spike missed" << endl; 00066 } 00067 } 00068 00069 return spikeHitReturn( AdvanceInfo( spike.dt ) ); 00070 } 00071 00072 int GABA_BResponse::psrLength(double dt) const 00073 { 00074 // TODO: replace this simple approximation 00075 const double tau = 0.200; 00076 return (int)( (double)PSR_MULTIPLE_TAU * tau / dt + 0.5 ); 00077 } 00078 00079 00080 00081 00082 00083 00084 00085 00086 00087 00089 // Nest style 00091 00092 00093 GABA_BResponseNest::GABA_BResponseNest() 00094 { 00095 k1 = 9.0*10e4; // [M^-1 s^-1] 00096 k2 = 1.2; // [s^-1] 00097 k3 = 180.0; // [s^-1] 00098 k4 = 34.0; // [s^-1] 00099 00100 kd = 100.0; 00101 pulse = 1.105*10e-3; // [s] 00102 T = 1e-3; // [M] 00103 n = 4; 00104 } 00105 00106 int GABA_BResponseNest::reset( double dt ) 00107 { 00108 r=0.0; 00109 s=0.0; 00110 00111 // The exact integration matrix 00112 exp_A00 = exp(-dt*k2); 00113 exp_A10 = (exp(-dt*k2)-exp(-dt*k4)) / (k4 - k2); 00114 exp_A11 = exp(-dt*k4); 00115 00116 00117 double tau_r_add = 1 / (k1*T + k2); 00118 00119 r_inf = k1* k3* T* tau_r_add; 00120 exp_r_add = 1 - exp(-pulse / tau_r_add); 00121 00122 return FiniteSpikeResponse::reset(dt); 00123 } 00124 00125 int GABA_BResponseNest::advance(AdvanceInfo const &ai) 00126 { 00127 // The exact integration step 00128 s = exp_A10 * r + exp_A11 * s; 00129 r = exp_A00 * r; 00130 00131 psr = g_max / ( 1.0 + kd / pow(s, n) ); 00132 00133 return advanceReturn(); 00134 } 00135 00136 int GABA_BResponseNest::spikeHit( spikeport_t port, SpikeEvent const& spike ) 00137 { 00138 if( port == 0 ) { 00139 r += (r_inf - r)*exp_r_add; 00140 // g_max=spike.weight; 00141 } 00142 00143 return spikeHitReturn( AdvanceInfo( spike.dt ) ); 00144 } 00145 00146 00147 int GABA_BResponseNest::psrLength(double dt) const 00148 { 00149 // TODO: replace this simple approximation 00150 const double tau = 0.200; 00151 return (int)( (double)PSR_MULTIPLE_TAU * tau / dt + 0.5 ); 00152 } 00153 00154 /* 00155 // nest type 00156 00157 k1 = 90.0, // M/ms 00158 k2 = 0.0012, // 1/ms 00159 k3 = 0.18, // 1/ms 00160 k4 = 0.034, // 1/ms 00161 kd = 100, 00162 T = 1e-3, // M 00163 pulse = 1.105, //ms The pulse length (adjusted) 00164 00165 virtual int reset( double dt ) 00166 { 00167 r=0.0; 00168 s=0.0; 00169 00170 double _dt = dt*10e3; 00171 00172 // The exact integration matrix 00173 exp_A00 = exp(-_dt*k2); 00174 exp_A10 = (exp(-_dt*k2)-exp(-_dt*k4)) / (k4 - k2); 00175 exp_A11 = exp(-_dt*k4); 00176 00177 double tau_r_add = 1 / (k1*T + k2); 00178 00179 r_inf = k1* k3* T* tau_r_add; 00180 exp_r_add = 1 - exp(-pulse / tau_r_add); 00181 00182 return FiniteSpikeResponse::reset(dt); 00183 } 00184 00185 */