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 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 initVariables() { double L = 2.5; double alfa = angle*M_PI/180.0; /* BoxNoiseStimulus planes[2]; double density = 0.0125; for (int i=0; i<2; i++) { int NPoints = L*L*density; planes[i].setDimensions(L,0.01,L); planes[i].setNpoints(1000); planes[i].compute(); stimDrawerPlanes[i].setSpheres(false); stimDrawerPlanes[i].setStimulus(&planes[i]); stimDrawerPlanes[i].initList(&planes[i],glRed); } */ WedgePointsStimulus wedge; wedge.setNpoints(500); wedge.setAngle(alfa); wedge.setPlanesSize(2*L, L); wedge.compute(); stimDrawer.setSpheres(false); stimDrawer.setStimulus(&wedge); stimDrawer.initList(&wedge,glRed); cerr << "angle= " << angle << endl; }
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(); }
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(); }
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"); }
void generateSphereStimulus(double radius) { int nStimulusPoints=(int)(stimulusDensity*4*M_PI*radius*radius); /* cylinder.setNpoints(nStimulusPoints); cylinder.setAperture(0,2*M_PI); cylinder.setRadiusAndHeight(radius,height); cylinder.setFluffiness(0.001); cylinder.compute(); */ sphere.setNpoints(nStimulusPoints); sphere.setRadius(radius); sphere.setFluffiness(0.001); sphere.compute(); // Update the stimulus drawer stimDrawer.setSpheres(false); stimDrawer.setStimulus(&sphere); stimDrawer.initList(&sphere,glRed,3); //stimDrawer.setStimulus(&cylinder); //stimDrawer.initList(&cylinder,glRed,3); visualStimCenter << util::str2num<double>(parameters.find("OffsetX")),0,factors.getCurrent().at("Distances"); 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)); }
/** * @brief updateStimulus * @param CurvatureZ */ void updateStimulus(double CurvatureZ) { double radiusX = util::str2num<double>(parameters.find("RadiusX")); double noiseDensity = util::str2num<double>(parameters.find("RandomNoiseDensity")); int nRandomDots = mathcommon::getParaboloidArea(radiusX,CurvatureZ)*noiseDensity; parabolicCylinderPoints.setNpoints(nRandomDots); parabolicCylinderPoints.setCurvature(CurvatureZ); parabolicCylinderPoints.setFluffiness(0.0); parabolicCylinderPoints.compute(); stimDrawerBlack.setSpheres(false); stimDrawerRed.setSpheres(false); stimDrawerRed.setStimulus(¶bolicCylinderPoints); stimDrawerBlack.setStimulus(¶bolicCylinderPoints); float randomDotsSize = util::str2num<float>(parameters.find("RandomDotsSize")); if (parameters.find("DotsColor")=="RedAndBlack") { stimDrawerRed.initList(¶bolicCylinderPoints,glRed,randomDotsSize); parabolicCylinderPoints.compute(); stimDrawerBlack.initList(¶bolicCylinderPoints,glBlack,randomDotsSize); surface.setUniformColor(glRed); } else { stimDrawerRed.initList(¶bolicCylinderPoints,glWhite,randomDotsSize); parabolicCylinderPoints.compute(); stimDrawerBlack.initList(¶bolicCylinderPoints,glWhite,randomDotsSize); surface.setUniformColor(glWhite); } if ( parameters.find("UsePolkaDots")=="1" ) { int nSpheres = util::str2num<int>(parameters.find("TotalPolkaDots")); int dotsRadiusMin = util::str2num<int>(parameters.find("PolkaDotsRadiusMin")); int dotsRadiusMax = util::str2num<int>(parameters.find("PolkaDotsRadiusMax")); int textureResolution = util::str2num<int>(parameters.find("TextureResolution")); //surface.fillVolumeWithSpheres2(nSpheres,nSpheres,nSpheres*util::str2num<double>(parameters.find("MaxCurvatureZ")),dotsRadiusMin,dotsRadiusMax); surface.fillVolumeWithSpheres(nSpheres,dotsRadiusMin ,dotsRadiusMax); surface.initializeTexture(); surface.parabolicCylinderSurface.curvature=CurvatureZ; //surface.setUniformColor(glWhite); } }
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(); }
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); }
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); }
void buildTrainingCylinder(double depth) { // stimolo training cylinder[3].setNpoints(250); cylinder[3].setRadiusAndHeight(depth/2,50); // raggio (mm) altezza (mm) // Dispone i punti random sulla superficie cilindrica cylinder[3].compute(); trainingstim.setStimulus(&cylinder[3]); // seguire questo ordine altrimenti setspheres non ha effetto se chiamata dopo StimulusDrawer::initList trainingstim.setSpheres(true); trainingstim.initList(&cylinder[3], glRed); }
void initVariables() { //interoculardistance = str2num<double>(parameters.find("IOD")); cylinder.setNpoints(150); cylinder.setAperture(0,2*M_PI); cylinder.setRadiusAndHeight(10,50); cylinder.setFluffiness(0.001); cylinder.compute(); // update the stimulus drawer stimDrawer.setSpheres(false); stimDrawer.setStimulus(&cylinder); stimDrawer.initList(&cylinder,glRed,3); }
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); }
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(); }
void initStimulus(double height, double longAxis, double shortAxis ) { double ellipticCircumferenceApproximate = 4*3.1415*longAxis*shortAxis/(longAxis+shortAxis); // Evitiamo di calcolarci la circonferenza dell'ellisse con la mega formula tanto cambia ben poco alla fine... int nStimulusPoints=2*(int)floor(ellipticCircumferenceApproximate*height*stimulusDensity); ellipseBaseCylinder.setNpoints(nStimulusPoints); ellipseBaseCylinder.setAperture(0,2*M_PI); ellipseBaseCylinder.setAxesAndHeight(longAxis,shortAxis,height); ellipseBaseCylinder.setFluffiness(0.001); ellipseBaseCylinder.compute(); // update the stimulus drawer stimDrawer.setSpheres(false); stimDrawer.setStimulus(&ellipseBaseCylinder); stimDrawer.initList(&ellipseBaseCylinder,glRed,3); }
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(); }
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 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 } }
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); } }
/** * @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")); }