Skip to content

Commit 5fd637e

Browse files
committed
Updating reaction test adding between attempts implementation in exposition and altering fixpoint to just a flash
1 parent 4735aac commit 5fd637e

File tree

7 files changed

+109
-28
lines changed

7 files changed

+109
-28
lines changed

StroopTest/Models/Tests/Program.cs

+11-1
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,17 @@ public static void writeOutputFile(string filepath, string outContent)
390390
}
391391
}
392392

393-
393+
public static bool hasFixPoint(string fixpoint)
394+
{
395+
if(fixpoint.Equals("+") || fixpoint.Equals("o"))
396+
{
397+
return true;
398+
}
399+
else
400+
{
401+
return false;
402+
}
403+
}
394404

395405
}
396406
}

StroopTest/Models/Tests/Reaction/ReactionProgram.cs

+15-8
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ class ReactionProgram : Program
2222
private bool sstInterval; // interval calculated according to stop signal test
2323
private int intervalBetweenAttempts;
2424
private static Int32 ELEMENTS = 27; //quantity of fields used in ReactionProgram
25+
public static string[] responseTimeType = { "Antecipação", "Durante exposição", "Após exposição", "Sem resposta"};
26+
public static int ANTECIPATION = 0;
27+
public static int DURING_EXPOSITION = 1;
28+
public static int AFTER_EXPOSITION = 2;
29+
public static int NO_RESPONSE = 3;
2530

2631
public ReactionProgram()
2732
{
@@ -60,7 +65,7 @@ public ReactionProgram(string programName, int expositionTime, int numExposition
6065
this.NumberPositions = numberPositions;
6166
this.hasColorList = hasColorList;
6267
this.SstInterval = sstInterval;
63-
this.intervalBetweenAttempts = intervalBetweenAttempts;
68+
this.IntervalBetweenAttempts = intervalBetweenAttempts;
6469

6570
if(!hasColorList)
6671
{
@@ -114,7 +119,7 @@ public ReactionProgram(string programName, int expositionTime, int numExposition
114119
this.setWordListFile(wordList);
115120
this.hasColorList = hasColorList;
116121
this.SstInterval = sstInterval;
117-
this.intervalBetweenAttempts = intervalBetweenAttempts;
122+
this.IntervalBetweenAttempts = intervalBetweenAttempts;
118123

119124
if (!hasColorList)
120125
{
@@ -168,7 +173,7 @@ public ReactionProgram(string programName, int expositionTime, int numExposition
168173
this.hasColorList = false;
169174
this.ExpandImage = expandImage;
170175
this.SstInterval = sstInterval;
171-
this.intervalBetweenAttempts = intervalBetweenAttempts;
176+
this.IntervalBetweenAttempts = intervalBetweenAttempts;
172177

173178
//default configurations for first version of ReactionProgram
174179
this.setAudioListFile("false");
@@ -213,7 +218,7 @@ public ReactionProgram(string programName, int expositionTime, int numExposition
213218
this.FontSize = fontSize;
214219
this.ExpandImage = expandImage;
215220
this.SstInterval = sstInterval;
216-
this.intervalBetweenAttempts = intervalBetweenAttempts;
221+
this.IntervalBetweenAttempts = intervalBetweenAttempts;
217222

218223
if (!hasColorList)
219224
{
@@ -263,7 +268,7 @@ public ReactionProgram(string programName, int expositionTime, int numExposition
263268

264269
this.ResponseType = responseType;
265270
this.NumberPositions = numberPositions;
266-
this.intervalBetweenAttempts = intervalBetweenAttempts;
271+
this.IntervalBetweenAttempts = intervalBetweenAttempts;
267272
this.hasColorList = hasColorList;
268273
if (!hasColorList)
269274
{
@@ -315,7 +320,7 @@ public ReactionProgram(string programName, int expositionTime, int numExposition
315320
this.ResponseType = responseType;
316321
this.NumberPositions = numberPositions;
317322
this.ExpandImage = expandImage;
318-
this.intervalBetweenAttempts = intervalBetweenAttempts;
323+
this.IntervalBetweenAttempts = intervalBetweenAttempts;
319324
//default configurations for image with audio version of ReactionProgram
320325
this.fontSize = 10;
321326
this.setColorListFile("false");
@@ -517,6 +522,8 @@ public bool SstInterval
517522
}
518523
}
519524

525+
public int IntervalBetweenAttempts { get => intervalBetweenAttempts; set => intervalBetweenAttempts = value; }
526+
520527
public static string GetReactionPath()
521528
{
522529
return FileManipulation.ReactionTestFilesPath;
@@ -587,7 +594,7 @@ public string data()
587594
this.FontSize + " " +
588595
this.ExpandImage + " " +
589596
this.SstInterval + " " +
590-
this.intervalBetweenAttempts.ToString();
597+
this.IntervalBetweenAttempts.ToString();
591598
return data;
592599
}
593600

@@ -643,7 +650,7 @@ public void readProgramFile(string filepath)
643650
FontSize = int.Parse(config[23]);
644651
expandImage = bool.Parse(config[24]);
645652
SstInterval = bool.Parse(config[25]);
646-
intervalBetweenAttempts = int.Parse(config[26]);
653+
IntervalBetweenAttempts = int.Parse(config[26]);
647654

648655
string[] linesInstruction = File.ReadAllLines(filepath);
649656
if (linesInstruction.Length > 1) // read instructions if any

StroopTest/Models/Tests/Reaction/ReactionTest.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,12 @@ private string expositionTypeOutput()
125125
}
126126

127127
public void writeLineOutput(long intervalTime, long intervalShouldBe, long reactTime, int currentExposition, long expositionAccumulative,
128-
string[] currentLists, string[] currentStimuli, string position, bool beeped, string currentColor)
128+
string[] currentLists, string[] currentStimuli, string position, bool beeped, string currentColor, string currentResponseTimeType)
129129
{
130130
/* This variable keeps data from an exposition to only one stimulus, being them:
131-
* programa\tparticipante\tdata\thorarioInicial\thorarioExposicao\ttr(ms)\tintervalo(ms)\tintervaloestimado(ms)\texposicaoTempo(ms)\texposicao(ms)\tsequencia\tpos\trespostaUsuario\ttipoEstimulo\tEstimulo\tCordoEstimulo\tBeep
132-
* program\tparticipant\tdate\tInitialDate\texpositionTime\treactionTime(ms)\tInterval(ms)\testimatedInterval(ms)\texpositionDuration(ms)\texposition(ms)\tsenquency\tpos\tuserResponse\tstimulusType\tstimulus\tstimulusColor\tBeep
133-
* program name participant name date hour exposition hour hit time(ms) interval(ms) interval should be(ms)
131+
* programa\tparticipante\tdata\thorarioInicial\thorarioExposicao\tTipodeResposta\ttr(ms)\tintervalo(ms)\tintervaloestimado(ms)\texposicaoTempo(ms)\texposicao(ms)\tsequencia\tpos\trespostaUsuario\ttipoEstimulo\tEstimulo\tCordoEstimulo\tBeep
132+
* program\tparticipant\tdate\tInitialDate\texpositionTime\tResponseType\treactionTime(ms)\tInterval(ms)\testimatedInterval(ms)\texpositionDuration(ms)\texposition(ms)\tsenquency\tpos\tuserResponse\tstimulusType\tstimulus\tstimulusColor\tBeep
133+
* program name participant name date hour exposition hour response time type hit time(ms) interval(ms) interval should be(ms)
134134
* exposition accumulative timeexposition time(ms) number of sequency position on screen user response type of stimulus stimulus1List stimulus1
135135
* stimulus2List stimulus2
136136
* stimulus color */
@@ -139,7 +139,7 @@ public void writeLineOutput(long intervalTime, long intervalShouldBe, long react
139139
currentParticipant[1] + "\t" + initialDate.Day + "/" +
140140
initialDate.Month + "/" + initialDate.Year + "\t" + initialDate.Hour + ":" + initialDate.Minute +
141141
":" + initialDate.Second + ":" + initialDate.Millisecond.ToString() + "\t" + ExpositionTime.Hour + ":" + ExpositionTime.Minute +
142-
":" + ExpositionTime.Second + ":" + ExpositionTime.Millisecond.ToString() + "\t" + reactTime.ToString() +
142+
":" + ExpositionTime.Second + ":" + ExpositionTime.Millisecond.ToString() + "\t" + currentResponseTimeType + "\t" + reactTime.ToString() +
143143
"\t" + intervalTime.ToString() + "\t" + intervalShouldBe.ToString() + "\t" + expositionAccumulative + "\t" +
144144
ProgramInUse.ExpositionTime + "\t" + currentExposition + "\t" + position + "\t" + CurrentResponse + "\t"+ expositionTypeOutput() + "\t" +
145145
currentLists[0] + "\t" + currentStimuli[0] + "\t"+ currentLists[1] + "\t" + currentStimuli[1] + "\t" + currentColor + "\t" + beeped.ToString();

StroopTest/Resources/Localizations/LocalizedResources.en-US.resx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1068,7 +1068,7 @@ To upgrade, the new version installation file must be run in the same folder as
10681068
<value>wasn't written\n\n</value>
10691069
</data>
10701070
<data name="reactionTestHeader" xml:space="preserve">
1071-
<value>program\t#\tparticipant\tdate\tInitial Time\tExposition time\tReactionTime(ms)\tInterval(ms)\tEstimated Interval(ms)\tExposition Duration(ms)\tExposition(ms)\tsenquency\tpos\tUser response\tList1\tStimulus1\tList2\tStimulus2 Type\tstimulus\tStimulus Color\tBeep</value>
1071+
<value>program\t#\tparticipant\tdate\tInitial Time\tExposition time\tResponse Type\tReaction Time(ms)\tInterval(ms)\tEstimated Interval(ms)\tExposition Duration(ms)\tExposition(ms)\tsenquency\tpos\tUser response\tList1\tStimulus1\tList2\tStimulus2 Type\tstimulus\tStimulus Color\tBeep</value>
10721072
</data>
10731073
<data name="responseTypeError" xml:space="preserve">
10741074
<value>Selected response type is invalid. Valid options are: spacebar or key arrows.</value>

StroopTest/Resources/Localizations/LocalizedResources.pt-BR.resx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1298,7 +1298,7 @@ https://github.com/lab-neuro-comp/Test-Platform</value>
12981298
<value>não foi escrito\n\n</value>
12991299
</data>
13001300
<data name="reactionTestHeader" xml:space="preserve">
1301-
<value>Programa\t#\tParticipante\tData\tHorário inicial\tHorário exposição\tTR(ms)\tIntervalo(ms)\tIntervalo estimado(ms)\tExposição tempo(ms)\tExposicao(ms)\tSequência\tPosição\tResposta usuário\tTipo estímulo\tLista1\tEstímulo1\tLista2\tEstímulo2\tCor do estímulo\tBeep</value>
1301+
<value>Programa\t#\tParticipante\tData\tHorário inicial\tHorário exposição\tTipo de Resposta\tTR(ms)\tIntervalo(ms)\tIntervalo estimado(ms)\tExposição tempo(ms)\tExposicao(ms)\tSequência\tPosição\tResposta usuário\tTipo estímulo\tLista1\tEstímulo1\tLista2\tEstímulo2\tCor do estímulo\tBeep</value>
13021302
</data>
13031303
<data name="responseTypeError" xml:space="preserve">
13041304
<value>Tipo de resposta selecionado inválido. As opções válidas são: barra de espaço ou setas.</value>

StroopTest/Views/ReactionPages/FormReactExposition.cs

+75-12
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public partial class FormReactExposition : Form
3838
private long expositionAccumulative;
3939
private Stopwatch hitStopWatch = new Stopwatch();
4040
private Stopwatch accumulativeStopWatch = new Stopwatch();
41+
private Stopwatch betweenAttemptsStopWatch = new Stopwatch();
4142
private bool intervalCancelled;
4243
private bool cancelExposition = false;
4344

@@ -55,14 +56,15 @@ public partial class FormReactExposition : Form
5556
private System.Windows.Forms.Label wordLabel = new System.Windows.Forms.Label();
5657

5758
private bool exposing = false;
59+
private bool between = false;
5860
private string[] currentStimuli = {"-", "-" };
5961
private string[] currentLists = { "-", "-" };
6062
private int currentPosition;
6163
private string currentPositionOutput;
6264
private bool currentBeep = false;
6365
private string currentColor = "false";
6466
private int currentExposition = 0;
65-
67+
private long fixPointTime = 100;
6668
private ResourceManager LocRM = new ResourceManager("TestPlatform.Resources.Localizations.LocalizedResources", typeof(FormMain).Assembly);
6769
private CultureInfo currentCulture = CultureInfo.CurrentUICulture;
6870

@@ -368,7 +370,12 @@ private int waitIntervalTime(bool isWaitTimeRandom, int waitTime)
368370

369371
Stopwatch intervalStopWatch = new Stopwatch();
370372
intervalStopWatch.Start();
371-
while (intervalStopWatch.ElapsedMilliseconds < intervalTimeRandom)
373+
long interval = intervalTimeRandom;
374+
if (Program.hasFixPoint(executingTest.ProgramInUse.FixPoint))
375+
{
376+
interval = intervalTimeRandom - fixPointTime;
377+
}
378+
while (intervalStopWatch.ElapsedMilliseconds < interval)
372379
{
373380
if (expositionBW.CancellationPending)
374381
{
@@ -377,6 +384,20 @@ private int waitIntervalTime(bool isWaitTimeRandom, int waitTime)
377384
}
378385
/* just wait for interval time to be finished */
379386
}
387+
ExpositionController.makingFixPoint(executingTest.ProgramInUse.FixPoint, executingTest.ProgramInUse.FixPointColor,
388+
this);
389+
if (Program.hasFixPoint(executingTest.ProgramInUse.FixPoint))
390+
{
391+
while (intervalStopWatch.ElapsedMilliseconds < intervalTimeRandom)
392+
{
393+
if (expositionBW.CancellationPending)
394+
{
395+
intervalCancelled = true;
396+
break;
397+
}
398+
/* just wait for interval time to be finished */
399+
}
400+
}
380401
intervalShouldBe = intervalTimeRandom;
381402
intervalStopWatch.Stop();
382403
int elapsedTime = (int)intervalStopWatch.ElapsedMilliseconds;
@@ -615,13 +636,20 @@ private void expositionBW_DoWork(object sender, DoWorkEventArgs e)
615636
expositionAccumulative = accumulativeStopWatch.ElapsedMilliseconds;
616637
hitStopWatch = new Stopwatch();
617638
hitStopWatch.Start();
618-
639+
between = false;
619640
// Sending mark to neuronspectrum to sinalize that exposition of stimulus started
620641
SendKeys.SendWait(executingTest.Mark.ToString());
621642
executingTest.ExpositionTime = DateTime.Now;
643+
try
644+
{
645+
showStimulus();
646+
}
647+
catch (Exception)
648+
{
649+
650+
}
651+
622652

623-
showStimulus();
624-
625653
if (intervalCancelled)
626654
{
627655
e.Cancel = true;
@@ -646,6 +674,34 @@ private void expositionBW_DoWork(object sender, DoWorkEventArgs e)
646674
/* just wait for exposition time to be finished */
647675
}
648676
}
677+
between = true;
678+
if (Player.SoundLocation != null)
679+
{
680+
Player.Stop();
681+
Player = new SoundPlayer();
682+
}
683+
// cleaning screen
684+
if (ActiveForm != null)
685+
{
686+
this.CreateGraphics().Clear(ActiveForm.BackColor);
687+
688+
}
689+
betweenAttemptsStopWatch = new Stopwatch();
690+
betweenAttemptsStopWatch.Start();
691+
692+
while (betweenAttemptsStopWatch.ElapsedMilliseconds < executingTest.ProgramInUse.IntervalBetweenAttempts)
693+
{
694+
if (expositionBW.CancellationPending)
695+
{
696+
betweenAttemptsStopWatch.Stop();
697+
e.Cancel = true;
698+
break;
699+
}
700+
else
701+
{
702+
/* just wait for between expositions time to be finished */
703+
}
704+
}
649705
}
650706

651707
if (Player.SoundLocation != null)
@@ -683,32 +739,41 @@ private void expositionBW_RunWorkerCompleted(object sender, RunWorkerCompletedEv
683739
intervalBW.ReportProgress(50, currentControl);
684740
}
685741
}
686-
ExpositionController.makingFixPoint(executingTest.ProgramInUse.FixPoint, executingTest.ProgramInUse.FixPointColor, this);
687742
}
688743
else
689744
{
690745
/*do nothing*/
691746
}
692747

748+
if((e.Cancelled) == true && between)
749+
{
750+
/* user clicked after stimulus disappeared */
751+
between = false;
752+
executingTest.writeLineOutput(intervalElapsedTime, intervalShouldBe, betweenAttemptsStopWatch.ElapsedMilliseconds,
753+
currentExposition + 1, expositionAccumulative, currentLists, currentStimuli, currentPositionOutput, currentBeep, currentColor,
754+
ReactionProgram.responseTimeType[ReactionProgram.AFTER_EXPOSITION]);
755+
}
693756
if ((e.Cancelled == true) && !intervalCancelled)
694757
{
695758
/* user clicked after stimulus is shown*/
696759
executingTest.writeLineOutput(intervalElapsedTime, intervalShouldBe, hitStopWatch.ElapsedMilliseconds,
697-
currentExposition + 1, expositionAccumulative, currentLists,currentStimuli, currentPositionOutput, currentBeep, currentColor);
760+
currentExposition + 1, expositionAccumulative, currentLists,currentStimuli, currentPositionOutput, currentBeep, currentColor,
761+
ReactionProgram.responseTimeType[ReactionProgram.DURING_EXPOSITION]);
698762
}
699-
700763
else if ((e.Cancelled == true) && intervalCancelled)
701764
{
702765
/* user clicked before stimulus is shown*/
703766
executingTest.writeLineOutput(intervalElapsedTime, intervalShouldBe, intervalElapsedTime - intervalShouldBe,
704-
currentExposition + 1, expositionAccumulative, currentLists, currentStimuli, currentPositionOutput, currentBeep, currentColor);
767+
currentExposition + 1, expositionAccumulative, currentLists, currentStimuli, currentPositionOutput, currentBeep, currentColor,
768+
ReactionProgram.responseTimeType[ReactionProgram.ANTECIPATION]);
705769
}
706770
else
707771
{
708772
/* user missed stimulus */
709773
executingTest.CurrentResponse = "NA";
710774
executingTest.writeLineOutput(intervalElapsedTime, intervalShouldBe, 0, currentExposition + 1, expositionAccumulative, currentLists, currentStimuli,
711-
currentPositionOutput, currentBeep, currentColor);
775+
currentPositionOutput, currentBeep, currentColor,
776+
ReactionProgram.responseTimeType[ReactionProgram.NO_RESPONSE]);
712777
hitStopWatch.Stop();
713778
}
714779
expositionBW.Dispose();
@@ -721,8 +786,6 @@ private void intervalBW_DoWork(object sender, DoWorkEventArgs e)
721786

722787
for (int counter = 0; counter < executingTest.ProgramInUse.NumExpositions && !cancelExposition; counter++)
723788
{
724-
ExpositionController.makingFixPoint(executingTest.ProgramInUse.FixPoint, executingTest.ProgramInUse.FixPointColor,
725-
this);
726789
currentExposition = counter;
727790
//preparing execution
728791
expositionBackground();

StroopTest/Views/ReactionPages/FormTRConfig.cs

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ private void editProgram()
5353
numExpo.Value = editProgram.NumExpositions;
5454
expoTime.Value = editProgram.ExpositionTime;
5555
intervalTime.Value = editProgram.IntervalTime;
56+
intervalBetweenAttempts.Value = editProgram.IntervalBetweenAttempts;
5657
beepingCheckbox.Checked = editProgram.IsBeeping;
5758
beepDuration.Value = editProgram.BeepDuration;
5859
stimuluSize.Value = (decimal) editProgram.StimuluSize;

0 commit comments

Comments
 (0)