Exemplo n.º 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();
}
Exemplo n.º 2
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");
}
Exemplo n.º 3
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();
}
Exemplo n.º 4
0
void mouseFunc(int button, int state, int _x , int _y)
{
    if ( trialMode == PROBEMODE )
    {
        glutWarpPointer(SCREEN_WIDTH/2,SCREEN_HEIGHT/2);

        if ( button == GLUT_LEFT_BUTTON && (state==GLUT_DOWN) )
            probeAngle+=90;
        if ( button == GLUT_RIGHT_BUTTON && (state==GLUT_DOWN) )
            probeAngle-=90;

        if( button== GLUT_MIDDLE_BUTTON  )
        {
            double responseTime=responseTimer.getElapsedTimeInMilliSec();
            double clickDelay=100;	//milliseconds before the click is valid
            if ( responseTime > clickDelay )
            {
                timeFrame=0.0; //this put the stimulus in the center each central time mouse is clicked in
                bool contraction = ( factors["Tilt"]==90 ) || (factors["Tilt"]==0);
                double angleResponse = (mod(probeAngle+probeStartingAngle,360));
                if ( trial.getRemainingTrials()==0 )
                {
                    responseFile << setw(6) << left <<  trialNumber << " " << factors["Def"] <<" " << factors["Tilt"] <<" " << factors["Slant"] << " " << factors["Anchored"] <<  " " << factors["FollowingSpeed"] << " " << factors["Onset"] << " " << (focalDistance - eyeCalibration.z()) << " " << angleResponse << " " << responseTime << " " << contraction << endl;
                    cleanup();
                    exit(0);
                }
                else
                {
                    responseFile << setw(6) << left <<  trialNumber << " " << factors["Def"] <<" " << factors["Tilt"] <<" " << factors["Slant"] << " " << factors["Anchored"] << " " << factors["FollowingSpeed"] << " " << factors["Onset"] << " " << (focalDistance - eyeCalibration.z()) << " " << angleResponse << " " << responseTime << " " << contraction << endl;
                    factors = trial.getNext();
                    trialNumber++;
                }
                advanceTrial();

                double possibleAngles[]= {0,90,180,270};
                probeStartingAngle=possibleAngles[rand()%4];
                probeAngle=0;
                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.initList(&redDotsPlane);
                mouseButton=0;
            }
        }
    }
    glutPostRedisplay();
}
Exemplo n.º 5
0
void build_two_planes()
{
	// BOX left
	boxLeft.setDimensions(40.0, 50.0, 0.1);
	boxLeft.setNpoints(450);
	boxLeft.compute();

	boxLeftDrawer.setStimulus(&boxLeft);
	boxLeftDrawer.setSpheres(true);
	boxLeftDrawer.initList(&boxLeft, glRed);

	// BOX right
	boxRight.setDimensions(40.0, 50.0, 0.1);;
	boxRight.setNpoints(450);
	boxRight.compute();

	boxRightDrawer.setStimulus(&boxRight);
	boxRightDrawer.setSpheres(true);
	boxRightDrawer.initList(&boxRight, glRed);

	// fixation rod
	rodMiddle.setDimensions(10.0, 5.0, 0.5);;
	rodMiddle.setNpoints(100);
	rodMiddle.compute();

	rodMiddleDrawer.setStimulus(&rodMiddle);
	rodMiddleDrawer.setSpheres(true);
	rodMiddleDrawer.initList(&rodMiddle, glRed);
}
void initVariables()
{
    interoculardistance = str2num<double>(parameters.find("IOD"));

    redDotsPlane.setNpoints(75);  //XXX controllare densita di distribuzione dei punti
    redDotsPlane.setDimensions(50,50,0.1);
	redDotsPlane.compute();
    stimDrawer.setSpheres(true);
	stimDrawer.setStimulus(&redDotsPlane);
    stimDrawer.initList(&redDotsPlane);
}
Exemplo n.º 7
0
void keyPressed()
{
    // Reset the translation of strip
    stripDisplacementIncrement = 0;
    double responseTime=responseTimer.getElapsedTimeInMilliSec();
    timeFrame=0.0; //this put the stimulus in the center each central time mouse is clicked in
    advanceTrial();

    // Imposta stimolo e drawer
    redDotsPlane.setNpoints(75);
    redDotsPlane.setDimensions(50,50,0.1);
    redDotsPlane.compute();
    stimDrawer.initList(&redDotsPlane,glRed,2);
}
Exemplo n.º 8
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();
}
Exemplo n.º 9
0
void mouseFunc(int button, int state, int _x , int _y)
{
    if ( trialMode == PROBEMODE )
    {
        glutWarpPointer(SCREEN_WIDTH/2,SCREEN_HEIGHT/2);

        if ( button == GLUT_LEFT_BUTTON && (state==GLUT_DOWN) )
            mouseButton=1;
        if ( button == GLUT_RIGHT_BUTTON && (state==GLUT_DOWN) )
            mouseButton=-1;

        if( (button== GLUT_LEFT_BUTTON || button==GLUT_RIGHT_BUTTON) && (state==GLUT_UP) && (mouseButton!=0) )
        {
            double responseTime=responseTimer.getElapsedTimeInMilliSec();
            double clickDelay=100;	//milliseconds before the click is valid
            if ( responseTime > clickDelay )
            {
                timeFrame=0.0; //this put the stimulus in the center each central time mouse is clicked in
                if ( trial.isEmpty() )
                {
                    responseFile << setw(6) << left <<  trialNumber << " " << factors["Def"] <<" " << factors["Tilt"] <<" " << factors["Slant"] << " " << factors["Anchored"] << " " << factors["RotationSpeed"] << " " << factors["FollowingSpeed"] << " " << factors["Onset"] << " " << (focalDistance - eyeCalibration.z()) << " " << mouseButton << " " << responseTime << endl;
                    cleanup();
                    exit(0);
                }
                else
                {
                    responseFile << setw(6) << left <<  trialNumber << " " << factors["Def"] <<" " << factors["Tilt"] <<" " << factors["Slant"] << " " << factors["Anchored"] << " " << factors["RotationSpeed"] << " " << factors["FollowingSpeed"] << " " << factors["Onset"] << " " << (focalDistance - eyeCalibration.z()) << " " << mouseButton << " " << responseTime << endl;
                    factors = trial.getNext();
                    trialNumber++;

                }
                advanceTrial();
                redDotsPlane.setDimensions(50,50,0.1);
                redDotsPlane.setSlantTilt(factors["Slant"], factors["Tilt"] );
                redDotsPlane.compute();
                stimDrawer.initList(&redDotsPlane);
                mouseButton=0;
            }
        }
    }
    glutPostRedisplay();
}
void build_three_rods()
{
	// Ora inizializza i 3 rods (stimoli)
	for (int i=0; i<3; i++)
	{
		cylinder[i].setNpoints(150);
		cylinder[i].setRadiusAndHeight(0.1,50.0); // raggio (mm) altezza (mm)
		// Dispone i punti random sulla superficie cilindrica 
		cylinder[i].compute();
		stimDrawer[i].setStimulus(&cylinder[i]);
		// seguire questo ordine altrimenti setspheres non ha effetto se chiamata dopo StimulusDrawer::initList
		stimDrawer[i].setSpheres(true);
		stimDrawer[i].initList(&cylinder[i], glRed);
	}

	// BOX pedestal
	boxPedestal.setDimensions(objwidth+10.0, 55.0, depth_pedestal+5.0);
	boxPedestal.setNpoints(150);
	boxPedestal.compute();

	boxPedestalDrawer.setStimulus(&boxPedestal);
	boxPedestalDrawer.setSpheres(true);
	boxPedestalDrawer.initList(&boxPedestal, glRed);

	// BOX stimulus
	boxStimulus.setDimensions(objwidth+10.0, 55.0, depth_stimulus+5.0);;
	boxStimulus.setNpoints(150);
	boxStimulus.compute();

	boxStimulusDrawer.setStimulus(&boxStimulus);
	boxStimulusDrawer.setSpheres(true);
	boxStimulusDrawer.initList(&boxStimulus, glRed);
}
void keyPressed()
{
    if ( trialMode == PROBEMODE )
    {
        if ( trialNumber==0)
        {   responseFile << setw(6) << left <<
                         "TrialNumber" << "Tilt Slant Rotation RotationSpeed FollowingSpeed Onset EyeCal.x EyeCal.y EyeCal.z StimFrames ProbeAngle" << endl;
        }
        responseFile << setw(6) << left <<
                     trialNumber << " " <<
                     factors["Tilt"] << " "  <<
                     factors["Slant"] << " " <<
                     factors["Rotation"] << " " <<
                     factors["RotationSpeed"] << " " <<
                     factors["FollowingSpeed"] << " " <<
                     factors["Onset"] << " " <<
                     eyeCalibration.transpose() << " " <<
					 stimulusFrames << " " <<
                     probeAngle << endl;

        double possibleAngles[]= {0,90,180,270};
        probeStartingAngle=possibleAngles[rand()%4];
        redDotsPlane.compute();
        
		stimDrawer.initList(&redDotsPlane);

        isReading=true;
        // Winds down the file until probemode isn't finished
        while ( trialMode == PROBEMODE  || trialMode == CALIBRATIONMODE )
        {   if ( readline(inputStream, trialNumber,  headCalibration,  trialMode, pointMatrix ) )
            {
                cleanup();
                exit(0);
            }
        }
        
    #ifdef _WIN32
    beepOk();
    #endif
	}
}
Exemplo n.º 12
0
void keyPressed()
{
    if ( trialMode == PROBEMODE )
    {
        if ( trialNumber==0)
        {   responseFile << setw(6) << left <<
                         "TrialNumber Tilt Slant Translation Onset TranslationConstant EyeCalx EyeCaly EyeCalz StimFrames ProbeAngle" << endl;
        }
        stimulusDuration.stop();
        responseFile << setw(6) << left <<
                     trialNumber << " " <<
                     factors["Tilt"] << " "  <<
                     factors["Slant"] << " " <<
                     factors["Translation"] << " " <<
                     factors["Onset"] << " " <<
                     factors["TranslationConstant"] << " " <<
                     eyeCalibration.transpose() << " " <<
                     stimulusFrames << " " <<
                     probeAngle << endl;
        if ( trial.getRemainingTrials()==0 )
        {
            cleanup();
            exit(0);
        }
        else
        {
            factors = trial.getNext();
            trialNumber++;
        }
        trialMode++;
        trialMode=trialMode%4;
        double possibleAngles[]= {0,90,180,270};
        probeStartingAngle=possibleAngles[rand()%4];
        redDotsPlane.compute();
        stimDrawer.initList(&redDotsPlane);
    }
}
void build_oblique_plane(double length_pedestal, double length_stimulus)
{
	// pedestal
	boxOblique_pedestal.setDimensions(length_pedestal, 50.0, 0.1);;
	boxOblique_pedestal.setNpoints(length_pedestal*40.0*0.225);
	boxOblique_pedestal.compute();

	boxOblique_pedestalDrawer.setStimulus(&boxOblique_pedestal);
	boxOblique_pedestalDrawer.setSpheres(true);
	boxOblique_pedestalDrawer.initList(&boxOblique_pedestal, glRed);

	// stimulus
	boxOblique_stimulus.setDimensions(length_stimulus, 50.0, 0.1);;
	boxOblique_stimulus.setNpoints(length_stimulus*40.0*0.225);
	boxOblique_stimulus.compute();

	boxOblique_stimulusDrawer.setStimulus(&boxOblique_stimulus);
	boxOblique_stimulusDrawer.setSpheres(true);
	boxOblique_stimulusDrawer.initList(&boxOblique_stimulus, glRed);
}
Exemplo n.º 14
0
/**
 * @brief updateStimulus
 */
void updateStimulus()
{
    double stimSize = parameters.get("StimulusSize");
	double stimPeriod = parameters.get("StimulusPeriod");
	double zWidth = trial.getCurrent().at("ZWidth");
	int nStimulusPoints = (int)(stimSize*stimSize*parameters.get("StimulusDensity"));
	// Generate the plane stimulus
    if (parameters.find("StimulusType")=="Plane")
    {
        stimulus.setDimensions(stimSize,stimSize,0.001);
        stimulus.setNpoints(nStimulusPoints);
        stimulus.setFluffiness(0.001);
        stimulus.compute();
    }
    else if (parameters.find("StimulusType")=="Sinusoid")
    {
        stimulus.setDimensions(stimSize,stimSize,0.001);
        stimulus.setNpoints(nStimulusPoints);
        stimulus.setFluffiness(0.001);
        for (PointsRandIterator iter = stimulus.pointsRand.begin(); iter!=stimulus.pointsRand.end();++iter)
        {
            (*iter)->x = mathcommon::unifRand(-stimSize/2,stimSize/2);
            (*iter)->y = mathcommon::unifRand(-stimSize/2,stimSize/2);
            (*iter)->z = 0.5*zWidth*sin(((*iter)->x)/stimPeriod*M_PI);
        }
    }
    else
    {
        throw std::runtime_error("Wrong argument! Must be Sinusoid or Plane");
    }

    // Generate the front stimulus
    stimDrawer.setSpheres(false);
    stimDrawer.setStimulus(&stimulus);
    stimDrawer.initList(&stimulus,glRed,parameters.get("PointsSize"));
}
Exemplo n.º 15
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();
}