Forum Replies Created
-
AuthorPosts
-
xkyan
ParticipantHi Jeremy,
Thanks for the previous answers! Here’s a follow-up:
I tried to reorganize my materials and correct my codes as following. But the Sequence controller did not work (my guess) so I can’t present trials in the order I want.
PennController.ResetPrefix(null) // DebugOff() // function ---------------------------------- const nRandomIntsToSum = (length,minInt,maxInt,targetSum) => { const a = []; for (let i=0; i<length; i++) { let min = minInt, max = maxInt, remainder = targetSum-(a.reduce((x,y)=>x+y,0)+min*(length-(i+1))); if (remainder < maxInt) max = remainder; a.push( min+Math.round(Math.random()*(max-min)) ); } fisherYates(a); return a; } const pic = row => [ // set a fixation newText("fixation1", "+") .css("font-size","50px") .print("center at 50%" , "center at 50%") .log() , newTimer("fixtime1",500).start().wait() , getText("fixation1").remove() , // set the picture stimuli newImage("pic", row.flan_file).size(720, 405).print() , newCanvas("canvas_pic",720,405) .add( 0, 0, getImage("pic")) .center().print() , // start recording RT getVar("RT1").global().set( v => Date.now() ) , // set key response newKey("flan_RespKey", "FJ") .log("flan_RespKey", getKey("flan_RespKey")) .wait() .callback( getVar("RT1").set( v => Date.now() - v ) .log( "flanRT" , getVar("RT1") ) ) , // record RT getVar("RT1").set( v => Date.now() - v ) .log( "flanRT" , getVar("RT1") ) , // clear the screen getCanvas("canvas_pic").remove() ]; const spr = row => [ // set a fixation newText("fixation2", "+") .css("font-size","50px") .print("center at 50%" , "center at 50%") .log() , newTimer("fixtime2",500).start().wait() , getText("fixation2").remove() , // set the spr stimuli newController("DashedSentence", {s: row.sent_cont}) .print() .log() .wait() .remove() , // start recording RT getVar("RT2").global().set( v => Date.now() ) , newController("Question", {q: "这句话合理吗?", as: [["F","合理"], ["J","不合理"]], hasCorrect: parseInt(row.sentCorr), randomOrder: false}) .print() .log() .wait() .remove() , // record RT getVar("RT2").set( v => Date.now() - v ) .log( "sentRT" , getVar("RT2") ) ]; // Main -------------------------- // Instructions newTrial("instructions", defaultText .cssContainer({"margin-bottom":"1em"}) .center() .print() , newText("instructions-1", "Welcome!") , newText("instructions-2", "In this experiment, you will hear and read a sentence, and see two images.") , newText("instructions-3", "<b>Select the image that better matches the sentence:</b>") , newText("instructions-4", "Press the <b>F</b> key to select the image on the left.<br>Press the <b>J</b> key to select the image on the right.<br>You can also click on an image to select it.") , newTextInput("input_ID") .cssContainer({"margin-bottom":"1em"}) .center() .print() , newButton("wait", "Click to start the experiment") .center() .print() .wait() , newVar("ID") .global() .set(getTextInput("input_ID")) ) // Define the template for target trials (完成,没问题) Template("items-targets.csv", row => newTrial("targets", newVar("RT1").global().set("0"), newVar("RT2").global().set("0"), pic(row) , spr(row) ) ) // Define the template for filler trials Template("items-fillers-flan.csv", row => newTrial("fillers", pic(row) ) ) Template("items-fillers-spr.csv", row => newTrial("fillers", spr(row) ) ) targets = randomize("targets") fillers = randomize("fillers") repetitions = nRandomIntsToSum(60,1,3,120) Sequence( "instructions", repetitions.map(n=>[ pick(targets,1),pick(fillers,n) ]).flat() ) // Sequence("instructions", randomize("targets")) // Sequence("instructions", "targets")
However, I found that when I ran it, it would go over with the Template order I coded (i.e. all targets in the sequential order as in the csv file, then the filler-flan, then the filler-spr) and the Sequence controller seems not work at all. Here are some other observations I hope to share with you while attempting to debug:
1. I tried to change the order of Template and the presented order during experiment changed correspondingly, which proved that the Sequence controller indeed did not work and it went with the order of the Template. It makes sense after checking the doc because I found that the function of Template is generating trials so the trials are presented once they are generated.
2. I tried to change the Sequence to see which part of Sequence can work. For example, I triedSequence("instructions", "fillers", randomize("targets"))
and it worked! So I guess there might be something wrong with my current Sequence design so it failed to work and therefore the experiment just went with the sequential order of Templates. But after checking.map
and.flat
, I still didn’t find where the bug is in this line.Could you please help me figure out why it fails? I’ve been stuck here for quite a long time which is frustrating 🙁 I really appreciate your help! Thanks in advance.
xkyan
ParticipantOhhh! I finally understand how it works! Thank you a lot Jeremy! 🙂
xkyan
ParticipantHi Jeremy,
Here’s a following question I have. I found that there’s something wrong with my
hasCorrect:row.Corr
because everytime I included it, the whole question would disappear when running. I suppose it might be because of inappropriate value I put in the .csv file. I’ve tried to put “F”/”J” (the keys) and “reasonable”/”unreasonable” (the exact values) and all didn’t work. Do you have any insight on this? Thank you.Best,
Karen-
This reply was modified 2 years, 6 months ago by
xkyan.
xkyan
ParticipantOh great it works well! Thanks Jeremy.
xkyan
ParticipantHi Jeremy,
Sorry it’s me again. When I tried to test the presentation of fillers, I encountered a problem that “Please wait while the resources are preloading. This may take up to 1min.” But I’ve waited for more than 15 mins and it still didn’t finish. I’m wondering if there’s sth wrong with my codes, or it was caused by some other problems (e.g. network connection, etc.).
Basically I just want to test if two kinds of fillers can be detected and presented in the right format. Here’s my code:
Sequence(randomize("fillers")) // Define the template for filler trials Template("items-fillers.csv", row => newTrial("fillers", // newVar("RT").global().set("0"), // newVar("TFPress").global().set(false), newVar("kind", row.condition) , // pic(row) getVar("kind") .test.is("flanker") .success( pic(row) ) .failure( spr(row) ) ) )
Thanks a lot in advance!
xkyan
ParticipantHi Jeremy,
Thank you a lot for the time and patience helping me figure out.
For 1, yes there’s no problem with the current version, and the easier one you posted is exactly the one I’m looking for!
For 2 and 3, sorry I didn’t explain it clearly but yes you understood it right. Those two functions really help a lot and did the things I want them to do.
Again, thank you so much for the help!
-
This reply was modified 2 years, 6 months ago by
-
AuthorPosts