/** \ingroup Experiment * Initialize the ParStaircase with n internal staircase, and randomize them in the lower-upper interval as specified by other two parameters. * @param params ParametersLoader object just initialized with the staircase properties, for a correct settings of the staircase parameters the parameters files loaded by params, should contain the following items (all starting with s to specify that are special parameters relative to the Parstaircase : \code sStairNumber: 4 sStairStartStates: 10,5,-5,-10 sStairAscending: 0,0,1,1 sStairCorrectAnswers: 3,3,3,3 sStairMaxreversals: 10,10,10,10 sStairMaxTrials: 100,100,100,100 sStairPositiveStep: 0.25,10,5,0.1 sStairPositiveStepAfterFirstReversal: 0.01 sStairNegativeStep: 1 \endcode **/ void ParStaircase::init( ParametersLoader ¶ms ) { this->currentStaircaseIndex=0; this-> init(str2num<int>(params.find("sStairNumber"))); this->setStartState(str2num<double>(params.find("sStairStartStates"),",")); this->setAscending(str2num<bool>(params.find("sStairAscending"),",")); this->setMaxReversals(str2num<int>(params.find("sStairMaxReversals"),",")); this->setMaxTrials(str2num<int>(params.find("sStairMaxTrials"),",")); this->setCorrectAnswers(str2num<int>(params.find("sStairCorrectAnswers"),",")); // Handle the case where the user want to specify different staircase steps for every single staircase, they are colon separated list of comma separated numbers if ( params.find("sStairPositiveStep").find(";")!=string::npos ) // a colon is found { // then try to stringify its content string content = params.find("sStairPositiveStep"); //removeAllWhite(content); vector<string> stairstepsstrings; util::tokenizeString(content,stairstepsstrings,";"); vector<string> negstepsstrings; util::tokenizeString(params.find("sStairNegativeStep"),negstepsstrings,";"); vector<double> negSteps(negstepsstrings.size()); for (unsigned int i=0; i<negstepsstrings.size(); i++) negSteps.at(i) = util::str2num<double>(negstepsstrings.at(i)); unsigned int n = str2num<int>(params.find("sStairNumber")); if ( stairstepsstrings.size()!=n || negstepsstrings.size()!=n ) { cerr << "Error here, number of list of staircase positive and negative steps size must equal the staircase number!" << endl; cerr << "Be sure to avoid spaces between the colon \";\"" << endl; exit(0); } for ( unsigned int i=0; i<stairstepsstrings.size(); i++) { vector<double> steps = str2num<double>(stairstepsstrings.at(i),","); this->setStairStep(i,steps,negSteps); } } else { vector<double> posSteps = str2num<double>(params.find("sStairPositiveStep"),","); vector<double> negSteps = str2num<double>(params.find("sStairNegativeStep"),","); for ( int i=0; i< str2num<int>(params.find("sStairNumber")) ; i++ ) this -> setStairStep( i,posSteps, negSteps); } double lowerClamp=-1e30,upperClamp=1e30; int maxClampHits=3; if ( params.exists("sStairClampLower") ) lowerClamp = str2num<double>(params.find("sStairClampLower")); if ( params.exists("sStairClampUpper") ) upperClamp = str2num<double>(params.find("sStairClampUpper")); if ( params.exists("sStairMaxClampHits") ) maxClampHits= str2num<int>(params.find("sStairMaxClampHits") ); this->setClamp(lowerClamp,upperClamp,maxClampHits); }
void initVariables() { trial.init(parameters); // module factor: 0 -> 1 -> 2 module.init(1,false); module.addFactor("Phase",str2num<int>(parameters.find("Phase"),",")); block = module.getNext(); if ( parameters.exists("StimulusDensity") ) stimulusDensity = str2num<double>(parameters.find("StimulusDensity")); else cerr << "Stimulus density parameters not found, set to 0.025..." << endl; adaptStimHeight = str2num<double>(parameters.find("AdaptStimulusHeight")); adaptStimRadius = str2num<double>(parameters.find("AdaptStimulusRadius")); // crea la lista degli offset in adaptation dati start, end e numero steps int nTrials = str2num<int>(parameters.find("AdaptTrials")); double adaptOffsetStart = str2num<double>(parameters.find("AdaptOffsetStart")); double adaptOffsetEnd = str2num<double>(parameters.find("AdaptOffsetEnd")); int adaptOffsetNSteps = str2num<int>(parameters.find("AdaptOffsetSteps")); if ( adaptOffsetNSteps > nTrials ) { cerr << "too much steps, they must be at max " << nTrials << endl; cin.ignore(1e6,'\n'); exit(0); } double adaptOffsetDelta = (adaptOffsetEnd - adaptOffsetStart)/adaptOffsetNSteps; for (int i=0; i<= adaptOffsetNSteps ; i++) adaptOffsets.push_back(i*adaptOffsetDelta+adaptOffsetStart); while ( adaptOffsets.size() != nTrials+2 ) //+2 così non rogna nel markersFile adaptOffsets.push_back(adaptOffsetEnd ); testStimHeight = str2num<double>(parameters.find("TestStimulusHeight")); ballRadius = str2num<double>(parameters.find("BallRadius")); initStimulus(adaptStimHeight,adaptStimRadius*2,adaptStimRadius*2); hapticRodCenter = Vector3d(0,0,focalDistance); indexInside[0]=indexInside[1]=false; globalTimer.start(); frameTimer.start(); //trial.print(cerr); }