PennController for IBEX › Forums › Support › How do I add a short experiment trial before the actual experiment?
Tagged: experiment, trial
- This topic has 4 replies, 3 voices, and was last updated 3 years, 8 months ago by Jeremy.
-
AuthorPosts
-
March 30, 2021 at 11:16 pm #6789uppsalasParticipant
Hello, I’m trying to add a short trial so the people taking the test can first get the hang of it. For some reason my code just goes straight to the actual experiment and I don’t understand why. This is the code:
PennController.ResetPrefix(null); // Shorten command names (keep this line here)) // DebugOff() // Uncomment this line only when you are 100% done designing your experiment // Instructions scree newTrial("instructions", // Automatically print all Text elements, centered defaultText.center().print() , newText("Bienvenido") , newText("En este experimento, verás una palabra escrita en un color determinado.") , // Note: the \ character allows you to continue the string on the next line newText("<strong><p> Tu tarea es presionar la tecla que corresponde con el color en el que está escrito la palabra.</p>\ <p>Por ejemplo, si la palabra 'casa' tiene color rojo, debes presionar la tecla que corresponde con este color.</p>\ \ </strong>") , newText("<p>Presione la tecla <strong>Z</strong> si el color de la palabra es rojo.</p>\ <p>Presione la tecla <strong>N</strong> si el color de la palabra es azul.</p>\ <p>Presione la tecla <strong>M</strong> si el color de la palabra es verde.</p>") , newButton("Presione aquí para realizar una prueba del experimento") .center() .print() .wait() // Finish this trial only when the button is clicked ) PennController.Sequence("instructions", randomize("experimental-trial2") , "send" ); Template( "trial2.csv" , row => newTrial ("experimental-trial2" , defaultText.center() // Horizontally center all Text elements automatically , newText("word", row.Word) // Show the text from the 'Word' column .color(row.Color) // Color the text as specified in the 'FontColor' column .css("font-size", "24pt") // Increase the font size .log() // Reports when the Text is displayed in the results file .print() , newKey("keypress", "znm") .log() // Reports when the key is pressed in the results file .wait() , // Wait 1s before moving to the next trial newTimer(500).start().wait() ) .log( "word" , row.Word ) // Append the value of 'Word' at the end of the results lines .log( "color" , row.Color ) // Append the value of 'FontColor' at the end of the results lines .log( "correct" , row.Key ) // Append the value of 'CorrectKey' at the end of the results lines ) newTrial("instructions2", // Automatically print all Text elements, centered defaultText.center().print() , newText("Bienvenido nuevamente") , newText("Ahora realizaremos el experimento.") , // Note: the \ character allows you to continue the string on the next line newText("<strong><p> Recuerda que tu tarea es presionar la tecla que corresponde con el color en el que está escrito la palabra.</p>\ <p>Por ejemplo, si la palabra 'casa' tiene color rojo, debes presionar la tecla que corresponde con este color.</p>\ \ </strong>") , newText("<p>Presione la tecla <strong>Z</strong> si el color de la palabra es rojo.</p>\ <p>Presione la tecla <strong>N</strong> si el color de la palabra es azul.</p>\ <p>Presione la tecla <strong>M</strong> si el color de la palabra es verde.</p>") , newButton("Presione aquí para empezar el experimento") .center() .print() .wait() // Finish this trial only when the button is clicked ) // Experimental trials: generate trials using the values from StroopTable.csv PennController.Sequence("instructions", randomize("experimental-trial") , "send" ); Template( "StroopTable.csv" , row => newTrial ("experimental-trial" , defaultText.center() // Horizontally center all Text elements automatically , newText("word", row.Word) // Show the text from the 'Word' column .color(row.Color) // Color the text as specified in the 'FontColor' column .css("font-size", "24pt") // Increase the font size .log() // Reports when the Text is displayed in the results file .print() , newKey("keypress", "znm") .log() // Reports when the key is pressed in the results file .wait() , // Wait 1s before moving to the next trial newTimer(500).start().wait() ) .log( "word" , row.Word ) // Append the value of 'Word' at the end of the results lines .log( "color" , row.Color ) // Append the value of 'FontColor' at the end of the results lines .log( "correct" , row.Key ) // Append the value of 'CorrectKey' at the end of the results lines ) SendResults() // Send the results // Final screen newTrial( newText("Gracias por participar!") .center() .print() , // This link a placeholder: replace it with a URL provided by your participant-pooling platform newText("<a href='https://www.pcibex.net/' target='_blank'>Click here to validate your submission</a>") .center() .print() , // Trick: wait here forever newButton().wait() ) .setOption("countsForProgressBar",false) // This is not a "real" trial
Any help so that the first trial can work would be appreciated!
March 31, 2021 at 3:20 am #6790amilamParticipantHi,
The experiment looks good. However, you should put this line of the code:
PennController.Sequence("instructions", randomize("experimental-trial2") , "send" );
before the first trial, not after it.
The sequence needs to be defined before the trials.
Let me know if it works.
If you have any further questions, let me know!March 31, 2021 at 10:42 am #6791JeremyKeymasterHi,
The problem does come from the
Sequence
command indeed, although you can actually use it wherever you want, it does not matter to PennController.*There are a couple problematic aspects. First, you have two
Sequence
commands: the first one references trials labeled"experiment-trial2"
, the second one references trials labeled"experiment-trial"
. The secondSequence
command overrides the first one, which is why the trials labeled"experiment-trial2"
(presumably the ones you mean to run before the full experiment) end up not being included in your experiment run.Second, both your
Sequence
commands also reference trials labeled"instructions"
and"send"
. However, one trial that you create is labeled"instructions2"
, so that one simply won’t be included in your experiment run. Moreover, there is no trial explicitly labeled"send"
: although it’s pretty clear to us humans that you want to include the trial generated by yourSendResults()
command, the program won’t just infer that, so you should explicitly label that trial by usingSendResults("send")
instead.Finally, you should also label your very last trial (“final screen”) and reference the label after
"send"
in theSequence
command, so that your final screen is indeed included as the very last screen in your experiment (after the results have been sent)Let me know if you have questions
Jeremy
* The only constraint is, if you use the prefix-less
Sequence
instead ofPennController.Sequence
, it must come afterPennController.ResetPrefix(null)
March 31, 2021 at 1:37 pm #6792uppsalasParticipantPerfect, thanks to your explanation now it works!
Would you happen to know how to add something to measure the time response for each word? That’s one of the variables I need to measure (reaction time of decision when clicking key).
Thanks in advance!
March 31, 2021 at 1:52 pm #6793JeremyKeymasterI’m not sure what you mean: you’re already logging the Key element, and the printing of the Text element is the first thing that happens in the trial, so you get the response time by subtracting the event time in the result line for the trial’s start, from the event time in the result line for the Key element
Jeremy
-
AuthorPosts
- You must be logged in to reply to this topic.