001 package cnslab.cnsnetwork; 002 003 import cnslab.cnsmath.*; 004 import java.io.Serializable; 005 006 import edu.jhu.mb.ernst.model.Synapse; 007 import edu.jhu.mb.ernst.util.slot.Slot; 008 009 /*********************************************************************** 010 * Background sensory neuron, it generate heterogeneous Poisson spike 011 * trains. The lamda is Decay from para.HighFre to para.LowFre with 012 * inverse decay constant para.timeCon 013 * 014 * @version 015 * $Date: 2012-08-04 13:43:22 -0500 (Sat, 04 Aug 2012) $ 016 * $Rev: 104 $ 017 * $Author: croft $ 018 * @author 019 * Yi Dong 020 * @author 021 * David Wallace Croft 022 ***********************************************************************/ 023 public final class BKPoissonNeuron 024 implements Neuron, Serializable 025 //////////////////////////////////////////////////////////////////////// 026 //////////////////////////////////////////////////////////////////////// 027 { 028 029 private static final long serialVersionUID = 0L; 030 031 private boolean record; 032 033 // Neuron axons 034 // public Axon axon; 035 036 /** the seed for this neuron */ 037 private Seed idum; 038 039 /** Target Host id, binary format */ 040 public long tHost; 041 042 public double time = 0.0; 043 044 /** Neuron parameter class */ 045 BKPoissonNeuronPara para; 046 047 //////////////////////////////////////////////////////////////////////// 048 // constructor methods 049 //////////////////////////////////////////////////////////////////////// 050 051 public BKPoissonNeuron ( 052 final Seed idum, 053 final BKPoissonNeuronPara para ) 054 //////////////////////////////////////////////////////////////////////// 055 { 056 // this.idum = new Seed(-idum.seed); 057 058 this.idum = idum; 059 060 this.para = para; 061 } 062 063 //////////////////////////////////////////////////////////////////////// 064 // interface Neuron accessor methods 065 //////////////////////////////////////////////////////////////////////// 066 067/* 068 public Axon getAxon ( ) 069 //////////////////////////////////////////////////////////////////////// 070 { 071 return axon; 072 } 073*/ 074 075 @Override 076 public double [ ] getCurr ( final double currTime ) 077 //////////////////////////////////////////////////////////////////////// 078 { 079 throw new RuntimeException ( "no curr for sensory neuron" ); 080 } 081 082 @Override 083 public double getMemV ( final double currTime ) 084 //////////////////////////////////////////////////////////////////////// 085 { 086 throw new RuntimeException ( "no memV for sensory neuron" ); 087 } 088 089 @Override 090 public boolean getRecord ( ) 091 //////////////////////////////////////////////////////////////////////// 092 { 093 return record; 094 } 095 096 @Override 097 public long getTHost ( ) 098 //////////////////////////////////////////////////////////////////////// 099 { 100 return tHost; 101 } 102 103 @Override 104 public double getTimeOfNextFire ( ) 105 //////////////////////////////////////////////////////////////////////// 106 { 107 return -1; 108 } 109 110 @Override 111 public boolean isSensory ( ) 112 //////////////////////////////////////////////////////////////////////// 113 { 114 return true; 115 } 116 117 @Override 118 public boolean realFire ( ) 119 //////////////////////////////////////////////////////////////////////// 120 { 121 return true; 122 } 123 124 //////////////////////////////////////////////////////////////////////// 125 // interface Neuron mutator methods 126 //////////////////////////////////////////////////////////////////////// 127 128 @Override 129 public void setRecord ( final boolean record ) 130 //////////////////////////////////////////////////////////////////////// 131 { 132 this.record = record; 133 } 134 135 @Override 136 public void setTHost ( final long id ) 137 //////////////////////////////////////////////////////////////////////// 138 { 139 this.tHost = id; 140 } 141 142 @Override 143 public void setTimeOfNextFire ( final double arg0 ) 144 //////////////////////////////////////////////////////////////////////// 145 { 146 this.time = arg0; 147 } 148 149 //////////////////////////////////////////////////////////////////////// 150 // interface Neuron lifecycle methods 151 //////////////////////////////////////////////////////////////////////// 152 153 @Override 154 public void init ( 155 final int expid, 156 final int trialid, 157 final Seed seed, 158 final Network network, 159 final int id ) 160 //////////////////////////////////////////////////////////////////////// 161 { 162 this.idum = seed; 163 164 this.time = updateFire ( ); 165 166 final Slot<FireEvent> fireEventSlot = network.getFireEventSlot ( ); 167 168 if ( network.getClass ( ).getName ( ).equals ( 169 "cnslab.cnsnetwork.ANetwork")) 170 { 171 fireEventSlot.offer ( 172 new AFireEvent ( 173 id, 174 this.time, 175 network.info.idIndex, 176 ( ( ANetwork ) network ).aData.getId ( 177 ( ANetwork ) network ) ) ); 178 } 179 else if ( network.getClass ( ).getName ( ).equals ( 180 "cnslab.cnsnetwork.Network" ) ) 181 { 182 fireEventSlot.offer ( 183 new FireEvent ( id, this.time ) ); 184 } 185 else 186 { 187 throw new RuntimeException ( "Other Network Class doesn't exist" ); 188 } 189 190 //throw new RuntimeException( 191 //"no need of initlization for sensory neuron"); 192 } 193 194 @Override 195 public double updateFire ( ) 196 //////////////////////////////////////////////////////////////////////// 197 { 198 double next = ( -Math.log ( Cnsran.ran2 ( idum ) ) / para.HighFre ); 199 200 while ( Cnsran.ran2 ( idum ) > ( 1.0 - para.LowFre / para.HighFre ) 201 * Math.exp ( -para.timeCon * ( time + next ) ) 202 + para.LowFre / para.HighFre ) 203 { 204 next += ( -Math.log ( Cnsran.ran2 ( idum ) ) / para.HighFre ); 205 } 206 207 return next; 208 } 209 210 @Override 211 public double updateInput ( 212 final double dummyTime, 213 final Synapse input ) 214 //////////////////////////////////////////////////////////////////////// 215 { 216 throw new RuntimeException ( "sensory neuron won't receive inputs" ); 217 } 218 219 //////////////////////////////////////////////////////////////////////// 220 //////////////////////////////////////////////////////////////////////// 221 222 @Override 223 public String toString ( ) 224 //////////////////////////////////////////////////////////////////////// 225 { 226 final String tmp = "Sensory Poisson Neuron\n"; 227 228 // tmp = tmp + axon; 229 230 return tmp; 231 } 232 233 //////////////////////////////////////////////////////////////////////// 234 //////////////////////////////////////////////////////////////////////// 235 }