00001 /*!@file Psycho/Staircase.H A staircase procedure for psychophysical thresholds */ 00002 00003 // //////////////////////////////////////////////////////////////////// // 00004 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2003 // 00005 // by the 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/Psycho/Staircase.H $ 00035 // $Id: Staircase.H 7272 2006-10-18 19:24:01Z rjpeters $ 00036 // 00037 00038 #ifndef STAIRCASE_H_DEFINED 00039 #define STAIRCASE_H_DEFINED 00040 00041 #include "Component/ModelComponent.H" 00042 #include "Component/ModelParam.H" 00043 #include "Util/Timer.H" 00044 #include "Util/Types.H" 00045 00046 #include <list> 00047 00048 class ModelManager; 00049 00050 //! A staircase procedure to measure psychophysical thresholds 00051 /*! This class facilitates the evaluation of a threshold in a 00052 psychophysical task. */ 00053 00054 class Staircase : public ModelComponent 00055 { 00056 public: 00057 //! Constructor 00058 Staircase(OptionManager& mgr, 00059 const std::string& descrName = "Staircase", 00060 const std::string& tagName = "Staircase"); 00061 00062 //! Destructor 00063 ~Staircase(); 00064 00065 //! Reset to initial conditions 00066 virtual void reset1(); 00067 00068 //! Get parameter values to use for next trial 00069 /*! This will give you two values, one to use for the first period 00070 of the following trial, and one for the second period. The 00071 Staircase class will keep in memory what the expected answer 00072 should be, which you will give using setResponse(). */ 00073 void getValues(double& value1, double& value2); 00074 00075 //! Set the response of the current trial 00076 /*! The response should be true is the user said 00077 nothing-then-something, false otherwise. */ 00078 void setResponse(const bool response); 00079 00080 //! Log an event 00081 /*! This is in the public section just in case someone wants to push 00082 external events, but should not be called by the user in normal 00083 situations, as it is called internally when getNextValue() is 00084 called. */ 00085 void pushEvent(const std::string& msg, const int trial = -1, 00086 const double val = 0.0, const bool response = false); 00087 00088 protected: 00089 NModelParam<double> itsInitial; //!< initial value 00090 NModelParam<double> itsDelta; //!< delta in values 00091 NModelParam<double> itsMini; //!< minimum possible value 00092 NModelParam<double> itsMaxi; //!< maximum possible value 00093 NModelParam<int> itsNright; //!< nb of right responses to subtract a delta 00094 NModelParam<int> itsNwrong; //!< nb of wrong responses to add a delta 00095 NModelParam<std::string> itsFileName; //!< name of file to save the logs 00096 00097 void start2(); //!< get started 00098 void stop1(); //!< get stopped 00099 00100 private: 00101 int itsTrial; 00102 double itsValue; 00103 Timer itsTimer; 00104 00105 struct StaircaseEvent { 00106 uint64 tim; // the time in microseconds since start() 00107 std::string descrip; // description of the event 00108 int trial; // trial number, or <0 to not display trial info 00109 double val; // current value 00110 bool response; // last response 00111 }; 00112 00113 std::list<StaircaseEvent> itsEvents; // record a bunch of events 00114 int itsNr, itsNw; 00115 bool itsExpectedResponse; 00116 }; 00117 00118 #endif 00119 00120 // ###################################################################### 00121 /* So things look consistent in everyone's emacs... */ 00122 /* Local Variables: */ 00123 /* indent-tabs-mode: nil */ 00124 /* End: */