MOOSE - Multiscale Object Oriented Simulation Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
SynChan.cpp
Go to the documentation of this file.
1 /**********************************************************************
2 ** This program is part of 'MOOSE', the
3 ** Messaging Object Oriented Simulation Environment.
4 ** Copyright (C) 2003-2007 Upinder S. Bhalla. and NCBS
5 ** It is made available under the terms of the
6 ** GNU Lesser General Public License version 2.1
7 ** See the file COPYING.LIB for the full notice.
8 **********************************************************************/
9 
10 #include "header.h"
11 #include "ChanBase.h"
12 #include "ChanCommon.h"
13 #include "SynChan.h"
14 
15 const double& SynE() {
16  static const double SynE = exp(1.0);
17  return SynE;
18 }
19 
21 {
23  // Shared message definitions
25 
27 // Field definitions
29  static ValueFinfo< SynChan, double > tau1( "tau1",
30  "Decay time constant for the synaptic conductance, tau1 >= tau2.",
33  );
34  static ValueFinfo< SynChan, double > tau2( "tau2",
35  "Rise time constant for the synaptic conductance, tau1 >= tau2.",
38  );
39  static ValueFinfo< SynChan, bool > normalizeWeights(
40  "normalizeWeights",
41  "Flag. If true, the overall conductance is normalized by the "
42  "number of individual synapses in this SynChan object.",
45  );
46 
48  // MsgDest definitions
50  static DestFinfo activation( "activation",
51  "Sometimes we want to continuously activate the channel",
53  );
54 
55  static Finfo* SynChanFinfos[] =
56  {
57  &tau1, // Value
58  &tau2, // Value
59  &normalizeWeights, // Value
60  &activation, // Dest
61  };
62 
63  static string doc[] =
64  {
65  "Name", "SynChan",
66  "Author", "Upinder S. Bhalla, 2007, 2014, NCBS",
67  "Description", "SynChan: Synaptic channel incorporating "
68  " weight and delay. Does not handle actual arrival of synaptic "
69  " events, that is done by one of the derived classes of "
70  "SynHandlerBase.\n"
71  "In use, the SynChan sits on the compartment connected to it by "
72  "the **channel** message. One or more of the SynHandler "
73  "objects connects to the SynChan through the **activation** "
74  "message. The SynHandlers each manage multiple synapses, and "
75  "the handlers can be fixed weight or have a learning rule. "
76  };
77 
78  static Dinfo< SynChan > dinfo;
79 
80  static Cinfo SynChanCinfo(
81  "SynChan",
83  SynChanFinfos,
84  sizeof( SynChanFinfos )/sizeof(Finfo *),
85  &dinfo,
86  doc,
87  sizeof( doc )/sizeof( string )
88  );
89 
90  return &SynChanCinfo;
91 }
92 
94 
96  :
97  tau1_( 1.0e-3 ), tau2_( 1.0e-3 ),
98  normalizeWeights_( 0 ),
99  xconst1_(0.0),
100  yconst1_(1.0),
101  xconst2_(1.0),
102  yconst2_(0.0),
103  norm_(1.0),
104  activation_(0.0),
105  X_(0.0),
106  Y_(0.0),
107  dt_( 25.0e-6 )
108 { ; }
109 
111 {;}
112 
114 // Field function definitions
116 //
117 void SynChan::vSetGbar( const Eref& e, double Gbar )
118 {
119  ChanCommon::vSetGbar( e, Gbar );
120  normalizeGbar();
121 }
122 
123 void SynChan::setTau1( double tau1 )
124 {
125  tau1_ = tau1;
126  // Aditya added
127  // required if changing tau1 during a simulation
128  // (eg. Marder pyloric networks).
129  xconst1_ = tau1_ * ( 1.0 - exp( -dt_ / tau1_ ) );
130  xconst2_ = exp( -dt_ / tau1_ );
131  normalizeGbar();
132 }
133 
134 double SynChan::getTau1() const
135 {
136  return tau1_;
137 }
138 
139 void SynChan::setTau2( double tau2 )
140 {
141  tau2_ = tau2;
142  // Aditya added
143  // required if changing tau1 during a simulation
144  // (eg. Marder pyloric networks).
145  if ( doubleEq( tau2_, 0.0 ) ) {
146  yconst1_ = 1.0;
147  yconst2_ = 0.0;
148  } else {
149  yconst1_ = tau2_ * ( 1.0 - exp( -dt_ / tau2_ ) );
150  yconst2_ = exp( -dt_ / tau2_ );
151  }
152  normalizeGbar();
153 
154 }
155 
156 double SynChan::getTau2() const
157 {
158  return tau2_;
159 }
160 
162 {
164 }
165 
167 {
168  return normalizeWeights_;
169 }
170 
172 {
173  if ( doubleEq( tau2_, 0.0 ) ) {
174  // norm_ = 1.0;
176  } else {
177  if ( doubleEq( tau1_, tau2_ ) ) {
179  } else {
180  double tpeak = tau1_ * tau2_ * log( tau1_ / tau2_ ) /
181  ( tau1_ - tau2_ );
182  norm_ = ChanCommon::getGbar() * ( tau1_ - tau2_ ) /
183  ( tau1_ * tau2_ * (
184  exp( -tpeak / tau1_ ) - exp( -tpeak / tau2_ )
185  ));
186  }
187  }
188  /*
189  * Can't handle at this time. Simple but tedious to implement.
190  if ( normalizeWeights_ && getNumSynapses() > 0 )
191  norm_ /= static_cast< double >( getNumSynapses() );
192  */
193 }
194 
196 // Dest function definitions
198 
201 {
202  /*
203  X_ = getModulation() * activation_ * xconst1_ + X_ * xconst2_;
204  Y_ = X_ * yconst1_ + Y_ * yconst2_;
205  activation_ = 0.0;
206  return Y_ * norm_;
207  */
209  Y_ = X_ * yconst1_ + Y_ * yconst2_;
210  activation_ = 0.0;
211  return Y_ * norm_ * getModulation();
212 }
213 
215 {
216  // http://www.genesis-sim.org/GENESIS/Hyperdoc/Manual-26.html#synchan
217  // For a spike event, activation = weight / dt
218  // is sent from SynHandler-s for one dt
219  // For continuous activation in a graded synapse,
220  // send activation for continous dt-s.
221  setGk( e, calcGk() );
222  updateIk();
223  sendProcessMsgs( e, info ); // Sends out messages for channel.
224 }
225 
226 /*
227  * Note that this causes issues if we have variable dt.
228  */
230 {
231  dt_ = info->dt;
232  activation_ = 0.0;
233  ChanBase::setGk( e, 0.0 );
234  ChanBase::setIk( e, 0.0 );
235  X_ = 0.0;
236  Y_ = 0.0;
237  // These below statements are also called when setting tau1 and tau2
238  // (required when changing tau1 and tau2 during a simulation).
239  xconst1_ = tau1_ * ( 1.0 - exp( -dt_ / tau1_ ) );
240  xconst2_ = exp( -dt_ / tau1_ );
241 
242  if ( doubleEq( tau2_, 0.0 ) ) {
243  yconst1_ = 1.0;
244  yconst2_ = 0.0;
245  } else {
246  yconst1_ = tau2_ * ( 1.0 - exp( -dt_ / tau2_ ) );
247  yconst2_ = exp( -dt_ / tau2_ );
248  }
249  normalizeGbar();
250  sendReinitMsgs(e, info);
251 }
252 
253 void SynChan::activation( double val )
254 {
255  activation_ += val;
256 }
void setIk(const Eref &e, double Ic)
Definition: ChanBase.cpp:225
static const Cinfo * initCinfo()
Definition: SynChan.cpp:20
uint32_t value
Definition: moosemodule.h:42
double tau2_
Definition: SynChan.h:75
double Y_
Definition: SynChan.h:84
Definition: Dinfo.h:60
double tau1_
Definition: SynChan.h:74
double yconst1_
Definition: SynChan.h:78
void vSetGbar(const Eref &e, double Gbar)
Definition: SynChan.cpp:117
void updateIk()
Definition: ChanCommon.cpp:119
void setTau2(double tau2)
Definition: SynChan.cpp:139
double getTau1() const
Definition: SynChan.cpp:134
void log(string msg, serverity_level_ type=debug, bool redirectToConsole=true, bool removeTicks=true)
Log to console (and to a log-file)
void activation(double val)
Definition: SynChan.cpp:253
bool getNormalizeWeights() const
Definition: SynChan.cpp:166
void setNormalizeWeights(bool value)
Definition: SynChan.cpp:161
void setGk(const Eref &e, double Gk)
Definition: ChanBase.cpp:216
bool doubleEq(double x, double y)
Definition: doubleEq.cpp:16
double activation_
Definition: SynChan.h:82
void normalizeGbar()
Definition: SynChan.cpp:171
const double & SynE()
Definition: SynChan.cpp:15
SynChan()
Definition: SynChan.cpp:95
int normalizeWeights_
Definition: SynChan.h:76
double dt
Definition: ProcInfo.h:18
void setTau1(double tau1)
Definition: SynChan.cpp:123
double dt_
Definition: SynChan.h:85
Definition: OpFunc.h:27
Definition: Eref.h:26
double getGbar() const
Utility function to acces Gbar.
Definition: ChanCommon.cpp:129
double calcGk()
Update alpha function terms for synaptic channel.
Definition: SynChan.cpp:200
double xconst1_
Definition: SynChan.h:77
double getTau2() const
Definition: SynChan.cpp:156
void sendReinitMsgs(const Eref &e, const ProcPtr info)
Definition: ChanCommon.cpp:111
double yconst2_
Definition: SynChan.h:80
double X_
Definition: SynChan.h:83
double getModulation() const
Definition: ChanCommon.cpp:54
double xconst2_
Definition: SynChan.h:79
void vProcess(const Eref &e, ProcPtr p)
Definition: SynChan.cpp:214
void vReinit(const Eref &e, ProcPtr p)
Definition: SynChan.cpp:229
void vSetGbar(const Eref &e, double Gbar)
Definition: ChanCommon.cpp:34
void sendProcessMsgs(const Eref &e, const ProcPtr info)
Definition: ChanCommon.cpp:100
static const Cinfo * synChanCinfo
Definition: SynChan.cpp:93
Definition: Cinfo.h:18
static const Cinfo * initCinfo()
Specify the Class Info static variable for initialization.
Definition: ChanBase.cpp:36
~SynChan()
Definition: SynChan.cpp:110
double norm_
Definition: SynChan.h:81
Definition: Finfo.h:12