PennController for IBEX › Forums › Support › Cannot get the template function to loop over my experiment
- This topic has 6 replies, 2 voices, and was last updated 1 year, 5 months ago by Jeremy.
-
AuthorPosts
-
April 10, 2023 at 2:15 pm #10437XiangyuParticipant
Hi Jeremy,
Hope you are doing well!
I developed an experiment script for my image priming study. Nevertheless, despite numerous attempts to fix the invisible elements for images, experiment items, and response sentences, I am unable to determine why my script can only be compiled for the commencement of the experiment though I stated the sequence of the whole experiment.
To provide a concise overview of my experiment, it consists of 52 trials, divided into 4 blocks of 13 trials each. I want the PCIBEX to randomise the blocks based on the block number. This is the structure of the experiment, and the structure of the trial is as follows:
a picture as priming for 600 milliseconds;
displaying a target sentence for 2100 milliseconds;
letting participants choose one sentence from two sentences displaying side-by-side, with the requirement of selecting the sentence that most closely matches the meaning of the previous sentence,
with a one-second interval between each trial.To generate a random block display in PCIbex, I initially attempted the templates() function; however, it did not work. I then added the array(…, fill(function, and here is an example:
newLoop(“trialLoop”, shuffle( …new Array(4).fill( newSeq(“block”, shuffle( …new Array(13).fill(
where I wanted to creates an array of 4 elements to represent the 4 blocks.There could be problems with my “sentences.csv” file, but I did not find warnings on that issue. I’ve check your two post regrading the partial selection function (like split all sentences into halves and randomly select from the two halves) but they are more advanced topics for my experiment.
My experiment can be found here: https://farm.pcibex.net/r/DPBdME/
Very looking forward to your reply! Just getting so stuck with the progress of my experiment.
Best regards & Worried,
XiangyuApril 12, 2023 at 7:07 am #10442JeremyKeymasterThis question was answered via email, but posting the suggested code here for the sake of future readers:
Template("sentences.csv",variable => newTrial("block"+variable.BlockNum, newTimer("break", 1000).start().wait() , newImage("im",variable.PictureFile).size(400, 400).print() , newTimer("image-item", 600).start().wait() , newText("ts", variable.TargetSentence).center().print() , newTimer("item", 2100).start().wait() , newText("response", variable.ResponseSentence1 + " or " + variable.ResponseSentence2).center().print() , newKey("keypress", "FJ").log().wait() ) ) // ... blocks = [randomize('block1'),randomize('block2'),randomize('block3'),randomize('block4')] fisherYates(blocks) // Ibex-internal function that shuffles an array Sequence("consent","welcome", "instructions", ...blocks, SendResults(), "goodbye")
Jeremy
April 12, 2023 at 7:56 am #10444XiangyuParticipantHi Jeremy,
Thank you so much for pointing me to the fisherYates()! It works with the experiment structure and now I have all elements displayed in between the Introduction and Goodbye.
I have another experiment-related query regarding how to make images and text invisible after 600 and 2100 milliseconds of delay for printing out. Therefore, I would like to set the display time of the image to 600 milliseconds and then print the TargetSentence visible for 2100 milliseconds, so that when participants are selecting a sentence, they cannot see preceding elements.
I searched the documentation with the keyword “invisible” and “remove” but the description does not have interaction with the Timer. In summary, I have two questions as follows:
How can I display an image for only 600 ms and then make it disappear?
What is the best way to make a TargetSentence visible for 2100 ms and then hide it from participants?All the best,
XiangyuApril 12, 2023 at 8:35 am #10445XiangyuParticipantHi Jeremy,
I figured out my questions in using getX(). remove().
However, I found a more severe problem. After the adoption of
blocks = [randomize('block1'),randomize('block2'),randomize('block3'),randomize('block4')]; fisherYates(blocks); // Ibex-internal function that shuffles an array Sequence("consent","welcome", "instructions", "blocks",SendResults(), "goodbye");
The display of pictures and sentences are sometimes inconsistent. For example, PCIbex may picture from select the second row and show a sentence is not from second row. I would like the script only allows shuffling blocks and randomize the within-block trials sequences as per the row. PCIbex seems to shuffle too much across the rows.
Best,
XiangyuApril 12, 2023 at 6:36 pm #10447XiangyuParticipantThis part is solved:
“The display of pictures and sentences are sometimes inconsistent. For example, PCIbex may picture from select the second row and show a sentence is not from second row. I would like the script only allows shuffling blocks and randomize the within-block trials sequences as per the row. PCIbex seems to shuffle too much across the rows.”April 13, 2023 at 5:25 am #10448XiangyuParticipantHi Jeremy,
I have some other questions regarding to the logging participants’ correct response. In my experiment, say I included an additional column “CorrectResp” coding all correct response as “F” or “J”, and I would like to compare this column with participants’ key response. Can I use Javascript to do this? Here is my draft for checking the accuracy of keypress:
newKey("keypress", "FJ") .log() .wait(function() { // Get the participant's response var response = this.keys; // Get the correct response from the CSV file var correctResponse = variable.CorrectResponse; // Check whether the participant's response matches the correct response if (response === correctResponse) { // Log a correct response log("CorrectResponse", 1); } else { // Log an incorrect response log("CorrectResponse", 0); } })
I searched the forum and documentation, and find test.pressed() seems to be okay, but I have no idea how to make the function automatically compare the response from participants with the pre-logged correct response in “sentences.csv” file.
Thanks a lot for your kind help!
April 13, 2023 at 5:39 am #10449JeremyKeymasterHi Xiangyu,
You cannot use a javascript function in that
wait
command: documentation, source code. Since that’s not supported, you cannot assume thatthis.keys
will return a key that was pressedNeither Ibex nor PennController define a global JavaScript
log
function. PennController hasnewTrial().log
and element-specificlog
commandsIf you want to add a column to the rows of this trial that will report whether the pressed key was correct, you can use a global Var element:
newTrial( // ... newVar("Correct", 0).global(), // ... newKey("keypress", "FJ") .log() .wait() .test.pressed( variable.CorrectResponse ) // assuming that CorrectResponse in the table is either F or J .success( getVar("Correct").set(1) ) , // ... ) .log( "CorrectResponse" , getVar("Correct") )
Jeremy
-
AuthorPosts
- You must be logged in to reply to this topic.