public void ResponseLogger() { if (CurrentBlockType == BlockType.RecallBlock) { _logger.LogRaw(_iterationCount + " " + _currentSpanLength + " " + _currentRespEval.ToString() + " " + _spanLengths.Max()); } }
public void ResponseLogger() { if (StimCode == 0 && _evalResponse.ResponseTime == 0) { _evalResponse.CurrentResponseEval = ResponseEval.MISS; _evalResponse.MissCount++; } if (StimCode != 0 && _evalResponse.ResponseTime == 0) { _evalResponse.CurrentResponseEval = ResponseEval.CRJ; _evalResponse.CorrectRejectCount++; } _logger.LogRaw(CurrentBlockType.ToString() + " " + StimCode + " " + StimTime + " " + _evalResponse.ResponseTime + " " + _evalResponse.CurrentResponseEval.ToString() + " " + _evalResponse.HitCount + " " + _evalResponse.FalseAlarmCount + " " + _evalResponse.MissCount + " " + _evalResponse.CorrectRejectCount); _evalResponse.CurrentResponseEval = ResponseEval.Init; _evalResponse.RTstamp = 0; _evalResponse.ResponseTime = 0; }
void Update() { //Asking TimeManger if we are at end of trial... if (_timer.EndTrial == true) { _currentTaskState = TaskState.EndTrial; } //asking TimeManager if we are at end of a block... if (_trialType == TrialType.Both) { if (_timer.SwitchBlock == true) { if (CurrentBlockType == BlockType.Baseline) { CurrentBlockType = BlockType.Reversal; _currentTaskState = TaskState.StartBlock; } else if (CurrentBlockType == BlockType.Reversal) { CurrentBlockType = BlockType.Baseline; _currentTaskState = TaskState.StartBlock; } } } // MAIN STATE MACHINE switch (_currentTaskState) { case TaskState.WaitForTrigger: if (!Hourglass.activeInHierarchy) { Hourglass.SetActive(true); } break; case TaskState.StartTrial: ClearFeedback(); _logger.Init(); switch (_trialType) { case TrialType.Both: CurrentBlockType = BlockType.Baseline; break; case TrialType.Baseline: CurrentBlockType = BlockType.Baseline; break; case TrialType.Reversal: CurrentBlockType = BlockType.Reversal; break; } _currentTaskState = TaskState.StartBlock; break; case TaskState.StartBlock: switch (CurrentBlockType) { case BlockType.Baseline: StartBaseline(); _blockLengthLimit = _baselineBlockLength; break; case BlockType.Reversal: StartReversal(); _blockLengthLimit = _reversalBlockLength; break; } //start the block timer here, check end in Timer script BlockTimerStart = DateTime.Now; _currentTaskState = TaskState.StartIteration; break; case TaskState.StartIteration: if (CurrentBlockType == BlockType.Baseline) { ClearFeedback(); StartBaseline(); } if (CurrentBlockType == BlockType.Reversal) { ClearFeedback(); StartReversal(); } _previousChoices = new List <ItemChoice>(); if (CurrentBlockType == BlockType.Baseline || _previousCorrectChoice == ItemChoice.None) { SetCorrectAnswerRandomly(); } else { SetCorrectAnswerToPrevious(); } if (CurrentBlockType == BlockType.Baseline) { DisplayHint(); } _iterationStartTime = Time.time; //start time of the iteration _currentTaskState = TaskState.ProcessChoice; break; case TaskState.ProcessChoice: // Filter out no choice or repeated choices if (_currentChoice != ItemChoice.None && !_previousChoices.Contains(_currentChoice)) { _previousChoices.Add(_currentChoice); if (_previousCorrectChoice == ItemChoice.None) { } if (CurrentBlockType == BlockType.Reversal && _interReversalIterationCount > _interReversalIterationNumber) // **RANDOMIZED # OF ITERATIONS BETWEEN REVERSAL BLOCKS** { SetCorrectAnswerBasedOnChoiceProb(_currentChoice); _reversalFlag = 1; //marks occurance of reversals } if (_currentChoice == _correctChoice) { UpdateDisplayForChoice(_currentChoice, ChoiceResult.Correct); if (CurrentBlockType == BlockType.Reversal) { _attemptCount++; //tally for total number of responses _correctAttemptCount++; //tally for totaly number of CORRECT responses } if (CurrentBlockType == BlockType.Baseline) { _baselineAttemptCount++; baselineCorrectAttemptCount++; } _iterationEndTime = Time.time; _currentTaskState = TaskState.ReinforceIteration; } else { UpdateDisplayForChoice(_currentChoice, ChoiceResult.Incorrect); if (CurrentBlockType == BlockType.Reversal) { _attemptCount++; //tally for total number of responses _incorrectAttemptCount++; //tally for totaly number of INCORRECT responses if (_reversalFlag == 1) { _incorrectAttemptOnReversalCount++; // tally for the number of INCORRECT responses in a REVERSAL condition } } if (CurrentBlockType == BlockType.Baseline) { _baselineAttemptCount++; baselineIncorrectAttemptCount++; } _currentTaskState = TaskState.ProcessChoice; } _currentChoice = ItemChoice.None; } break; case TaskState.ReinforceIteration: var tmpTime = Time.time; _currentTaskState = tmpTime - _iterationEndTime >= 1.5 ? TaskState.EndIteration : TaskState.ReinforceIteration; //FIX THIS : MAKE THE DELAY CONFIGURABLE break; case TaskState.EndIteration: //blockTimerEnd = DateTime.Now; _currentTrialLength = Time.timeSinceLevelLoad - ScannerDelay; _previousCorrectChoice = _correctChoice; _interReversalIterationCount++; _logger.LogRaw(_reversalIterationCount + " , " + _attemptCount + " , " + _correctAttemptCount + " , " + _incorrectAttemptCount + " , " + _incorrectAttemptOnReversalCount + " , " + _responseTime + " , " + _reversalCount + " , " + _reversalResponseTime + " , " + baselineIterationCount + " , " + baselineResponseTime + " , " + _baselineAttemptCount + " , " + baselineCorrectAttemptCount + " , " + baselineIncorrectAttemptCount); if (CurrentBlockType == BlockType.Reversal) { _reversalIterationCount++; //tally of the number of iterations presented _responseTime = _iterationEndTime - _iterationStartTime; //calculating time in between CORRECT responses (response time) _totalResponseTime = _totalResponseTime + _responseTime; //total response time compiler. compiles the time it takes to get the correct answer (the time taken to complete iteration) --> used to calculate average if (_reversalFlag == 1) // checking if reversal has occured and pulling that time frame from _responseTime { _interReversalIterationNumber = Random.Range(4, 7); _reversalResponseTime = _responseTime; _totalReversalResponseTime = _totalReversalResponseTime + _reversalResponseTime; //compiling total response time in reversal situation _reversalCount++; //compiles number of reversals as they occur _reversalFlag = 0; //resets reversal marker } } if (CurrentBlockType == BlockType.Baseline) //baseline block metrics { baselineIterationCount++; baselineResponseTime = _iterationEndTime - _iterationStartTime; _totalBaselineResponseTime = _totalBaselineResponseTime + baselineResponseTime; } if (_trialType != TrialType.Both) { _currentTaskState = TaskState.StartIteration; } //if (_trialType == TrialType.All && ((blockTimerEnd - blockTimerStart).Seconds > blockLengthLimit)) //{ // _currentTaskState = TaskState.EndBlock; //} else { _currentTaskState = TaskState.StartIteration; } // if (_trialLength > _trialLengthLimit) //**SET THIS TO A GIVEN TIME PERIOD (9 MIN WAS DISCUSSED - 540 sec)** //{ // _currentTaskState = TaskState.EndTrial; //} break; case TaskState.EndBlock: if (CurrentBlockType == BlockType.Baseline) { CurrentBlockType = BlockType.Reversal; } else if (CurrentBlockType == BlockType.Reversal) { CurrentBlockType = BlockType.Baseline; } _currentTaskState = TaskState.StartBlock; break; case TaskState.EndTrial: _averageResponseTime = _totalResponseTime / _reversalIterationCount; // average response time to get correct answer over course of the whole trial _averageReversalResponseTime = _totalReversalResponseTime / _reversalCount; // average response time to reversal condition averageBaselineResponseTime = _totalBaselineResponseTime / baselineIterationCount; // baseline block metrics _logger.LogReversalSummary("ReversalIterationCount , trialDuration , averageResponseTime , reversalCount , averageReversalResponseTime" + Environment.NewLine + _reversalIterationCount + " , " + _timer.CurrentTrialLength + " , " + _averageResponseTime + " , " + _reversalCount + " , " + _averageReversalResponseTime); // summery metrics for whole trial _logger.LogBaselineSummary("BaselineIterationCount , trialDuration , baselineCorrectCount , baselineIncorrectCount , averageBaselineResponseTime" + Environment.NewLine + baselineIterationCount + " , " + _timer.CurrentTrialLength + " , " + baselineCorrectAttemptCount + " , " + baselineIncorrectAttemptCount + " , " + averageBaselineResponseTime); _logger.Term(); SceneManager.LoadScene("GameEndScreen_Stimulation"); break; } }