00001 /*!@file Neuro/LeakyIntegrator.H Class declarations for a leaky integrator neuron */ 00002 00003 // //////////////////////////////////////////////////////////////////// // 00004 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2001 by the // 00005 // University of Southern California (USC) and the iLab at USC. // 00006 // See http://iLab.usc.edu for information about this project. // 00007 // //////////////////////////////////////////////////////////////////// // 00008 // Major portions of the iLab Neuromorphic Vision Toolkit are protected // 00009 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency // 00010 // in Visual Environments, and Applications'' by Christof Koch and // 00011 // Laurent Itti, California Institute of Technology, 2001 (patent // 00012 // pending; application number 09/912,225 filed July 23, 2001; see // 00013 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status). // 00014 // //////////////////////////////////////////////////////////////////// // 00015 // This file is part of the iLab Neuromorphic Vision C++ Toolkit. // 00016 // // 00017 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can // 00018 // redistribute it and/or modify it under the terms of the GNU General // 00019 // Public License as published by the Free Software Foundation; either // 00020 // version 2 of the License, or (at your option) any later version. // 00021 // // 00022 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope // 00023 // that it will be useful, but WITHOUT ANY WARRANTY; without even the // 00024 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // 00025 // PURPOSE. See the GNU General Public License for more details. // 00026 // // 00027 // You should have received a copy of the GNU General Public License // 00028 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write // 00029 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, // 00030 // Boston, MA 02111-1307 USA. // 00031 // //////////////////////////////////////////////////////////////////// // 00032 // 00033 // Primary maintainer for this file: Laurent Itti <itti@usc.edu> 00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Neuro/LeakyIntegrator.H $ 00035 // $Id: LeakyIntegrator.H 10729 2009-02-02 03:44:27Z itti $ 00036 // 00037 00038 #ifndef LEAKY_INTEGRATOR_H_DEFINED 00039 #define LEAKY_INTEGRATOR_H_DEFINED 00040 00041 #include "Util/SimTime.H" 00042 00043 // ###################################################################### 00044 //! A leaky integrator neuron, used by standard saliency map (SM) 00045 // ###################################################################### 00046 /*! This is the saliency map neuron used in conjunction with SM which is 00047 a 2D array of LeakyIntegrator. */ 00048 class LeakyIntegrator 00049 { 00050 public: 00051 //! constructor 00052 /*! Constructor with default params 00053 @param timeStep is the integration time step, in s 00054 @param C is the membrane capacitance, in Farads 00055 @param Gleak is the leak conductance, in Siemens 00056 @param GinhDecay decay factor applied to Ginh at every time step */ 00057 inline LeakyIntegrator(const SimTime timeStep = SimTime::SECS(0.0001), 00058 const float C = 5.0E-8F, 00059 const float Gleak = 1.0E-7F, 00060 const float GinhDecay = 0.9999F); 00061 00062 //! set input current (A) 00063 inline void input(const float current); 00064 00065 //! reset membrane potential to given value (in Volts) 00066 inline void resetV(const double val); 00067 00068 //! integrate for up to given time (in s) 00069 inline void integrate(const SimTime& t); 00070 00071 //! get current membrane potential (in V) 00072 inline float getV() const; 00073 00074 //! set inhibitory conductance (S) 00075 inline void setGinh(const float g); 00076 00077 //! add to inhibitory conductance (S) 00078 inline void addGinh(const float g); 00079 00080 //! set the decay factor for Ginh 00081 inline void setGinhDecay(const float decay); 00082 00083 private: 00084 SimTime itsTimeStep;// time step to use for difference equations (in s) 00085 float itsV; // membrane potential in Volts 00086 float itsI; // input current in Amperes 00087 float itsGinh; // inhibitory conductance in Siemens 00088 float itsGinhDecay; // per time step decay factor on Ginh 00089 float itsC; // capacitance in Farads 00090 float itsGleak; // leak conductance in Siemens 00091 SimTime itsT; // time of last integration 00092 }; 00093 00094 // ###################################################################### 00095 // ##### Inline functions for LeakyIntegrator: 00096 // ###################################################################### 00097 00098 inline LeakyIntegrator::LeakyIntegrator(const SimTime timeStep, 00099 const float C, 00100 const float Gleak, 00101 const float GinhDecay) : 00102 itsTimeStep(timeStep), itsV(0.0F), itsI(0.0F), itsGinh(0.0F), 00103 itsGinhDecay(GinhDecay), itsC(C), itsGleak(Gleak), itsT(SimTime::ZERO()) 00104 { } 00105 00106 // ###################################################################### 00107 inline void LeakyIntegrator::input(const float current) 00108 { itsI = current; } 00109 00110 // ###################################################################### 00111 inline void LeakyIntegrator::resetV(const double val) 00112 { itsV = val; } 00113 00114 // ###################################################################### 00115 inline void LeakyIntegrator::integrate(const SimTime& t) 00116 { 00117 // we run our difference equations with a time step of itsTimeStep; 00118 // let's here figure out how many iterations we will need to go from 00119 // itsT to t. We will iterate for a number of equal steps, with each 00120 // step as close to itsTimeStep as possible to that we end up at 00121 // time t after iterating for an integer number of time steps: 00122 const SimTime dt = SimTime::computeDeltaT((t - itsT), itsTimeStep); 00123 const float dtsc = float(dt.secs()) / itsC; 00124 00125 for (SimTime tt = itsT; tt < t; tt += dt) 00126 { 00127 itsV += dtsc * ( itsI - ( itsGleak + itsGinh ) * itsV ); 00128 if (itsV < 0.0F) itsV = 0.0F; 00129 itsGinh *= itsGinhDecay; // progressively loose inhibitory influences 00130 } 00131 00132 // we are done, just keep track of new current time: 00133 itsT = t; 00134 } 00135 00136 // ###################################################################### 00137 inline float LeakyIntegrator::getV() const 00138 { return itsV; } 00139 00140 // ###################################################################### 00141 inline void LeakyIntegrator::setGinh(const float g) 00142 { itsGinh = g; } 00143 00144 // ###################################################################### 00145 inline void LeakyIntegrator::addGinh(const float g) 00146 { itsGinh += g; } 00147 00148 // ###################################################################### 00149 inline void LeakyIntegrator::setGinhDecay(const float decay) 00150 { itsGinhDecay = decay; } 00151 00152 #endif 00153 00154 // ###################################################################### 00155 /* So things look consistent in everyone's emacs... */ 00156 /* Local Variables: */ 00157 /* indent-tabs-mode: nil */ 00158 /* End: */