00001 #ifndef CELL_ARRAY_H_ 00002 #define CELL_ARRAY_H_ 00003 00004 #include <iostream> 00005 #include <map> 00006 #include <errno.h> 00007 00008 #define cimg_display_type 1 00009 #define cimg_OS 1 00010 #include "cimg/CImg.h" 00011 00012 using namespace std; 00013 using namespace cimg_library; 00014 00015 typedef struct 00016 { 00017 double xPos; 00018 double yPos; 00019 }COORD; 00020 typedef struct 00021 { 00022 double xPos; 00023 double yPos; 00024 double radius; 00025 }CoordInfoStr; 00026 typedef std::map<int, CoordInfoStr> CoordinateList; 00027 00028 class CellArray 00029 { 00030 protected : 00031 int nb_units; 00032 double step; // Time step 00033 int timesPerFrame; 00034 CoordinateList coordList; 00035 00036 // ===================================================================================== 00037 // Parameters needed to construct the layer (distribution of cells) 00038 // ===================================================================================== 00039 double Rmax; // Size parameters (maximum radius and fovea) 00040 double R0; 00041 double d0; // Sampling parameters 00042 double decayRate; 00043 double gamma; 00044 double beta; 00045 00046 // ===================================================================================== 00047 // Parameters needed for the cells' synapses 00048 // ===================================================================================== 00049 double e_exc; 00050 double e_inh; 00051 double restingPotential; 00052 double gleak; 00053 double tau; 00054 00055 // ===================================================================================== 00056 // Tools to retrieve "position<-->identificator" of units : 00057 // ===================================================================================== 00058 int nb_circles; // Number of circles in the channel, INCLUDING central point 00059 double *angular_offset; // Angular_offset[n] is the angular_offset of circle n. 00060 00061 00062 // ===================================================================================== 00063 // Layer initialization: cells placement and filter building 00064 // ===================================================================================== 00065 virtual void channel_build( int init_index ){} 00066 00067 public : 00068 00069 // ===================================================================================== 00070 // Functions to handle SAMPLING : 00071 // ===================================================================================== 00072 double get_radius( int circle_index ); 00073 double get_density( double rad ); 00074 int get_numberUnits( double rad ); 00075 double density( double r ); 00076 00077 // ===================================================================================== 00078 // Functions to handle the filters' scales with eccentricity : 00079 // ===================================================================================== 00080 double spatial_scaling( double rad ); 00081 double temporal_scaling( double rad ); 00082 00083 // ===================================================================================== 00084 // Constructors/Destructor : 00085 // ===================================================================================== 00086 CellArray( double stepp = 1.0 ); 00087 virtual ~CellArray(); 00088 00089 // ===================================================================================== 00090 // Accessors : 00091 // ===================================================================================== 00092 int totalNumberUnits(); 00093 00094 // ===================================================================================== 00095 // Channel parameter definition functions : 00096 // ===================================================================================== 00097 void set_step( double s ); 00098 void set_timesPerFrame( int tf ); 00099 void set_Rmax( double f ); 00100 void set_foveaDensity( double f ); 00101 void set_foveaRadius( double f ); 00102 void set_decayRate( double f ); 00103 void set_beta( double f ); 00104 void set_gamma( double f ); 00105 00106 // ===================================================================================== 00107 // A more convenient way : 00108 // ===================================================================================== 00109 void set_channel(double rmax, double d, double r0, double k, double bet, double gam); 00110 00111 // ===================================================================================== 00112 //Global cell parameters definition (synapses and integrative properties) : 00113 // ===================================================================================== 00114 void set_Eexc( double f ); 00115 void set_Einh( double f ); 00116 void set_Erest( double f ); 00117 void set_gleak( double f ); 00118 void set_tau( double f ); 00119 00120 // ===================================================================================== 00121 //And the MOST CLASSICAL get-X functions : 00122 // ===================================================================================== 00123 double get_Rmax(); 00124 double get_step(); 00125 double get_foveaRadius(); 00126 double get_foveaDensity(); 00127 00128 CoordinateList *getCoordList(); 00129 00130 // ===================================================================================== 00131 // ===================================================================================== 00132 // ---- NOW -- The interesting part ---- 00133 00134 // The building function: 00135 void build(int init_index); 00136 void build_readingFromMap( int init_index, const char *mapFileName ); 00137 void build_uniformCellArray(int xSize, int ySize, int init_index); 00138 00139 // Feeding an image to the cell layer, this function returns the sum of all the 00140 // cell responses belonging this channel. 00141 // This function is declared as virtual, which it means that must be declared 00142 // for each class inherited from it. 00143 virtual double feed_image(CImg<double> & image, double xCenter, double yCenter) {return 0;} 00144 00145 // Saving/loading functions: 00146 virtual void channel_print(FILE*& print_file, int channel_index){} 00147 00148 void save(FILE*& print_file, int channel_index, int inIndex); 00149 void save_simple(FILE*& print_file, int channel_index, int ly_index, int inIndex); 00150 00151 void feedColumnInhibition(); 00152 00153 }; 00154 00155 00156 #endif // CELL_ARRAY_H_