Beispiel #1
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");
}
// Inizializza gli stream, apre il file per poi scriverci
void initStreams()
{
	// Initializza il file parametri partendo dal file parameters.txt, se il file non esiste te lo dice
	ifstream parametersFile;
	parametersFile.open("C:/cncsvisiondata/parametersFiles/Campagnoli/parametersstaircasePointing2.txt");
	parameters.loadParameterFile(parametersFile);

	/*
	// Principal streams file
	string markersFileName  = "C:/Users/visionlab/Dropbox/Shape Lab Shared/Carlo/spring13-pointingEquilateralTriangle/Staircase/twoBlocks2/staircasePointing2_markersFile_" + subjectName + ".txt";
    string responseFileName =  "C:/Users/visionlab/Dropbox/Shape Lab Shared/Carlo/spring13-pointingEquilateralTriangle/Staircase/twoBlocks2/staircasePointing2_"   + subjectName + ".txt";
	*/
	// Base directory, full path
    string baseDir = parameters.find("BaseDir");
	// Subject name
    string subjectName = parameters.find("SubjectName");
    // Principal streams file
    string markersFileName  = baseDir + "markersFile_" + subjectName + ".txt";
	string responseFileName = baseDir + "responseFile_"+ subjectName + ".txt";
	// Check for output file existence
	/// Response file
    if ( !fileExists((responseFileName)) )
        responseFile.open((responseFileName).c_str());
	if ( !fileExists(markersFileName) )
		markersFile.open(markersFileName.c_str());

	responseFile << fixed << "subjName\tIOD\ttrialN\tRelDepthObj\tStairID\tStairState\tReversals\tAscending\tresponsekey\tresp\tjitter\ttime\tstepsDone\tobjdepth\tCondition\tsequence\ttimeToFHP\tjitterObj\tstimulus" << endl;

	globalTimer.start();
}
Beispiel #3
0
/**
 * @brief drawTrial
 */
void drawTrial()
{
    if (!experimentStarted)
        return;

    if (drawInfo)
    {
        double radiusX = util::str2num<double>(parameters.find("RadiusX"));
        glPushAttrib(GL_ALL_ATTRIB_BITS);
        glDisable(GL_TEXTURE_3D);
        GLText text;
        text.init(SCREEN_WIDTH,SCREEN_HEIGHT,glWhite);
        text.enterTextInputMode();
        text.draw("CurvatureZ = " + util::stringify<double>(CurvatureZ));
        text.draw("CurvatureZ x RadiusX= " + util::stringify<double>(CurvatureZ*radiusX));
        text.draw("Factor CurvatureZ = " + util::stringify<double>(trial.getCurrent().at("CurvatureZ")));
        text.draw("IOD x k = " + util::stringify<double>(interoculardistance));
        if (parameters.find("UsePolkaDots")=="1")
            text.draw("Actual curvature controlled= "+util::stringify<double>(surface.parabolicCylinderSurface.curvature));
        text.leaveTextInputMode();
        glPopAttrib();
    }

    if ( trialMode == PROBEMODE )
        drawProbe();

    if (trialMode == STIMULUSMODE )
        drawStimulus();
}
void drawStimulus()
{
	if( fingerCalibrationDone==3 )
	{
		if( !endTrial )
		{
			if(timer.getElapsedTimeInMilliSec() < str2num<double>(parameters.find("PreMovementInterval")) ) // draw the stimulus
			{
				isStimulusDrawn=true;
				drawThreeRods();

			} else if (timer.getElapsedTimeInMilliSec() > str2num<double>(parameters.find("PreMovementInterval")) && timer.getElapsedTimeInMilliSec() < str2num<int>(parameters.find("TrialDuration")))	   // stimulus disappears
			{

				if( factors["Condition"] == 0 )
					drawTheVoid();
				else if(factors["Condition"] == 1)
				{
					if(abs(index.z()-thumb.z()) > 15.0 )
						drawTheVoid();
					else
						drawThreeRods();
				} else
					drawThreeRods();
	
			} else {															   // trial ends
				beepOk(1);
				isStimulusDrawn=false;
				drawTheVoid();
				endTrial=true;
			} 
		} 
	}

}
void initStreams()
{   /*ifstream inputParameters;
    inputParameters.open(parametersFileNames[paramIndex]);
    if ( !inputParameters.good() )
    {   cerr << "File doesn't exist" << endl;
    //exit(0);
    }*/
    parameters.loadParameterFile("C:/cncsvisioncmake/build/Debug/parametersExpFingerTrieste.txt");
    // WARNING:
    // Base directory and subject name, if are not
    // present in the parameters file, the program will stop suddenly!!!
    // Base directory where the files will be stored
    cerr << "Folders creation..." ;
    string baseDir = parameters.find("BaseDir");
    if ( !boost::filesystem::exists(baseDir) )
        boost::filesystem::create_directory(baseDir);
    // Subject name
    string subjectName = parameters.find("SubjectName");

    // Principal streams file
    string markersFileName  = "markersFile_" + subjectName + ".txt";

    // Check for output file existence
    if ( !fileExists((baseDir+markersFileName)) )
        markersFile.open((baseDir+markersFileName).c_str());
    cerr << " OK!" << endl;
}
Beispiel #6
0
void initStreams()
{   ifstream inputParameters;
    inputParameters.open("parametersRobertGrasping_v4_thumb_training.txt");
    if ( !inputParameters.good() )
    {   cerr << "File doesn't exist" << endl;
//exit(0);
    }
    parameters.loadParameterFile(inputParameters);
	interoculardistance = util::str2num<double>(parameters.find("IOD"));
// WARNING:
// Base directory and subject name, if are not
// present in the parameters file, the program will stop suddenly!!!
// Base directory where the files will be stored
    string baseDir = parameters.find("BaseDir");
    if ( !boost::filesystem::exists(baseDir) )
        boost::filesystem::create_directory(baseDir);
// Subject name
    string subjectName = parameters.find("SubjectName");

// Principal streams file
    string markersFileName  = "markersFile_" + subjectName + ".txt";

// Check for output file existence
    if ( !fileExists((baseDir+markersFileName)) )
        markersFile.open((baseDir+markersFileName).c_str());
}
Beispiel #7
0
void initTrial()
{
	// initializing all variables
	responsekey=0;
	recFHP = 0.0;
	tFHP = 0.0;
	timeToFHP = 0.0;
	step = 0.0;
	firstD = 0.0;
	secondD = 0.0;
	moveToPartII = false;
	moveToPartIII = false;
	moveToPartIV = false;
	moveToPartV = false;
	moveToPartVI = false;
	moveToPartVII = false;
	moveToPartVIII = false;
	handRecorded = false;
	pointing = false;
	part = 1;
	jitter = unifRand(str2num<double>(parameters.find("JitterMonLowBound")),
	str2num<double>(parameters.find("JitterMonUpBound")));
	condition = unifRand(-1, 1);
	jitterObj = unifRand(str2num<double>(parameters.find("RelDepthLowBound")),
	str2num<double>(parameters.find("RelDepthUpBound")));
	occludedFrames = 0;
	trialMode=rand()%3;

	// roll on
	drawBlack();
	initProjectionScreen(trial.getCurrent().first["AbsDepth"] + jitter);
	drawGLScene();
	
	timer.start();
}
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();
}
Beispiel #9
0
void initStreams()
{
#ifdef _WIN32
    string parametersFileName("parametersExpTexturingParabolicCylinderAdjustment.txt");
#endif
#ifdef __linux__
    string parametersFileName("/home/carlo/Desktop/params/parametersExpTexturingParabolicCylinderAdjustment.txt");
#endif
    inputParameters.open(parametersFileName.c_str());
    if ( !inputParameters.good() )
    {
        cerr << "File " << parametersFileName << " doesn't exist, enter a valid path, press Enter to exit" << endl;
        std::cin.ignore( std::numeric_limits <std::streamsize> ::max(), '\n' );
        exit(0);
    }
    parameters.loadParameterFile(inputParameters);

    string subjectName = parameters.find("SubjectName");
    string outputFilename = parameters.find("BaseDir")+string("responseFileAdjustment_") + subjectName + string(".txt");
    if ( util::fileExists(outputFilename) )
    {
        int i=0;
        cerr << "file " << outputFilename << "already exists, press Enter to quit" << endl;
        std::cin.ignore( std::numeric_limits <std::streamsize> ::max(), '\n' );
        exit(0);
    }
    else
    {
        responseFile.open( outputFilename.c_str() );
        responseFile << "TrialNumber\tCurrCurvature\tIODFactor\tAdjustedCurvatureZ" << endl;
    }
}
Beispiel #10
0
/**
 * @brief drawStimulus
 */
void drawStimulus()
{
    double radiusX = util::str2num<double>(parameters.find("RadiusX"));
    glPushMatrix();
    glLoadIdentity();
    glTranslated(0,0,focalDistance);
    //if (horizontal) glRotated(90,0,0,1);
    glScaled(radiusX,radiusX,radiusX);
    //glRotated(90,0,1,0); //for lateral debug mode
    if ( parameters.find("UsePolkaDots")=="1")
        surface.draw();
    glPopMatrix();

    glPushAttrib(GL_ALL_ATTRIB_BITS);
    glDisable(GL_TEXTURE_3D);
    glPushMatrix();
    glLoadIdentity();
    glTranslated(0,0,focalDistance+0.02);
    //    if ( horizontal ) glRotated(90,0,0,1);

    glScaled(radiusX,radiusX,radiusX);
    //glRotated(90,0,1,0); //for lateral debug mode
    if (parameters.find("AddRandomNoise")=="1")
    {
        stimDrawerRed.draw();
        //stimDrawerBlack.draw();
    }
    glPopMatrix();
    glPopAttrib();
}
/**
* @brief initStreams
**/
void initStreams()
{
    ifstream inputParameters;
	inputParameters.open(parametersFileNames[paramIndex]);
	parameters.loadParameterFile(inputParameters);
	interoculardistance = util::str2num<double>(parameters.find("IOD"));
    // Base directory, full path
    string baseDir = parameters.find("BaseDir");
    // Subject name
    string subjectName = parameters.find("SubjectName");
    // Principal streams file
    string markersFileName  = baseDir + "markersFile_" + subjectName + ".txt";

    // Check for output file existence
	if (util::fileExists(markersFileName ))
	{
		string error_on_file_io = markersFileName + string(" already exists");
		cerr << error_on_file_io << endl;
		MessageBox(NULL, (LPCSTR)"MARKER FILE ALREADY EXIST\n",NULL, NULL);
		exit(0);
	}
	else
	{
        markersFile.open(( markersFileName ).c_str());
		cerr << "File " << markersFileName << " loaded successfully" << endl;
	    markersFile << fixed << setprecision(3) << "SubjectName\tFingerDist\tTrialNumber\tTrialFrame\tTotTime\tVisualStimX\tVisualStimY\tVisualStimZ\tfStimulusRadius\tfDistances\tfGain\tDisappearRadius\tEyeLeftXraw\tEyeLeftYraw\tEyeLeftZraw\tEyeRightXraw\tEyeRightYraw\tEyeRightZraw\tWristXraw\tWristYraw\tWristZraw\tThumbXraw\tThumbYraw\tThumbZraw\tIndexXraw\tIndexYraw\tIndexZraw\tVisualThumbXraw\tVisualThumbYraw\tVisualThumbZraw\tVisualIndexXraw\tVisualIndexYraw\tVisualIndexZraw\tIsDrawing\tIsThumbProjected\tIsIndexProjected\tFingersLeaning" << endl;
	}
}
Beispiel #12
0
void initStreams()
{
    ifstream inputParameters;
    string parametersPassiveFileName("parametersPointsStrip.txt");
    inputParameters.open(parametersPassiveFileName.c_str());
    if ( !inputParameters.good() )
    {
        cerr << "File " << parametersPassiveFileName << " doesn't exist, enter a valid path" << endl;
        exit(0);
    }
    parameters.loadParameterFile(inputParameters);

    // WARNING:
    // Base directory and subject name, if are not
    // present in the parameters file, the program will stop suddenly!!!
    // Base directory where the files will be stored
    string baseDir = parameters.find("BaseDir");
    if ( !boost::filesystem::exists(baseDir) )
        boost::filesystem::create_directory(baseDir);

    string responseFileName = baseDir + "responseFileStripAdapt_" + parameters.find("SubjectName") +".txt";
    responseFile.open(responseFileName.c_str());

    responseFile << setw(6) << left <<
                 "Trial\tTilt\tSlant\tDef\tFlowDir\tFlowIncrement" << endl;
}
/*** TRIAL ***/
void initVariables()
{
	trial.init(parameters);
	interoculardistance = str2num<double>(parameters.find("IOD"));
	trial_duration = str2num<double>(parameters.find("trial_duration"));
	motion_step = str2num<double>(parameters.find("motion_step"));
	motion_theta = str2num<double>(parameters.find("motion_theta"));
}
Beispiel #14
0
/*** TRIAL ***/
void initVariables()
{
	trial.init(parameters);
	trial.print();

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

	max_repetitions = str2num<int>(parameters.find("max_repetitions"));
}
Beispiel #15
0
void initVariables()
{
	// initialize the trial matrix
	trial.init(parameters);
	// initialize the noise level
	stimulus_noise = str2num<double>(parameters.find("NoiseLevel"));
	// is it visual or haptic?
	condition = str2num<double>(parameters.find("Condition"));
}
Beispiel #16
0
/**
 * @brief arrowFunc
 * @param key
 * @param x
 * @param y
 */
void arrowFunc(int key, int x, int y)
{
    switch(key)
    {
    /*
    case GLUT_KEY_LEFT:
    {
        if (horizontal)
        {
            if (CurvatureZ>0.2)
                CurvatureZ+=util::str2num<double>(parameters.find("ParabolaStepSize"));
            else
                CurvatureZ+=util::str2num<double>(parameters.find("ParabolaStepSize"))/10.0;
        }
    }
        break;
    case GLUT_KEY_RIGHT:
    {
        if (horizontal)
        {
            if (CurvatureZ>0.2)
                CurvatureZ-=util::str2num<double>(parameters.find("ParabolaStepSize"));
            else //finer resolution
                CurvatureZ-=util::str2num<double>(parameters.find("ParabolaStepSize"))/10.0;
        }
    }
        break;
        */
    case GLUT_KEY_UP:
    {
        if (!horizontal)
        {
            if (CurvatureZ>0.2)
                CurvatureZ-=util::str2num<double>(parameters.find("ParabolaStepSize"));
            else //finer resolution
                CurvatureZ-=util::str2num<double>(parameters.find("ParabolaStepSize"))/10.0;
            if (CurvatureZ<0)
                CurvatureZ=0;
        }
    }
        break;
    case GLUT_KEY_DOWN:
    {
        if (!horizontal)
        {
            if (CurvatureZ>0.2)
                CurvatureZ+=util::str2num<double>(parameters.find("ParabolaStepSize"));
            else //finer resolution
                CurvatureZ+=util::str2num<double>(parameters.find("ParabolaStepSize"))/10.0;
            if (CurvatureZ<0)
                CurvatureZ=0;
        }
    }
        break;
    }
}
Beispiel #17
0
void checkBounds()
{
    double maxOscTime = str2num<double>(parameters.find("MaxOscillationTime"));
    double minOscTime = str2num<double>(parameters.find("MinOscillationTime"));
    double maxHeadShift = str2num<double>(parameters.find("MaxHeadShift"));

    if ( (headCalibrationDone > 2) && (trialMode!=PROBEMODE) )
    {
        conditionInside = abs(eyeRight.z()-eyeCalibration.z()) < maxHeadShift;
        if ( !( conditionInside || (!wasInside) ) )
        {
            signs.pop_back();
            signs.push_front( (eyeRight.z()-eyeCalibration.z()) > 0 );
            rythmMaker.stop();
            if ( signs.front() != signs.back() )
            {
                if ( trialMode == STIMULUSMODE )
                {
                    boost::thread beepOkThread(beepOk);
                    beepOkThread.detach();
                    sumOutside++;
                }
                double timeElapsed = rythmMaker.getElapsedTimeInMilliSec();
                if ( (timeElapsed > minOscTime ) && (timeElapsed < maxOscTime ) && (trialMode==FIXATIONMODE) )
                {
                    boost::thread beepOkThread(beepOk);
                    beepOkThread.detach();
                    if ( factors["Onset"]*optotrak.getAllVelocities()[3].z() > 0 )
                        sumOutside++;
                }
                if ( (timeElapsed < minOscTime ) && ( trialMode==FIXATIONMODE ) )
                {
                    boost::thread tweeterThread(tweeter);
                    tweeterThread.detach();
                    sumOutside=0;
                }
                if ( (timeElapsed > maxOscTime ) && ( trialMode==FIXATIONMODE ) )
                {
                    boost::thread wooferThread(woofer);
                    wooferThread.detach();
                    sumOutside=0;
                }
            }
            rythmMaker.start();
        }
        wasInside = conditionInside;
    }

    if ( (stimOutside) && (trialMode==STIMULUSMODE) )
    {
        outsideBeep();
        stimOutside=false;
        trialMode=CALIBRATIONMODE;
        sumOutside=0;
    }
}
Beispiel #18
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();
}
Beispiel #19
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();
}
Beispiel #20
0
void initStreams()
{
    string parametersPassiveFileName("../OpenGL/parametersPassiveCdef.txt");
    inputParameters.open(parametersPassiveFileName);
    if ( !inputParameters.good() )
    {
        cerr << "File " << parametersPassiveFileName << " doesn't exist, enter a valid path" << endl;
        cin.ignore(1E6,'\n');
        exit(0);
    }
    parameters.loadParameterFile(inputParameters);
#ifdef _WIN32
    // WARNING:
    // Base directory and subject name, if are not
    // present in the parameters file, the program will stop suddenly!!!
    // Base directory where the files will be stored
    string baseDir = parameters.find("BaseDir");
    if ( !exists(baseDir) )
        create_directory(baseDir);

    // Subject name
    string subjectName = parameters.find("SubjectName");

    // Principal streams file
    string transformationFileName("transformationFile_");
    string trialFileName("trialFile_");
    string anglesFileName("anglesFile_");
    string responseFileName("responseFile_");

    // Add the subject name to file extension
    transformationFileName	+=string(subjectName)+".txt";
    trialFileName			+=string(subjectName)+".txt";
    anglesFileName			+=string(subjectName)+".txt";
    responseFileName		+=string(subjectName)+".txt";

    // Check for output file existence
    /** Transformation file **/
    if ( !fileExists((baseDir+transformationFileName)) )
        transformationFile.open((baseDir+transformationFileName).c_str() );

    /** Trial file **/
    if ( !fileExists((baseDir+trialFileName)) )
        trialFile.open((baseDir+trialFileName).c_str());

    /** Angles file **/
    if ( !fileExists((baseDir+anglesFileName)) )
        anglesFile.open((baseDir+anglesFileName).c_str());

    /** Response file **/
    if ( !fileExists((baseDir+responseFileName)) )
        responseFile.open((baseDir+responseFileName).c_str());
#endif
    cerr << "streams end" << endl;
}
void initTrial()
{
	isStimulusDrawn=false;
	responsekey=0;
	jitter = unifRand(str2num<double>(parameters.find("VirtualObjRelDepthLowBound")),
	str2num<double>(parameters.find("VirtualObjRelDepthUpBound")));
	drawGLScene();
	initProjectionScreen(trial.getCurrent().first["AbsDepth"] + jitter);
	frame=0;
	timer.start();
	isStimulusDrawn=true;
}
Beispiel #22
0
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"));
}
Beispiel #23
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
	for(int i=0;i<ROUNDS;i++)
	{
		srand(timer.getElapsedTimeInMicroSec());
		timer.sleep(1000);
		trial[i].init(parameters);
		cerr << "round" << endl;
		trial[i].print();
	}
	middlePos = (str2num<double>(parameters.find("TrainingDist"))+str2num<double>(parameters.find("CatchDist")))/2.0;
}
Beispiel #24
0
/*** TRIAL ***/
void initVariables()
{
	trial.init(parameters);
	interoculardistance = str2num<double>(parameters.find("IOD"));
	trial_duration = str2num<double>(parameters.find("trial_duration"));
	motion_step = str2num<double>(parameters.find("motion_step"));
	motion_theta = str2num<double>(parameters.find("motion_theta"));
	motion_mono = str2num<int>(parameters.find("motion_mono"));
	
	if(motion_mono == 1)
		IOD_motion = 0.0;
	else
		IOD_motion = interoculardistance;
}
Beispiel #25
0
void drawSquare()
{

		glLoadIdentity();
		glTranslated(0.0,0,trial.getCurrent()["AbsDepth"]);
		glRotated(trial.getCurrent()["Orientation"]*(str2num<double>(parameters.find("ThetaSign")))+theta,1,1,0);
		edge = str2num<double>(parameters.find("SquareSize")) + jitterX;
		glColor3fv(glRed);
		glBegin(GL_LINE_LOOP);
		glVertex3d(edge,edge,0.0);
		glVertex3d(edge,-edge,0.0);
		glVertex3d(-edge,-edge,0.0);
		glVertex3d(-edge,edge,0.0);
		glEnd();
}
Beispiel #26
0
void advanceTrial()
{
	beepOk(0);
	double timeElapsed = timer.getElapsedTimeInMilliSec();
	responseFile.precision(3);
	responseFile << fixed << 
					parameters.find("SubjectName") << "\t" <<
					(eyeLeft-eyeRight).norm() << "\t" <<
					trialNumber << "\t" <<
					trial.getCurrent()["AbsDepth"] << "\t" << 
					trial.getCurrent()["RelDepthObj"] << "\t" << 
					xedge << "\t" <<
					xedge + jitter << "\t" <<
					zedge << "\t" <<
					zedge + (jitter/2) << "\t" <<
					jitter << "\t" <<
					jitterX << "\t" <<
					theta << "\t" <<
					trial.getCurrent()["Orientation"] << "\t" <<
					timeElapsed
					<< endl;
	trialNumber++;
	if(trial.getRemainingTrials() != 0)
		initTrial();
	else
	{
		cleanup(); // shut down Optotrak
		exit(0);
	}
}
Beispiel #27
0
void drawInfo()
{
	if ( visibleInfo )
	{
	GLText text;	
	text.init(SCREEN_WIDTH,SCREEN_HEIGHT,glWhite,GLUT_BITMAP_HELVETICA_12);
	text.enterTextInputMode();
	text.draw("####### SUBJECT #######");
	text.draw("#");
	text.draw("# Name: " +parameters.find("SubjectName"));
	text.draw("# IOD: " +stringify<double>(interoculardistance));
	text.draw("#");
	text.draw("# trial: " +stringify<double>(trialNumber));
	text.draw("#");
	text.draw("# orientation: " +stringify<double>(trial.getCurrent()["Orientation"]*(str2num<double>(parameters.find("ThetaSign")))+theta));
	text.draw("#");
	/*
	for ( std::map<string,double>::iterator iter = trial.getCurrent().begin(); iter!=trial.getCurrent().end();++iter)
	{
		text.draw(iter->first + ": " + stringify<double>(iter->second));
	}
	*/
	text.draw("#######################");
/*	text.draw("HeadCalibration= " + stringify<int>(headCalibrationDone) );
	if ( isVisible(markers[1].p) && isVisible(markers[2].p) )
		glColor3fv(glGreen);
	else
		glColor3fv(glRed);
	text.draw("Marker "+ stringify<int>(1)+stringify< Eigen::Matrix<double,1,3> > (markers[1].p.transpose())+ " [mm]" );
	text.draw("Marker "+ stringify<int>(2)+stringify< Eigen::Matrix<double,1,3> > (markers[2].p.transpose())+ " [mm]" );
	
	glColor3fv(glWhite);
	text.draw("Marker "+ stringify<int>(3)+stringify< Eigen::Matrix<double,1,3> > (markers[3].p.transpose())+ " [mm]" );
	text.draw("Marker "+ stringify<int>(4)+stringify< Eigen::Matrix<double,1,3> > (markers[4].p.transpose())+ " [mm]" );
	
	if ( isVisible(markers[5].p) && isVisible(markers[6].p) && isVisible(markers[7].p) )
		glColor3fv(glGreen);
	else
		glColor3fv(glRed);
	text.draw("Marker "+ stringify<int>(5)+stringify< Eigen::Matrix<double,1,3> > (markers[5].p.transpose())+ " [mm]" );
	text.draw("Marker "+ stringify<int>(6)+stringify< Eigen::Matrix<double,1,3> > (markers[6].p.transpose())+ " [mm]" );
	text.draw("Marker "+ stringify<int>(7)+stringify< Eigen::Matrix<double,1,3> > (markers[7].p.transpose())+ " [mm]" );
	text.draw("Marker "+ stringify<int>(9)+stringify< Eigen::Matrix<double,1,3> > (markers[9].p.transpose())+ " [mm]" );
	
	glColor3fv(glWhite);

	text.draw("EyeRight= "+stringify< Eigen::Matrix<double,1,3> > (eyeRight.transpose())+ " [mm]" );
	text.draw("EyeLeft= "+stringify< Eigen::Matrix<double,1,3> > (eyeLeft.transpose())+ " [mm]" );
	text.draw("Alignment(X,Y)= " +stringify<double>(alignmentX)+","+stringify<double>(alignmentY));
	text.draw(" ");
	text.draw("jitter = " +stringify<double>(jitter));
	text.draw(" ");
	text.draw("size = " +stringify<double>((xedge + jitter)));
	text.draw("xedge = " +stringify<double>(xedge));
	text.draw(" ");
	text.draw("depth = " +stringify<double>(zedge + (jitter/2)));
	text.draw("zedge = " +stringify<double>(zedge));
*/	text.leaveTextInputMode();
	}
}
Beispiel #28
0
// Inizializza gli stream, apre il file per poi scriverci
void initStreams()
{
	// Initializza il file parametri partendo dal file parameters.txt, se il file non esiste te lo dice
	ifstream parametersFile;
	parametersFile.open("parametersShapeSizeConstancyRtG.txt");
	parameters.loadParameterFile(parametersFile);

	// Subject name
	string subjectName = parameters.find("SubjectName");

	//Subject's ReportFile
	ifstream subjParametersFile;
	string reportFile  = subjectName + "Est.txt";
	subjParametersFile.open(reportFile.c_str());
	subjParams.loadParameterFile(subjParametersFile);

	// Principal streams file
	string markersFileName  = "markersFile_" + subjectName + ".txt";
	string responseFileName =	"responseFile_"	+ subjectName + ".txt";

	// Check for output file existence
	/// Response file
	if ( !fileExists(responseFileName) )
		responseFile.open(responseFileName.c_str());
	if ( !fileExists(markersFileName) )
		markersFile.open(markersFileName.c_str());

	responseFile << fixed << "NTrial\tIOD\tEstSize\tEstDepth\tAbsDepth\tTime\tStimTime" << endl;

}
Beispiel #29
0
// Inizializza gli stream, apre il file per poi scriverci
void initStreams()
{
	// Initializza il file parametri partendo dal file parameters.txt, se il file non esiste te lo dice
	ifstream parametersFile;
	parametersFile.open(parametersFile_directory.c_str());
	parameters.loadParameterFile(parametersFile);

	// Subject name
	string subjectName = parameters.find("SubjectName");

	initVariables();

	// Principal streams files

	// response file (if haptic)
	if(condition == 1)
	{
		string responseFileName = experiment_directory + responseFile_name + subjectName + "_" + stringify<int>(condition) + "_" + stringify<int>(stimulus_noise) + ".txt";
	
		if ( !util::fileExists(responseFileName) )
	        responseFile.open(responseFileName.c_str());

		responseFile << fixed << responseFile_headers << endl;
	}

	// summary file
	string summaryFileName = experiment_directory + responseFile_name + subjectName + "_" + stringify<int>(condition) + "_" + stringify<int>(stimulus_noise) + "_summary.txt";

	/// Summary file
	if ( !util::fileExists(summaryFileName) )
	        summaryFile.open(summaryFileName.c_str());

	summaryFile << fixed << summaryFile_headers << endl;
}
Beispiel #30
0
void drawFingerTips()
{   // ADAPTATION BLOCK
    if ( block.at("Phase") == 1 && headCalibrationDone==3 && fingerCalibrationDone==3 && trialMode==STIMULUSMODE && isDrawing ) //adaptation
    {   glColor3fv(glRed);
        glPointSize(8);
        glBegin(GL_POINTS);
        switch ( str2num<int>(parameters.find("AdaptFinger")) )
        {
        case 0:
        {   glVertex3d(visualThumb.x(),visualThumb.y(), visualThumb.z());
        }
        break;
        case 1:
        {   glVertex3d(visualIndex.x(),visualIndex.y(), visualIndex.z());
        }
        break;
        case 2:
        {   glVertex3d(visualThumb.x(),visualThumb.y(), visualThumb.z());
            glVertex3d(visualIndex.x(),visualIndex.y(), visualIndex.z());
        }
        break;
        }
        glEnd();
        glPointSize(1);
    }
    // END ADAPTATION BLOCK
}