001    package cnslab.cnsnetwork;
002    
003    import java.util.*;
004    /***********************************************************************
005    * VSICLIFNeuronV2 neuron parameters. 
006    * 
007    * @version
008    *   $Date: 2012-08-04 13:43:22 -0500 (Sat, 04 Aug 2012) $
009    *   $Rev: 104 $
010    *   $Author: croft $
011    * @author
012    *   Yi Dong
013    * @author
014    *   David Wallace Croft
015    * @author
016    *   Jeremy Cohen
017    ***********************************************************************/
018    public final class  VSICLIFNeuronParaV2
019      implements Para
020    ////////////////////////////////////////////////////////////////////////
021    ////////////////////////////////////////////////////////////////////////
022    {
023
024    /** constant for membrane voltage */
025    public double CON_v;
026    
027    /** constant for membrane voltage - threshold */
028    public double CON;
029
030    /** capacitance of the neuron farad */
031    public double CAP = 3E-11;
032    
033    /** leak conductance siemens */
034    public double GL = 1.5E-9;
035    
036    @Deprecated
037    /** inverse of the time constant */
038    public int TIMECON = (int)(GL/CAP); 
039
040    /** reset potential V */
041    public double VRESET = -0.07;
042
043    /** resting potential V */
044    public double VREST = -0.07;  
045
046    /** threshold potential V (theta infinity in the paper) */
047    public double THRESHOLD = -0.05;
048    
049    /** refractory current */
050    public double REFCURR = 0E-10;
051
052    /** Change of threshold when neuron fires */
053    public double THRESHOLDADD=0.0;
054    
055    public double RRESET=-.06;
056    
057    /** Adaptation see Mihalas, Niebur 2009 */
058    public double A = 0.0;
059
060    public double K;
061    
062    /** Adaptation see Mihalas, Niebur 2009 */
063    public double B=10;
064
065    /** Must put 0, NG-term, NB-term, followed by NJs in same order as curr
066    with highest exponent last! */
067    public int[] expts;
068    
069    public int[] orderOfExpts;
070
071    /** the array of  decays for receptors */
072    // the decay for excitation 5 ms
073    public double [] DECAY = {1/0.005,1/0.025};
074    
075    /** the array of addition of spike induced current */
076    public double [] IADD= {0,0};
077    
078    /** the array of multiplication of spike induced current */
079    public double[] IRATIO= {1.0,1.0};
080    
081    /** the array of initial spike induced current */
082    public double [] ini_curr = {0.0,0.0};
083
084    /** external constant current */
085    public double IEXT = 0;
086
087    /** some constants to boost up the computation */
088    public double [] GLCAPDECAY;
089    
090    /** some constants to boost up the computation */
091    public double [] BCAPDECAY;
092    
093    /** some constants to boost up the computation */
094    public double [] ABDECAY;
095    
096    /** some constants to boost up the computation */
097    public double ABGLCAP;
098
099    /** all state variables' decays */
100    public double [] allDecays;
101
102    /** absolute refractory period */
103    public double ABSREF = 0.002;
104
105    @Deprecated
106    /** minimum rising time for neuron to fire */
107    public double MINRISETIME = 1e-4;
108
109    /** initial membrane voltage */
110    public double ini_mem = -0.07;
111    
112    /** initial membrane voltage jitter, uniformly distributed. */
113    public double ini_memVar = 0.005;
114    
115    /** initial membrane voltage variance */
116    public double ini_threshold = -0.05;
117
118    /** weight of strength of LTD */
119    public double Alpha_LTD=0.01;
120    
121    /** weight of strength of LTP (e.g. best timed spike doublet changes
122    the synapse by 1%) */
123    public double Alpha_LTP=0.01;
124    
125    /** LTD inverse time constant */
126    public double K_LTD=1/0.020;
127    
128    /** LTP inverse time constant */
129    public double K_LTP=1/0.005;
130
131    ////////////////////////////////////////////////////////////////////////
132    ////////////////////////////////////////////////////////////////////////
133    
134    @Override
135    public String  getModel ( )
136    ////////////////////////////////////////////////////////////////////////
137    {
138      return "VSICLIFNeuronV2";
139    }
140
141    /***********************************************************************
142    * pre-processing parameters
143    ***********************************************************************/
144    @Deprecated
145    public void  assignExp ( )
146    ////////////////////////////////////////////////////////////////////////
147    {
148      TIMECON =  (int)(GL/CAP);
149      
150      int currLen = DECAY.length;
151      
152      if ( currLen != IADD.length
153        || currLen != IRATIO.length
154        || currLen != ini_curr.length )
155      {
156        throw new RuntimeException (
157          "current length doesn't match "
158          + "decay.length:"     + DECAY.length
159          + " iadd.length:"     + IADD.length
160          + " iratio.length:"   + IRATIO.length
161          + " ini_curr.length:" + ini_curr.length );
162      }
163      
164      expts = new int[currLen+3];
165      
166      orderOfExpts = new int[currLen+3];
167      
168      int [] gcdArray = new int[currLen+2];
169      
170      gcdArray[0]=TIMECON;
171      
172      gcdArray[1]=(int)B;
173
174      for(int i=2; i < gcdArray.length ; i++)
175      {
176        gcdArray[i] = (int)DECAY[i-2];
177      }
178
179      //computes the greatest common divisor
180      
181      K = FunUtil.gcd(gcdArray);
182
183      expts[0]=0;
184      
185      expts[1]=TIMECON/(int)K;
186      
187      expts[2]=((int)B)/(int)K;
188      
189      for(int i=3; i < expts.length; i++)
190      {
191        expts[i] =  ((int)DECAY[i-3])/(int)K;
192      }
193      
194
195      System.arraycopy(expts, 0, orderOfExpts, 0, orderOfExpts.length);
196      
197      Arrays.sort(orderOfExpts);
198
199      GLCAPDECAY = new double [currLen];
200      
201      for(int a=0; a <currLen; a++)
202      {
203        GLCAPDECAY[a]=(GL-CAP*DECAY[a]);
204      }
205
206      BCAPDECAY = new double [currLen];
207      
208      for(int a=0; a <currLen; a++)
209      {
210        BCAPDECAY[a]=(B*CAP-CAP*DECAY[a]);
211      }
212      
213      ABGLCAP = A/(B-GL/CAP);
214
215      ABDECAY = new double [currLen];
216      
217      for(int a=0; a <currLen; a++)
218      {
219        ABDECAY[a]= A/(B-DECAY[a]);
220      }
221    }
222
223    /**
224     * pre-processing parameters
225     */
226    public void  calConstants ( )
227    ////////////////////////////////////////////////////////////////////////
228    {
229      TIMECON =  (int)(GL/CAP);
230      
231      int currLen = DECAY.length;
232      
233      if ( currLen != IADD.length
234        || currLen != IRATIO.length
235        || currLen != ini_curr.length )
236      {
237        throw new RuntimeException (
238          "current length doesn't match "
239          + "decay.length:"     + DECAY.length
240          + " iadd.length:"     + IADD.length
241          + " iratio.length:"   + IRATIO.length
242          + " ini_curr.length:" + ini_curr.length );
243      }
244
245      GLCAPDECAY = new double [currLen];
246      
247      for(int a=0; a <currLen; a++)
248      {
249        GLCAPDECAY[a]=(GL-CAP*DECAY[a]);
250      }
251
252      BCAPDECAY = new double [currLen];
253      
254      for(int a=0; a <currLen; a++)
255      {
256        BCAPDECAY[a]=(B*CAP-CAP*DECAY[a]);
257      }
258      
259      ABGLCAP = A/(B-GL/CAP);
260
261      ABDECAY = new double [currLen];
262      
263      for(int a=0; a <currLen; a++)
264      {
265        ABDECAY[a]= A/(B-DECAY[a]);
266      }
267
268      allDecays = new double[currLen+2];
269      
270      allDecays[0]=GL/CAP;
271      
272      allDecays[1]=B;
273      
274      for(int i=2; i < allDecays.length ; i++)
275      {
276        allDecays[i] = DECAY[i-2];
277      }
278    }
279
280    ////////////////////////////////////////////////////////////////////////
281    ////////////////////////////////////////////////////////////////////////
282    }