예제 #1
0
void initVariables()
{
    interoculardistance = str2num<double>(parameters.find("IOD"));
    // Create the factors-staircase object TrialGenerator
    trial.init(parameters);
    maxTotalTrials = trial.getRemainingTrials();
    cerr << "There are " << maxTotalTrials << " total trials to do..." << endl;
    factors = trial.getNext();

    redDotsPlane.setNpoints(300);
    redDotsPlane.setDimensions(50,50,0.1);

    redDotsPlane.compute();
    //stimDrawer.drawSpecialPoints();
    stimDrawer.setStimulus(&redDotsPlane);
    stimDrawer.setSpheres(false);
    stimDrawer.initList(&redDotsPlane,glRed,3);


    // Set the maximum x displacement of head
    maxXOscillation = util::str2num<double>(parameters.find("MaxXOscillation"));
    nOscillationsFixation = util::str2num<int>(parameters.find("NOscillationsFixation"));
    minOscTime = util::str2num<double>(parameters.find("MinOscillationTime"));
    maxOscTime = util::str2num<double>(parameters.find("MaxOscillationTime"));

	centerTolerance = util::str2num<double>(parameters.find("CenterTolerance"));

    totalTimer.start();
}
예제 #2
0
void initVariables()
{
    totalTimer.start();
    interoculardistance = str2num<double>(parameters.find("IOD"));
    trial.init(parameters);
    factors = trial.getNext(); // Initialize the factors in order to start from trial 1

    useCircularMask = util::str2num<int>( parameters.find("CircularMask")) == 1 ;
    circularMaskRadius = util::str2num<int>(parameters.find("CircularMaskRadius"));
    if (useCircularMask)
        glEnable(GL_STENCIL_TEST);
    else
        glDisable(GL_STENCIL_TEST);

    fixationDurationInSeconds = util::str2num<double>(parameters.find("AdaptationDurationInSeconds"));
    // Imposta stimolo e drawer
    redDotsPlane.setNpoints(util::str2num<int>(parameters.find("NumStimulusPoints")));
    redDotsPlane.setDimensions(
        util::str2num<int>(parameters.find("StimulusEdgeLength")),
        util::str2num<int>(parameters.find("StimulusEdgeLength")),0.1);
    redDotsPlane.compute();
    stimDrawer.initList(&redDotsPlane,glRed);

    resetPointStrip();

    stimulusDurationInMilliSeconds = util::str2num<double>(parameters.find("StimulusDuration"));
    initialAdaptationTimeInSeconds = util::str2num<double>(parameters.find("InitialAdaptationTime"));
    initialAdaptationFlowIncrement = util::str2num<double>(parameters.find("InitialAdaptationFlowIncrement"));
    stimMotion=SINUSOIDAL_MOTION;
    trialMode = INITIALADAPTATION;

    headEyeCoords.init(Vector3d(interoculardistance/2,0,0),Vector3d(interoculardistance/2,0,0), Vector3d(0,0,0),Vector3d(0,10,0),Vector3d(0,0,10),interoculardistance );
    eyeCalibration=headEyeCoords.getRightEye();
}
예제 #3
0
void initVariables()
{
    interoculardistance = str2num<double>(parameters.find("IOD"));
    stimulusEmiCycles= atoi(parameters.find("StimulusEmiCycles").c_str());
    trial.init(parameters);
    factors = trial.getNext(); // Initialize the factors in order to start from trial 1

    if ( atoi(parameters.find("DrawOccluder").c_str()) ==1 )
    {
        redDotsPlane.setNpoints(500);  //XXX controllare densita di distribuzione dei punti
        redDotsPlane.setDimensions(200,200,0.1);
    }
    else
    {
        redDotsPlane.setNpoints(75);  //XXX controllare densita di distribuzione dei punti
        redDotsPlane.setDimensions(50,50,0.1);
    }
    //redDotsPlane.setSlantTilt( factors["Slant"], (int) factors["Tilt"] );
    redDotsPlane.compute();
    stimDrawer.setStimulus(&redDotsPlane);
    stimDrawer.initList(&redDotsPlane);

    /** Bound check things **/
    signsX.push_back(false);
    signsX.push_back(false);

    signsY.push_back(false);
    signsY.push_back(false);

    headEyeCoords.init(Vector3d(-32.5,0,0),Vector3d(32.5,0,0), Vector3d(0,0,0),Vector3d(0,10,0),Vector3d(0,0,10),interoculardistance );
    eyeCalibration=headEyeCoords.getRightEye();
    model.load("../data/objmodels/occluder.obj");
}
예제 #4
0
void initVariables()
{
    cam.setOrthoGraphicProjection((bool)str2num<int>(parameters.find("OrthographicMode")));
    drawInfo = (bool)util::str2num<int>(parameters.find("DrawInfo"));
    //cam.setOrthoGraphicProjection(orthoMode);
    cerr << "COMPUTED IOD=" << interoculardistance  << endl;
    trial.init(parameters);

    stimulusTime=util::str2num<double>(parameters.find("StimulusTime"));
    trialTimer.start();

    trial.next();
    interoculardistance = str2num<double>(parameters.find("IOD"))*trial.getCurrent().at("IODFactor");

    int textureResolution = util::str2num<int>(parameters.find("TextureResolution"));
    int maxTextureResolutionZ = (int) std::ceil(textureResolution*util::str2num<double>(parameters.find("MaxCurvatureZ")));
    // allocate the texture memory
    if (parameters.find("UsePolkaDots")=="1")
    {
        surface.resize(textureResolution,textureResolution, maxTextureResolutionZ);
        surface.initializeSurfaceShaders(VolumetricSurfaceIntersection::SurfaceParabolicCylinder);
    }
    updateStimulus(trial.getCurrent().at("CurvatureZ"));
    CurvatureZ=0.0;
}
예제 #5
0
void initVariables()
{
	// Riempie la lista dei fattori a partire da quanto descritto nei fattori dell'oggetto parameters
	// Per dubbi prova i vari esempi di test del modulo experiments
	trial.init(parameters);
	trial.print();
}
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);
}
예제 #7
0
/*** TRIAL ***/
void initVariables()
{
	trial.init(parameters);
	trial.print();

	objdistance = str2num<double>(parameters.find("distance"));

	max_repetitions = str2num<int>(parameters.find("max_repetitions"));
}
예제 #8
0
void initVariables()
{
	// Riempie la lista dei fattori a partire da quanto descritto nei fattori dell'oggetto parameters
	// Per dubbi prova i vari esempi di test del modulo experiments
	trial.init(parameters);
	if(headCalibration)
		headCalibrationDone=0;
	else
		headCalibrationDone=3;
}
예제 #9
0
/**
 * @brief initializeExperiment
 */
void initializeExperiment()
{
    // MUST BE CALLED WITHIN A VALID OPENGL CONTEXT
    //Screen screen(SCREEN_WIDE_SIZE, SCREEN_WIDE_SIZE*SCREEN_HEIGHT/SCREEN_WIDTH, alignmentX, alignmentY, focalDistance );
	screen.init(SCREEN_WIDE_SIZE, SCREEN_WIDE_SIZE*SCREEN_HEIGHT/SCREEN_WIDTH, alignmentX, alignmentY, focalDistance );
	screen.setOffset(alignmentX,alignmentY);
    screen.setFocalDistance(focalDistance);
    cam.init(screen);

    // Initialize all the streams for file output eccetera
	parameters.loadParameterFile("C:/cncsvisiondata/parametersFiles/Fulvio/expMicroHeadMovements/parametersExpMicroHeadMovementsActive.txt");
	// Initialize focal distance and interocular distance from parameter file
    focalDistance = parameters.get("FocalDistance");
    interocularDistance = parameters.get("IOD");
    infoDraw = (int)parameters.get("DrawInfo");
	useCircularOcclusor = (int)parameters.get("UseCircularOcclusor");
    // Initialize trials balance factors
    trial.init(parameters);
	trial.next();
    // Base directory, full path
    string baseDir = parameters.find("BaseDir");
    // Subject name
    string subjectName = parameters.find("SubjectName");
    // Principal streams file

	string markersFileName = baseDir + "markersFile_MicroHeadMovementsActive_" + subjectName  + ".txt";
    string outputFileName  = baseDir + "responseFile_MicroHeadMovementsActive_" + subjectName +".txt";
    string timingFileName  = baseDir + "timingFile_MicroHeadMovementsActive_" + subjectName   + ".txt";
    // Check for output file existence
    if ( !util::fileExists((outputFileName)) )
        responseFile.open(outputFileName.c_str());
    cerr << "File " << outputFileName << " loaded successfully" << endl;

	// Check for output markers file existence
    if ( !util::fileExists((markersFileName)) )
        markersFile.open(markersFileName.c_str());
   cerr << "File " << markersFileName << " loaded successfully" << endl;

	// Check for output timing file existence
    if ( !util::fileExists((timingFileName)) )
        timingFile.open(( timingFileName ).c_str());
    cerr << "File " << timingFileName << " opened successfully" << endl;

	// Write the response file header
    responseFile << "# SubjectName\tTrialNumber\tFocalDistance\tKeyPressed\tResponseTime\tfZWidth\tfSlant\tfTilt\tfStimAnchored" << endl;

  // Finished loading parameter files

    // Update the stimulus
    updateStimulus();

    trialTimer.start();
    globalTimer.start();
}
void initVariables()
{
	// initialize the trial matrix
	trial.init(parameters);
	if(condition == 0) // get the noise level if condition is visual
	{
		// initialize the noise level
		stimulus_noise = str2num<double>(parameters.find("NoiseLevel"));
	} else // otherwise set it to zero
		stimulus_noise = 0;
	// is it visual or haptic?
	condition = str2num<double>(parameters.find("Condition"));
}
예제 #11
0
/**
 * @brief initializeExperiment
 */
void initializeExperiment()
{
    initStreams();
	factors.init(parameters);
    factors.next();
    generateSphereStimulus(factors.getCurrent().at("StimulusRadius") );
    initProjectionScreen(factors.getCurrent().at("Distances"));

	vector<double> distances = util::str2num<double>(parameters.find("fDistances")," ");
	maxCoveredDistance = max(distances.begin(),distances.end()) - min(distances.begin(),distances.end());

	selectedFinger = util::str2num<int>(parameters.find("SelectedFinger"));
	// For the rod initialization
	thetaRod = M_PI/180.0*parameters.get("RodLatitude");
	phiRod = M_PI/180.0*parameters.get("RodLongitude");
	r = parameters.get("RodRadius");
	rodStart = visualStimCenter + r*Vector3d(sin(thetaRod)*cos(phiRod),cos(thetaRod),sin(thetaRod)*sin(phiRod));
	rodEnd= visualStimCenter - r*Vector3d(sin(thetaRod)*cos(phiRod),cos(thetaRod),sin(thetaRod)*sin(phiRod));
}
예제 #12
0
void initVariables()
{
    interoculardistance = str2num<double>(parameters.find("IOD"));
    trial.init(parameters);
    factors = trial.getNext(); // Initialize the factors in order to start from trial 1

    redDotsPlane.setNpoints(75);  //XXX controllare densita di distribuzione dei punti
    redDotsPlane.setDimensions(50,50,0.1);

    redDotsPlane.compute();
    //stimDrawer.drawSpecialPoints();
    stimDrawer.setSpheres(true);
    stimDrawer.setStimulus(&redDotsPlane);
    stimDrawer.initList(&redDotsPlane);
    /** Bound check things **/
    signs.push_back(false);
    signs.push_back(false);
    rythmMaker.start();
}
예제 #13
0
void initVariables()
{
    totalTimer.start();
    interoculardistance = str2num<double>(parameters.find("IOD"));
    trial.init(parameters);
    factors = trial.getNext(); // Initialize the factors in order to start from trial 1

    // Imposta stimolo e drawer
    redDotsPlane.setNpoints(75);
    redDotsPlane.setDimensions(50,50,0.1);
    redDotsPlane.compute();
    stimDrawer.initList(&redDotsPlane,glRed);

    // Imposta striscia del fixation e drawer
    stripPlane.setNpoints(N_STRIP_POINTS);
    stripPlane.setDimensions(STRIP_WIDTH,STRIP_HEIGHT,0.01);
    stripPlane.compute();
    stripDrawer.initList(&stripPlane,glRed);

    stimMotion=SINUSOIDAL_MOTION;

    headEyeCoords.init(Vector3d(-32.5,0,0),Vector3d(32.5,0,0), Vector3d(0,0,0),Vector3d(0,10,0),Vector3d(0,0,10),interoculardistance );
    eyeCalibration=headEyeCoords.getRightEye();
}
예제 #14
0
int main(void)
{  randomizeSeed();
   /*
   BalanceFactor<int> balance;
   map<string,int> factors;
   balance.init(1,true);
   vector<int> f;
   for (int i=0; i<10; i++)
   f.push_back(i);

   balance.addFactor( "Slant",  f );
   while ( !balance.isEmpty() )
   {
       factors = balance.getNext();
       cout << factors["Slant"] << endl;
   }
   balance.init(1,true);
   cerr << "==========" << endl;
   f.clear();
   for (int i=0; i<10; i++)
   f.push_back(i);

   balance.addFactor( "Slant",  f );
   while ( !balance.isEmpty() )
   {
       factors = balance.getNext();
       cout << factors["Slant"] << endl;
   }
   */
   /*
   balance.addFactor( "Tilt", vlist_of<int>(90) );
   balance.addFactor( "Anchored", vlist_of<int>(0)(1)(2)(3));

   //balance.print();

   while ( !balance.isEmpty() )
   {
         map<string, int> tmp2 = balance.getNext() ;
         for ( map<string, int>::iterator iter = tmp2.begin(); iter!=tmp2.end(); ++iter)
         cout << iter->first << " " << iter->second << " ";
         cout << endl;
   }

   cerr << isnan(1.0/0.0) << " " << isinf(1.0/0.0) << endl;
    return 0;
    */
   map<string,int> factors;
   ifstream paramFile;
   paramFile.open("prova.exp");

   ParametersLoader params;
   params.loadParameterFile(paramFile);
   BalanceFactor<int> bfact;
   bfact.init(params);
   while (!bfact.isEmpty())
   {  factors = bfact.getNext();
      cout << factors["StimSpeed"] << endl;
   }
   //bfact.print();

   bfact.init(params);

   while (!bfact.isEmpty())
   {  factors = bfact.getNext();
      cout << factors["StimSpeed"] << endl;
   }
   /*
   BalanceFactor<int> balance;
   balance.init(params);
   balance.print();

   while ( !balance.isEmpty() )
   {
        map<string,int> vals = balance.getNext();
        for ( map<string,int>::iterator iter = vals.begin(); iter!=vals.end(); ++iter )
        {
        cout << iter->first << " " << iter->second << endl;
        }
        cout << endl << endl;

   }
   */

   return 0;
}
예제 #15
0
void advanceTrial()
{   if ( trialMode == STIMULUSMODE )
    {   bool pretrialMode=trialMode;
        trialMode++;
        trialMode=trialMode%2;
        totalTrialNumber++;

        if (block.at("Phase") != 1 )
        {
            double percentOccludedFrames = ((double)occludedFrames/(double)drawingTrialFrame )*100.0;
            if ( percentOccludedFrames > str2num<double>(parameters.find("TestPercentOccludedFrames")) )
            {
                cerr << "Percent occluded frames is" << percentOccludedFrames << " " << occludedFrames << " over " << drawingTrialFrame << endl;
                trial.reinsert(factors);

            }
            drawingTrialFrame=0;
            occludedFrames=0;
        }
        trialFrame=0;
        switch( block.at("Phase") )
        {
        case 0:  //pre-test
        {
            if ( !trial.isEmpty() )	// ci son ancora trial
            {   beepTrial();
                initStimulus(testStimHeight,testStimRadius);
                factors = trial.getNext();
                deltaXRods = mathcommon::unifRand(str2num<double>(parameters.find("DeltaXMin")),str2num<double>(parameters.find("DeltaXMax")));
                visualRodCenter = Vector3d(0,0,factors.at("Distances"));
                hapticRodCenter  = rodAway;
                initProjectionScreen(visualRodCenter.z());
                moveScreenAbsolute(visualRodCenter.z(),homeFocalDistance,SCREENSPEED);
                beepTrial();
            }
            else // si prepara per la modalità 1 (adaptation)
            {   trialMode = HANDONSTARTMODE;
                block = module.getNext();
                initStimulus(testStimHeight,testStimRadius );
                double zadaptmin = str2num<double>(parameters.find("AdaptZMin"));
                double zadaptmax = str2num<double>(parameters.find("AdaptZMax"));

                if (str2num<int>(parameters.find("AdaptMoveMonitor"))==1)
                    visualRodCenter=Vector3d(0,0,mathcommon::unifRand(zadaptmin,zadaptmax));
                else
                    visualRodCenter=Vector3d(0,0, (zadaptmin+zadaptmax)/2);
                initProjectionScreen( visualRodCenter.z());

                if ( str2num<int>(parameters.find("AdaptHapticFeedback"))==1 )
                    hapticRodCenter = visualRodCenter - Vector3d(0,0,adaptOffsets.at(block1TrialNumber));
                else
                    hapticRodCenter = rodAway;

                moveRod(Vector3d(0,0,hapticRodCenter.z() ),RODSPEED);

                checkBounds();
                beepLong();
            }
            block0TrialNumber++;
        }
        break;
        case 1:  // adaptation
        {
            block1TrialNumber++;
            if ( block1TrialNumber < str2num<int>(parameters.find("AdaptTrials")) )
            {   beepTrial();
                initStimulus(adaptStimHeight,adaptStimRadius);
                double zadaptmin = str2num<double>(parameters.find("AdaptZMin"));
                double zadaptmax = str2num<double>(parameters.find("AdaptZMax"));

                if (str2num<int>(parameters.find("AdaptMoveMonitor"))==1)
                    visualRodCenter = Vector3d(0,0,mathcommon::unifRand(zadaptmin,zadaptmax));
                else
                    visualRodCenter=Vector3d(0,0, (zadaptmin+zadaptmax)/2);

                if ( str2num<int>(parameters.find("AdaptHapticFeedback"))==1 )
                {
                    hapticRodCenter = visualRodCenter - Vector3d(0,0,adaptOffsets.at(block1TrialNumber));
                    moveScreenAbsoluteAsynchronous(visualRodCenter.z(),homeFocalDistance,SCREENSPEED);
                    moveRod(hapticRodCenter,RODSPEED);
                }
                else
                {
                    hapticRodCenter = rodAway;
                    moveScreenAbsolute(visualRodCenter.z(),homeFocalDistance,SCREENSPEED);
                }

                initProjectionScreen( visualRodCenter.z());
                beepTrial();
            }
            else
            {   beepLong();
                trialMode = HANDONSTARTMODE;
                block  = module.getNext();
                // reset the factors in order to prepare the next test phase
                trial.init(parameters);
                factors.clear();
                factors  = trial.getNext();
                deltaXRods = mathcommon::unifRand(str2num<double>(parameters.find("DeltaXMin")),str2num<double>(parameters.find("DeltaXMax")));
                //cerr << "DISTANCE= " << factors.at("Distances") << endl;
                initStimulus(testStimHeight,testStimRadius);
                visualRodCenter = Vector3d(0,0,factors.at("Distances"));
                hapticRodCenter = rodAway;

                moveScreenAbsolute(visualRodCenter.z(),homeFocalDistance,SCREENSPEED);
                moveRod(rodAway,RODSPEED);
                initProjectionScreen(visualRodCenter.z());

                beepTrial();
            }
        }
        break;
        case 2:  /// post-test
        {   if ( trial.isEmpty() )
            {   beepLong();
                cleanup();
                exit(0);
            }
            else
            {   beepTrial();
                initStimulus(testStimHeight,testStimRadius);
                factors = trial.getNext();
                deltaXRods = mathcommon::unifRand(str2num<double>(parameters.find("DeltaXMin")),str2num<double>(parameters.find("DeltaXMax")));
                cerr << "DISTANCE= " << factors.at("Distances") << endl;
                visualRodCenter =  Vector3d(0,0,factors.at("Distances"));
                hapticRodCenter  = rodAway;
                initProjectionScreen(visualRodCenter.z());
                moveScreenAbsolute(visualRodCenter.z(),homeFocalDistance,SCREENSPEED);
                beepTrial();
            }
            block2TrialNumber++;
        }
        break;
        }
        globalTimer.start();
    }
    // Mettere una idle così non perde il primo trial
    idle();
}
void initVariables()
{
    trial.init(parameters);
}
예제 #17
0
void initVariables()
{
	trial.init(parameters);
	interoculardistance = str2num<double>(parameters.find("IOD"));
}