001    package cnslab.cnsnetwork;
002    
003    /***********************************************************************
004    * MiNiNeuron neuron parameters. 
005    * 
006    * @version
007    *   $Date: 2012-08-04 13:43:22 -0500 (Sat, 04 Aug 2012) $
008    *   $Rev: 104 $
009    *   $Author: croft $
010    * @author
011    *   Yi Dong
012    * @author
013    *   David Wallace Croft, M.Sc.
014    * @author
015    *   Jeremy Cohen
016    ***********************************************************************/
017    public final class  MiNiNeuronPara
018      implements Para
019    ////////////////////////////////////////////////////////////////////////
020    ////////////////////////////////////////////////////////////////////////
021    {
022    /** capacitance of the neuron farad */
023    public double CAP = 3E-11;
024    
025    /** leak conductance siemens */
026    public double GL = 1.5E-9;
027    
028    /** reset potential V */
029    public double VRESET = -0.07;
030
031    /** resting potential V */
032    public double VREST = -0.07;  
033
034    /** threshold potential V (theta infinity in the paper) */
035    public double THRESHOLD = -0.05;
036    
037    /** refractory current */
038    public double REFCURR = 0E-10;
039
040    /** Change of threshold when neuron fires */
041    public double THRESHOLDADD=0.0;
042    
043    public double RRESET=-.06;
044    
045    /** Adaptation see Mihalas, Niebur 2009 */
046    public double A = 0.0;
047    
048    /** Adaptation see Mihalas, Niebur 2009 */
049    public double B=10;
050    
051    /** Decay rates for synaptic currents (inverse time constant) */
052    public double [] DECAY_SYNAPSE = {1/0.005, 1/0.025};
053
054    /** Decay rates for spike-induced currents (inverse time constant) */
055    // the decay for excitation 5 ms
056    public double [] DECAY_SPIKE = {1/0.005,1/0.025};
057    
058    /** Additive resets for spike-induced currents */
059    public double [] SPIKE_ADD= {0,0};
060    
061    /** Multiplicative resets for spike-induced currents */
062    public double[] SPIKE_RATIO= {1.0,1.0};
063    
064    /** Initial spike induced currents */
065    public double [] ini_spike_curr = {0.0,0.0};
066
067    /** external constant current */
068    public double IEXT = 0;
069
070    /** absolute refractory period */
071    public double ABSREF = 0.002;
072
073    /** initial membrane voltage */
074    public double ini_mem = -0.07;
075    
076    /** initial membrane voltage jitter, uniformly distributed. */
077    public double ini_memVar = 0.005;
078    
079    /** initial voltage threshold */
080    public double ini_threshold = -0.05;
081    
082    // STDP constants.
083
084    /** weight of strength of LTD */
085    public double Alpha_LTD = 0.01;
086    
087    /** weight of strength of LTP (e.g. best timed spike doublet changes
088    the synapse by 1%) */
089    public double Alpha_LTP = 0.01;
090    
091    /** LTD inverse time constant */
092    public double K_LTD = 1/0.020;
093    
094    /** LTP inverse time constant */
095    public double K_LTP = 1/0.005;
096    
097    // Calculated constants.
098   
099    /** constant for membrane voltage */
100    public double MEMBRANE_VOLTAGE_BASE;
101    
102    /** constant for threshold gap (membrane voltage - threshold)*/
103    public double THRESHOLD_DIFF_BASE;
104    
105    /** the base of the NB term */
106    public double NB_BASE;
107    
108    /** the base of the NG term */
109    public double NG_BASE;
110    
111    /** all state variables' decays */
112    public double [ ] [ ] allDecays;
113    
114    // Conversion factors
115    
116  /*
117   * The state of a Mihalas-Niebur neuron is formally defined by a voltage, a
118   * voltage threshold, and an arbitrary number of both spike-induced and
119   * synaptic currents. However, the MNNeuron class does not keep track of those
120   * "model variables" directly. Instead, the state of an MNNeuron is stored as
121   * a set of "state variables": one NB term, one NG term, and an arbitrary
122   * number of NJ_SPIKE and NJ_SYNAPSE terms. This novel storage scheme makes it
123   * possible to compute the thresholdDiff function very quickly, but it also
124   * makes it difficult to access or change the values of the model variables.
125   * The program must use the conversion factors below to convert between model
126   * variables and state variables.
127   * 
128   * Due to the definitions of the state variables, the following guidelines
129   * apply when changing or accessing the value of a model variable:
130   * 
131   * To change a current, the program must change the NG term, the NB term, and
132   * the corresponding NJ term.
133   * 
134   * To change the voltage, the program must change the NG term and the NB term.
135   * 
136   * To change the threshold, the program must change the NB term.
137   * 
138   * To access a current, the program must access the corresponding NJ term.
139   * 
140   * To access the voltage, the program must access the NG term and all NJ
141   * terms. (This is done in membraneVoltage() ).
142   * 
143   * (The program never needs to access the threshold.)
144   * 
145   * For example, to add "x" (in amps) to current 0, the program would need to
146   * change the state variables like this: nj_term_0 += CURRENT_TO_NJ[0] * x;
147   * ng_term += CURRENT_TO_NG * x; nb_term += CURRENT_TO_NB * x;
148   * 
149   * The conversion factors are all derived Equation 3.2 and Equation 3.5.
150   */
151
152    /**
153     * Conversion factor between a spike current and a spike NJ term. Used when
154     * adding a spike current to a spike NJ term and when accessing a spike
155     * current from a spike NJ term.
156     */
157    public double [ ] SPIKE_CURRENT_TO_SPIKE_NJ;
158    
159    /**
160     * Conversion factor between a spike current and the NG term.  Used when changing
161     * a spike current in the NG term.
162     */
163    public double [ ] SPIKE_CURRENT_TO_NG;
164    
165    /**
166     * Conversion factor between a spike current and the NB term.  Used when 
167     * changing a spike current in the NB term.
168     */
169    public double [ ] SPIKE_CURRENT_TO_NB;
170    
171    /**
172     * Conversion factor between the voltage and a spike NJ term.  Used when 
173     * accessing the voltage from a spike NJ term.
174     */
175    public double [ ] VOLTAGE_TO_SPIKE_NJ;
176    
177    /**
178     * Conversion factor between a synapse current and a synapse NJ term. Used when
179     * adding a synapse current to a synapse NJ term and when accessing a synapse
180     * current from a synapse NJ term.
181     */
182    public double [ ] SYNAPSE_CURRENT_TO_SYNAPSE_NJ;
183    
184    /**
185     * Conversion factor between a synapse current and the NG term.  Used when changing
186     * a synapse current in the NG term.
187     */
188    public double [ ] SYNAPSE_CURRENT_TO_NG;
189    
190    /**
191     * Conversion factor between a synapse current and the NB term.  Used when 
192     * changing a synapse current in the NB term.
193     */
194    public double [ ] SYNAPSE_CURRENT_TO_NB;
195    
196    /**
197     * Conversion factor between the voltage and a synapse NJ term.  Used when 
198     * accessing the voltage from a synapse NJ term.
199     */
200    public double [ ] VOLTAGE_TO_SYNAPSE_NJ;
201    
202    /** 
203     * Conversion factor between the voltage and the NG term.  Used when
204     * changing voltage in the NG term and when accessing the voltage from the
205     * NG term.
206     */
207    public double VOLTAGE_TO_NG;
208    
209    /** 
210     * Conversion factor between the voltage and the NB term.  Used when
211     * changing the voltage in the NB term.
212     */
213    public double VOLTAGE_TO_NB;
214    
215    /**
216     * Conversion factor between the threshold and the NB term.  Used when
217     * changing the threshold in the NG term. 
218     */
219    public double THRESHOLD_TO_NB;
220
221    ////////////////////////////////////////////////////////////////////////
222    ////////////////////////////////////////////////////////////////////////
223    
224    @Override
225    public String  getModel ( )
226    ////////////////////////////////////////////////////////////////////////
227    {
228      return "MiNiNeuron";
229    }
230
231 
232    /**
233     * Pre-calculate constants.
234     */
235    public void  calConstants ( )
236    ////////////////////////////////////////////////////////////////////////
237    {           
238      if ( DECAY_SPIKE.length != SPIKE_ADD.length
239        || DECAY_SPIKE.length != SPIKE_RATIO.length
240        || DECAY_SPIKE.length != ini_spike_curr.length )
241      {
242        throw new RuntimeException (
243          "number of spike-induced currents doesn't match "
244          + "decay.length:"     + DECAY_SPIKE.length
245          + " iadd.length:"     + SPIKE_ADD.length
246          + " iratio.length:"   + SPIKE_RATIO.length
247          + " ini_curr.length:" + ini_spike_curr.length );
248      } 
249      
250      SPIKE_CURRENT_TO_SPIKE_NJ = new double [ DECAY_SPIKE.length ];
251      
252      for (int a = 0; a < DECAY_SPIKE.length; a ++)
253      {
254        SPIKE_CURRENT_TO_SPIKE_NJ [ a ] = (1 - ( A / ( B - DECAY_SPIKE [ a ]
255                ) ) )  / ( GL- CAP * DECAY_SPIKE [ a ] );
256      }
257      
258      SPIKE_CURRENT_TO_NG = new double [ DECAY_SPIKE.length ];
259      
260      for (int a = 0; a < DECAY_SPIKE.length; a ++)
261      {
262        SPIKE_CURRENT_TO_NG [ a ] = - (1 - ( A / (B - GL / CAP ) ) ) /
263                ( GL- CAP * DECAY_SPIKE [ a ] );
264      }
265      
266      SPIKE_CURRENT_TO_NB = new double [ DECAY_SPIKE.length ];
267      
268      for (int a = 0; a < DECAY_SPIKE.length; a ++)
269      {
270          SPIKE_CURRENT_TO_NB [ a ] = - ( A / (B - GL / CAP ) )  /
271                  (B * CAP - CAP * DECAY_SPIKE [ a ] );
272      }
273      
274      SYNAPSE_CURRENT_TO_SYNAPSE_NJ = new double [ DECAY_SYNAPSE.length ];
275      
276      for (int a = 0; a < DECAY_SYNAPSE.length; a ++)
277      {
278          SYNAPSE_CURRENT_TO_SYNAPSE_NJ [ a ] = (1 - ( A / 
279              ( B - DECAY_SYNAPSE [ a ] ) ) )
280              / ( GL- CAP * DECAY_SYNAPSE [ a ] );
281      }
282      
283      SYNAPSE_CURRENT_TO_NG = new double [ DECAY_SYNAPSE.length ];
284      
285      for (int a = 0; a < DECAY_SYNAPSE.length; a ++)
286      {
287          SYNAPSE_CURRENT_TO_NG [ a ] = - (1 - ( A / (B - GL / CAP ) ) )
288                  / ( GL- CAP * DECAY_SYNAPSE [ a ] );
289      }
290      
291      SYNAPSE_CURRENT_TO_NB = new double [ DECAY_SYNAPSE.length ];
292      
293      for (int a = 0; a < DECAY_SYNAPSE.length; a ++)
294      {
295          SYNAPSE_CURRENT_TO_NB [ a ] = - ( A / (B - GL / CAP ) ) 
296                  / (B * CAP - CAP * DECAY_SYNAPSE [ a ] );
297      }
298      
299      VOLTAGE_TO_SPIKE_NJ = new double [ DECAY_SPIKE.length ];
300      
301      for (int a = 0; a < DECAY_SPIKE.length; a ++)
302      {
303          VOLTAGE_TO_SPIKE_NJ [ a ] = 1 - ( A / ( B - DECAY_SPIKE [ a ] ) );
304      }
305      
306      VOLTAGE_TO_SYNAPSE_NJ = new double [ DECAY_SYNAPSE.length ];
307      
308      for (int a = 0; a < DECAY_SYNAPSE.length; a ++)
309      {
310          VOLTAGE_TO_SYNAPSE_NJ [ a ] = 
311              1 - ( A / ( B - DECAY_SYNAPSE [ a ] ) );
312      }
313      
314      VOLTAGE_TO_NG = 1 - ( A / (B - GL / CAP ) );
315      
316      VOLTAGE_TO_NB = ( A / (B - GL / CAP ) );
317      
318      THRESHOLD_TO_NB = -1;
319      
320      // Set up allDecays.
321      
322      allDecays = new double [ 4 ] [ ];
323      
324      // Decay for NG term.
325      
326      allDecays [ 0 ] = new double [] { GL / CAP  };
327      
328      // Decay for NB term.
329      
330      allDecays [ 1 ] = new double [] { B };
331      
332      // Decay for NJ_SPIKE terms.
333      
334      allDecays [ 2 ] = new double [ DECAY_SPIKE.length ];
335      
336      for ( int i = 0; i < DECAY_SPIKE.length ; i++)
337      {
338        allDecays [ 2 ] [ i ] = DECAY_SPIKE [ i ];
339      }
340      
341      // Decay for NJ_SYNAPSE terms.
342      
343      allDecays [ 3 ] = new double [ DECAY_SYNAPSE.length ];
344      
345      for ( int i = 0; i < DECAY_SYNAPSE.length ; i++)
346      {
347        allDecays [ 3 ] [ i ] = DECAY_SYNAPSE [ i ];
348      }
349      
350      // Compute the base values before state variables are considered.
351      
352      NG_BASE = (1 - ( A / ( B - GL / CAP)))
353              * (- VREST - IEXT / GL);
354      
355      NB_BASE = THRESHOLD + ( A / ( B -  GL / CAP))
356              * (- VREST - IEXT / ( B * CAP ) );
357      
358      MEMBRANE_VOLTAGE_BASE = IEXT / GL;
359      
360      THRESHOLD_DIFF_BASE = VREST - THRESHOLD - (1 - A / B) * (IEXT / GL);
361    }
362
363    ////////////////////////////////////////////////////////////////////////
364    ////////////////////////////////////////////////////////////////////////
365    }