Пример #1
0
        private void runEvaluationTrial()
        {
            Point currPoint;

            try
            {
                /* Scenarios:
                    1. We're at the end of the experiment.
                        - StimQueue = 0
                        - TestQueue = 0
                    2. We've finished a test, proceed to next one.
                        - StimQueue = 0
                        - TestQueue > 0
                    3. We still have stimuli pairs to go through.
                        - StimQueue > 0
                */

                if (StimQueue.Count == 0 && TestQueue.Count == 0)
                {
                    MessageBox.Show("Experiment completed! Thank you for participating!");
                    outputData();
                    this.Close();
                    return;
                }

                if (StimQueue.Count == 0)
                {
                    CurrTest = TestQueue.Dequeue();

                    findTestQueue(CurrTest);

                    CurrTrial = new Trial(CurrPhase);
                    CurrStim = StimQueue.Dequeue();
                    CurrTrial.StimPair = CurrStim;
                    CurrTrial.Test = CurrTest;

                    labelA.Text = CurrStim.A;
                    labelB.Text = CurrStim.B;

                    // our locations
                    currPoint = findLocation(CurrStim.Location);

                    labelA.Location = new Point(currPoint.X - labelA.Width / 2, currPoint.Y);
                    labelB.Location = new Point(currPoint.X - labelB.Width / 2, currPoint.Y);

                    setButtonLocations();

                    mainPanel.BackColor = Color.White;
                    labelA.Visible = true;
                    labelB.Visible = false;
                    firstStimTimer.Start();
                }
                else
                {
                    CurrTrial = new Trial(CurrPhase);
                    CurrStim = StimQueue.Dequeue();
                    CurrTrial.StimPair = CurrStim;
                    CurrTrial.Test = CurrTest;

                    labelA.Text = CurrStim.A;
                    labelB.Text = CurrStim.B;

                    // our locations
                    currPoint = findLocation(CurrStim.Location);

                    labelA.Location = new Point(currPoint.X - labelA.Width / 2, currPoint.Y);
                    labelB.Location = new Point(currPoint.X - labelB.Width / 2, currPoint.Y);

                    setButtonLocations();

                    mainPanel.BackColor = Color.White;
                    labelA.Visible = true;
                    labelB.Visible = false;
                    firstStimTimer.Start();
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("Error occurred while running evaluation trials: " + e.Message);
                throw e;
            }
        }
Пример #2
0
        public void runTrial()
        {
            Point currPoint;

            try
            {
                // PRETRAINING PHASE
                if (CurrPhase == (int)Constants.Phases.Pretraining)
                {
                    if (StimQueue.Count == 0)
                    {
                        runPreTrainingEval();
                    }
                    else
                    {
                        CurrTrial = new Trial(CurrPhase);
                        CurrStim = StimQueue.Dequeue();
                        CurrTrial.StimPair = CurrStim;

                        labelA.Text = CurrStim.A;
                        labelB.Text = CurrStim.B;

                        // our locations
                        labelA.Location = new Point(Center.X - labelA.Width / 2, Center.Y);
                        labelB.Location = new Point(Center.X - labelB.Width / 2, Center.Y);

                        mainPanel.BackColor = Color.White;
                        labelA.Visible = true;
                        labelB.Visible = false;
                        firstStimTimer.Start();
                    }
                }
                // PRETRAINING EVALUATION PHASE
                else if (CurrPhase == (int)Constants.Phases.PretrainingEval)
                {
                    if (StimQueue.Count == 0)
                    {
                        // check if we've reached the expected accuracy
                        // otherwise, continue with the trials
                        if (checkAccuracy())
                        {
                            runTraining();
                        }
                        else
                        {
                            // start over!
                            setupPreTrainingEval();
                            runTrial();
                        }
                    }
                    else
                    {
                        CurrTrial = new Trial(CurrPhase);
                        CurrStim = StimQueue.Dequeue();
                        CurrTrial.StimPair = CurrStim;

                        labelA.Text = CurrStim.A;
                        labelB.Text = CurrStim.B;

                        // our locations
                        labelA.Location = new Point(Center.X - labelA.Width / 2, Center.Y);
                        labelB.Location = new Point(Center.X - labelB.Width / 2, Center.Y);

                        setButtonLocations();

                        mainPanel.BackColor = Color.White;
                        labelA.Visible = true;
                        labelB.Visible = false;
                        firstStimTimer.Start();
                    }
                }
                // TRAINING PHASE
                else if (CurrPhase == (int)Constants.Phases.Training)
                {
                    if (StimQueue.Count == 0)
                    {
                        runEvaluation();
                    }
                    else
                    {
                        CurrTrial = new Trial(CurrPhase);
                        CurrStim = StimQueue.Dequeue();
                        CurrTrial.StimPair = CurrStim;

                        labelA.Text = CurrStim.A;
                        labelB.Text = CurrStim.B;

                        // our locations
                        currPoint = findLocation(CurrStim.Location);

                        labelA.Location = new Point(currPoint.X - labelA.Width / 2, currPoint.Y);
                        labelB.Location = new Point(currPoint.X - labelB.Width / 2, currPoint.Y);

                        mainPanel.BackColor = Color.White;
                        labelA.Visible = true;
                        labelB.Visible = false;
                        firstStimTimer.Start();
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("Error occurred while running trial: " + e.Message);
                throw e;
            }
        }