本文整理汇总了C++中BalanceFactor::init方法的典型用法代码示例。如果您正苦于以下问题:C++ BalanceFactor::init方法的具体用法?C++ BalanceFactor::init怎么用?C++ BalanceFactor::init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BalanceFactor
的用法示例。
在下文中一共展示了BalanceFactor::init方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initVariables
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: initVariables
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: initVariables
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);
}
示例4: initializeExperiment
/**
* @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();
}
示例5: initVariables
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"));
}
示例6: initializeExperiment
/**
* @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));
}
示例7: initVariables
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();
}
示例8: main
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;
}
示例9: advanceTrial
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;
//.........这里部分代码省略.........
示例10: initVariables
void initVariables()
{
trial.init(parameters);
}
示例11: initVariables
void initVariables()
{
trial.init(parameters);
interoculardistance = str2num<double>(parameters.find("IOD"));
}