NeuralSimModule.H

00001 /*!@file Neuro/NeuralSimModule.H interface to neural simulaiton code */
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: David J, Berg <dberg@usc.edu>
00034 // $HeadURL: svn://isvn.usc.edu:/software/invt/trunk/saliency/src/Neuro/NeuralSimModule.H $
00035 
00036 #ifndef NEURALSIMMODULE_H_DEFINED
00037 #define NEURALSIMMODULE_H_DEFINED
00038 
00039 #include "Component/ModelComponent.H"
00040 #include "Component/ModelParam.H"
00041 #include "Image/Image.H"
00042 #include "Image/ImageSet.H"
00043 #include "Image/Range.H"
00044 #include "Util/SimTime.H"
00045 
00046 #include "ModelNeuron/Location.H"
00047 #include "ModelNeuron/SimStructure.H"
00048 #include "ModelNeuron/NeuralFieldSC.H"
00049 #include "ModelNeuron/SCTracker.H"
00050 #include "ModelNeuron/StructurePlot.H"
00051 
00052 // ######################################################################
00053 //!A SimModule interface to various models created with the ModelNeuron 
00054 // tools. The correct model is chosen from the factory by the tagName, 
00055 // so someplace early on, like in the constructor or start1, set the 
00056 // tag name of the component to the name of the model. 
00057 // ######################################################################
00058 template <class T>
00059 class NeuralSimModule : public ModelComponent
00060 {
00061 public:
00062   //! Uninitialized constructor
00063   NeuralSimModule(OptionManager& mgr, 
00064                   const std::string& descrName = "NeuralSimModule",
00065                   const std::string& tagName = "NeuralSimModule");
00066   
00067   //! Destructor
00068   virtual ~NeuralSimModule();
00069   
00070   //! get the number of input/output layers
00071   uint size() const;
00072   
00073   //! set a new input, -1 for default
00074   void setInput(const Image<float>& in, const int layer);
00075 
00076   //! set a gain for the desired input
00077   void setInputGain(const float& weight, const int layer);
00078   
00079   //! get the output, -1 for default
00080   Image<float> getV(const int layer) const;
00081   
00082   //! get the output of all the layers
00083   ImageSet<float> getSubV() const;
00084   
00085   //! update our internals to the current time
00086   void update(const SimTime& time);
00087   
00088   //get the display
00089   Layout<PixRGB<byte> > getDisplay() const;
00090   
00091   //! Reset to initial state just after construction
00092   void reset();
00093   
00094   //get the structure
00095   rutz::shared_ptr<T> getStructure();
00096   
00097 protected:
00098   OModelParam<SimTime> itsSCtimestep;//!< simulation timestep
00099   OModelParam<Dims> itsSCdims;//!< SC dimensions
00100   NModelParam<bool> itsUseSpaceVariantBoundary; //!< use space variant boundary
00101   OModelParam<std::string> itsDecoderType; //!< type of decoder 
00102   
00103   //display options
00104   OModelParam<Location> itsProbe;
00105   OModelParam<uint> itsPlotLength;
00106   OModelParam<uint> its2DPlotDepth;
00107   OModelParam<uint> itsProbeDepth;
00108   OModelParam<bool> itsDisplayOutput;
00109   OModelParam<Range<double> > itsDisplayRange;
00110   OModelParam<Dims> its2DPlotSize;
00111     
00112   //our structure and plot organizer
00113   rutz::shared_ptr<T> itsStructure;   
00114   rutz::shared_ptr<StructurePlot> itsPlot; //for saving output
00115 
00116   //our last inputs
00117   ImageSet<double> itsInput;
00118   std::vector<double> itsInputGain;
00119   Dims itsInputDims;
00120 
00121   //construct our model
00122   virtual void setModel(const std::string& model, const Dims& dims, const SimTime& starttime = SimTime::ZERO());
00123 
00124 };
00125 
00126 #endif
00127 // ######################################################################
00128 /* So things look consistent in everyone's emacs... */
00129 /* Local Variables: */
00130 /* indent-tabs-mode: nil */
00131 /* End: */
Generated on Sun May 8 08:41:01 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3