private void CheckForMark() { if (IsLookingAtMarkable && ReleasedMarkKey) { _markable.Mark(); } }
protected override void OnNextStage(StageChangedEventArgs e) { var stage = e.Stage; DisplayText = stage.Cue?.Trim(); SubtitleText = stage.Subtitle?.Trim(); if (stage.Marker != null) { /* Record marker */ Markable?.Mark(stage.Marker.Value); var sessionTime = Session.SessionTime; /* Handle events */ switch (stage.Marker) { case MarkerDefinitions.ParadigmStartMarker: Result.ParadigmStartTime = sessionTime; ParadigmStarted = true; SpellerController.Start(); HintButton(); break; case MarkerDefinitions.ParadigmEndMarker: Result.ParadigmEndTime = sessionTime; break; case MarkerDefinitions.TrialStartMarker: { var trial = new SpellerParadigm.Result.Trial(); var activedButton = _activatedButton = UpdateCursor(GazePointHandler.CurrentPosition); if (activedButton != null) { trial.ActivedButtons = new SpellerParadigm.Result.Button(activedButton.Key).SingletonArray(); } trial.StartTime = CurrentTime; _trial = trial; SelectedButton = null; DisplayText = null; TrialCancelled = false; if (activedButton != null) { _detector.Active(activedButton.BorderRect); } break; } case MarkerDefinitions.TrialEndMarker: { var hintButton = HintedButton; HintButton(TrialCancelled ? 1 : 2); var trial = _trial; var detectorResult = _detector.GetResult(Buttons); _detector.Reset(); _trial = null; trial.Cancelled = TrialCancelled; trial.EndTime = CurrentTime; if (!trial.Cancelled && ComputeTrialResult(Buttons, Functions.Constant(detectorResult), hintButton, out var button, out var correct)) { trial.Correct = correct; if (button != null) { trial.SelectedButton = new SpellerParadigm.Result.Button(button.Key); } else if (!Paradigm.Config.Test.AlwaysCorrectFeedback) { SystemSounds.Exclamation.Play(); } } CheckStop(); Result.Trials.Add(trial); TrialTrigger?.Reset(); break; } } } }
protected override void OnNextStage(StageChangedEventArgs e) { var stage = e.Stage; if (TrialCancelled && stage.Marker != null && stage.Marker == SpellerMarkerDefinitions.SubTrialMarker) { e.Action = StageAction.Skip; return; } DisplayText = stage.Cue?.Trim(); SubtitleText = stage.Subtitle?.Trim(); if (stage.Marker != null) { /* Record marker */ Markable?.Mark(stage.Marker.Value); var sessionTime = Session.SessionTime; /* Handle events */ switch (stage.Marker) { case MarkerDefinitions.ExperimentStartMarker: Result.ExperimentStartTime = sessionTime; ExperimentStarted = true; SpellerController.Start(); HintButton(); break; case MarkerDefinitions.ExperimentEndMarker: Result.ExperimentEndTime = sessionTime; break; case MarkerDefinitions.TrialStartMarker: { var trial = new P300Trial { SubTrials = new List <P300Trial.SubTrial>((int)(Experiment.Config.Test.SubTrialCount + 1)) }; UpdateCursor(GazePointHandler.CurrentPosition); var activedButtons = _activedButtons; if (activedButtons != null) { var buttons = new LinkedList <SpellerExperiment.Result.Button>(); foreach (var activedButton in activedButtons) { if (activedButton != null) { buttons.AddLast(new SpellerExperiment.Result.Button(activedButton.Key)); } } trial.ActivedButtons = buttons; } trial.StartTime = CurrentTime; _trial = trial; if (_p300Detector != null) { _p300Detector.Actived = true; } SelectedButton = null; DisplayText = null; TrialCancelled = false; break; } case MarkerDefinitions.TrialEndMarker: { var hintButton = HintedButton; HintButton(TrialCancelled ? 1 : 2); var trial = _trial; _trial = null; trial.Cancelled = TrialCancelled; trial.EndTime = CurrentTime; if (_p300Detector != null) { _p300Detector.Actived = false; } if (!trial.Cancelled && ComputeTrialResult(_activedButtons, _p300Detector == null ? null : (Func <int>)_p300Detector.Compute, hintButton, out var button, out var correct)) { trial.Correct = correct; if (button == null) { SystemSounds.Exclamation.Play(); } else { trial.SelectedButton = new SpellerExperiment.Result.Button(button.Key); } } CheckStop(); Result.Trials.Add(trial); TrialTrigger?.Reset(); break; } case SpellerMarkerDefinitions.SubTrialMarker: { var activedButtons = _activedButtons; var randomBoolSequences = _randomBoolSequences; if (activedButtons != null) { var flags = new bool[activedButtons.Length]; for (var i = 0; i < activedButtons.Length; i++) { var button = activedButtons[i]; if (button != null) { button.State = (flags[i] = randomBoolSequences[i].Next()) ? 1 : 0; } } _trial.SubTrials.Add(new P300Trial.SubTrial { Timestamp = CurrentTime, Flags = flags }); } break; } } } }
protected override void OnNextStage(StageChangedEventArgs e) { var stage = e.Stage; DisplayText = stage.Cue?.Trim(); SubtitleText = stage.Subtitle?.Trim(); if (stage.Marker != null) { /* Record marker */ Markable?.Mark(stage.Marker.Value); var sessionTime = Session.SessionTime; /* Handle events */ switch (stage.Marker) { case MarkerDefinitions.BaselineStartMarker: if (_hybridSsvepIdentifier != null) { _initializer = _hybridSsvepIdentifier?.CreateInitializer(); _biosignalStreamer.AttachConsumer(_initializer); } break; case MarkerDefinitions.BaselineEndMarker: if (_initializer != null) { _biosignalStreamer.DetachConsumer(_initializer); _initializer.Initialize(); _initializer = null; } SpellerController.CalibrationComplete(); break; case MarkerDefinitions.ParadigmStartMarker: Result.ParadigmStartTime = sessionTime; ParadigmStarted = true; SpellerController.Start(); HintButton(); break; case MarkerDefinitions.ParadigmEndMarker: Result.ParadigmEndTime = sessionTime; break; case MarkerDefinitions.TrialStartMarker: { var trial = new SsvepTrial { TargetFrequencyIndex = HintedButton?.State }; var activedButtons = _activedButtons = UpdateCursor(GazePointHandler.CurrentPosition); if (activedButtons != null) { var buttons = new LinkedList <SpellerParadigm.Result.Button>(); foreach (var activedButton in activedButtons) { if (activedButton != null) { buttons.AddLast(new SsvepButton(activedButton.Key, activedButton.State)); } } trial.ActivedButtons = buttons; } trial.StartTime = CurrentTime; _trial = trial; if (_hybridSsvepIdentifier != null) { _hybridSsvepIdentifier.IsActive = true; } SelectedButton = null; DisplayText = null; TrialCancelled = false; break; } case MarkerDefinitions.TrialEndMarker: { var hintButton = HintedButton; if (Paradigm.Config.Test.AlwaysCorrectFeedback) { SelectedButton = hintButton; SelectionFeedbackCorrect = true; } HintButton(TrialCancelled ? 1 : 2); var trial = _trial; _trial = null; trial.Cancelled = TrialCancelled; trial.EndTime = CurrentTime; if (_hybridSsvepIdentifier != null) { _hybridSsvepIdentifier.IsActive = false; } if (!trial.Cancelled && ComputeTrialResult(_activedButtons, _hybridSsvepIdentifier == null ? null : (Func <IdentificationResult>)_hybridSsvepIdentifier.Identify, hintButton, out var button, out var correct)) { trial.Correct = correct; if (button != null) { trial.SelectedFrequencyIndex = button.State; trial.SelectedButton = new SsvepButton(button.Key, button.State); } else if (!Paradigm.Config.Test.AlwaysCorrectFeedback) { SystemSounds.Exclamation.Play(); } } CheckStop(); Result.Trials.Add(trial); TrialTrigger?.Reset(); break; } } } }