PennController for IBEX › Forums › Support › Choosing subet of items to present
- This topic has 55 replies, 6 voices, and was last updated 4 years, 5 months ago by
Jeremy.
-
AuthorPosts
-
April 1, 2021 at 12:40 pm #6799
apspjParticipantThanks, Jeremy!
1 – “If I understand you correctly, your cond column will go from A through H (8 conditions) with 4 rows for each letter (4 items).”
Yes!2 – “What I’m not clear about are your fillers: does your cond column go from filler-1 through filler-5 (5 types of fillers), with 4 rows for each one again (as hinted at by the repeated “1” in your example)?”
Just to clarify I have 5 types of fillers with 8 in each type (the items for fillers are all different and do not repeat as in the experimental items). So I have 40 fillers in total to distribute.Great! I will try the code (I am happy I could understand the code lol). But, anyway, would it assure that the items (experimental and fillers) are randomly selected for each participant?
Thanks,
Ana.
April 1, 2021 at 1:02 pm #6800
JeremyKeymasterBut, anyway, would it assure that the items (experimental and fillers) are randomly selected for each participant?
Yes, the script is run anew for each participant, so the
randomizeandsort(...)parts in particular will give you a (possibly) different output for each participant. This means that the pair of “A” trials will be random and (possibly) different for each participant, same thing for the pair of “B” trials and so on. The order in which those pairs are run will also be random and (possibly) different for each participant: one participant for example will see “E,E,filler-4,filler-1,C,C,…” and another one could see “C,C,filler-2,filler-3,A,A,…”Jeremy
April 1, 2021 at 2:58 pm #6802
apspjParticipantOk, so within a dashed sentence experiment I would have something like this?:
Template("myTable.csv", variable => newTrial("experiment", newController("DashedSentence", {s: conditions = [ pick(randomize(startsWith("A-")), 2), pick(randomize(startsWith("B-")), 2), // etc. ] .sort( ()=>Math.random()-0.5 ) // shuffle })April 1, 2021 at 3:55 pm #6805
JeremyKeymasterI’m not sure why you are trying to pass the
conditionsarray as thesparameter of your DashedSentence Controller elements.The
conditionsarray contains references to labeled trials, and its cells are therefore meant to feature in theSequencecommand, as in my example.If you take a look at my example project, I simply use a single Button element in the trials I generate. That’s the part where you should use a Controller element with DashedSentence if you need to use it, and presumably reference
row.sentence(or, to be consistent with your example,variable.sentence) as thesparameter. You can read more about how theTemplatecommand works here, and more about theSequencecommand hereJeremy
April 1, 2021 at 4:56 pm #6806
apspjParticipantI was not sure either. Getting into this world of programming now…
So this is what I am trying but it does not seem to work (I put 1 item of each just to test):
//Experiment conditions = [ pick(randomize(startsWith("A")), 1), pick(randomize(startsWith("B")), 1), pick(randomize(startsWith("C")), 1), pick(randomize(startsWith("D")), 1), pick(randomize(startsWith("E")), 1), pick(randomize(startsWith("F")), 1), pick(randomize(startsWith("G")), 1), pick(randomize(startsWith("H")), 1) ] .sort( ()=>Math.random()-0.5) fillers = randomize(startsWith("dist")) Sequence( conditions[0], pick(dist, 1), conditions[1], pick(fillers, 1), conditions[2], pick(fillers, 1), conditions[3], pick(fillers, 1), conditions[4], pick(fillers, 1), conditions[5], pick(fillers, 1), conditions[6], pick(fillers, 1), conditions[7], pick(fillers,1) ) Template("myTable.csv", row => newTrial("experiment", row.cond + "-" + row.item, newController("DashedSentence", {s: row.sentence} .css("font-size", "20px") .css("font-family", "Calibri") .center() .print() .print() .log() .wait() .remove() ) ) )April 1, 2021 at 6:19 pm #6808
JeremyKeymasterThis line
row => newTrial("experiment", row.cond + "-" + row.item,labels all your trials"experiment"and does nothing ofrow.cond + "-" + row.item. If your table hasA,B, etc. in cond, simply delete"experiment",and that part should work fine (I think)You also reference a variable
distin the firstpickfunction ofSequencebut you have defined no such variable: I think the variable name you mean there isfillers, which three lines above you have reference all the trials (in a random order) whose label starts with “dist”. You will only have such trials (that is, after deleting"experiment",) assuming that cond in your table isdist(or at least starts withdist) for your filler itemsOne last thing: you need to close the parenthesis of you
newControllerimmediately after the}(and then accordingly delete one of the three closing parentheses at the end of your code)Because your calls to
pickall have1as their second argument, your code will include 16 trials in your run: 1 experimental trial, 1 filler trial, 1 experimental trial, 1 filler trial, and so onFYI, you can also share code with me (and readers of the forum) by sharing the demonstration link of your project (option “Share” in your project’s right panel menu)
Jeremy
April 1, 2021 at 7:04 pm #6809
apspjParticipantThanks a lot for all the help, Jeremy.
The
"experiment"in the code referred to the Sequence of presentation, which is as follows:
Sequence("TCLE" (consent), "info","instructions", "treino" (trainning),"experiment", SendResults(), "end")I managed to creat all the parts pre-experiment and they are working really well. The problem is really in the
"experiment"part, that is why I repeated it withinnewTrial. I made the changes you suggested and understood whyrow.cond + "-" + row.itemmakes no sense in my project. And yes, about dist it was a mistake, because I was changing to fillers in Brazilian Portuguese distratores, which is how it is coded in my table. But I turned it back to English, as fillers. So everything runs very well but it gets"experiment"does not open at all.//Experiment conditions = [ pick(randomize(startsWith("A")), 1), pick(randomize(startsWith("B")), 1), pick(randomize(startsWith("C")), 1), pick(randomize(startsWith("D")), 1), pick(randomize(startsWith("E")), 1), pick(randomize(startsWith("F")), 1), pick(randomize(startsWith("G")), 1), pick(randomize(startsWith("H")), 1) ] .sort( ()=>Math.random()-0.5) fillers = randomize(startsWith("dist")) Sequence( conditions[0], pick(fillers,1), conditions[1], pick(fillers,1), conditions[2], pick(fillers,1), conditions[3], pick(fillers,1), conditions[4], pick(fillers,1), conditions[5], pick(fillers,1), conditions[6], pick(fillers,1), conditions[7], pick(fillers,1) ) Template("frases_utf_poss.csv", row => newTrial("experiment", newController("DashedSentence", {s: row.sentence}) .css("font-size", "20px") .css("font-family", "Calibri") .center() .print() .print() .log() .wait() .remove() ) )Ana.
April 1, 2021 at 7:10 pm #6810
JeremyKeymasterThe
"experiment"in the code referred to the Sequence of presentation:Sequence("TCLE" (consent), "info","instructions", "treino" (trainning),"experiment", SendResults(), "end")But the
Sequencecommand that we have been working on so far is not this one, it’s the one that you report later in your message:Sequence( conditions[0], pick(fillers,1), conditions[1], pick(fillers,1), conditions[2], pick(fillers,1), conditions[3], pick(fillers,1), conditions[4], pick(fillers,1), conditions[5], pick(fillers,1), conditions[6], pick(fillers,1), conditions[7], pick(fillers,1) )If there is no reference to your trials labeled
"experiment"in thatSequencecommand, then they won’t be included in the experimentJeremy
April 1, 2021 at 7:32 pm #6811
apspjParticipantYes, I tried to call it as a
newTrial("experiment",beforeDashedSentenceor call theSequence("experiment",But it seems I cannot get through it…Anyway, here goes part of the code: https://farm.pcibex.net/r/AebAtk/
Ana.
April 1, 2021 at 7:46 pm #6812
JeremyKeymasterYour experiment contains two
Sequencecommands, so PennController will ignore one of them. Because you usepickahead of the secondSequencecommand and your file pick.js, which is supposed to define that function, is empty, the script crashes on the first call topickand all the code below it, including the secondSequencecommand and theTemplatecommand that generates your trials labeled"experiment", is not executed.Your table does contain a cond column listing values from
AtoHand values starting withdist, so it does make sense to userow.cond + "-" + row.itemin your projectI have re-filled the file pick.js with the content from the project I initially shared and minimally edited your code along the lines of what we’ve discussed here, you can see the result here: https://farm.pcibex.net/r/MXPSBL/
(note that it runs only 8 experimental trials and 8 fillers, for the reasons I mentioned above)Jeremy
April 1, 2021 at 8:01 pm #6813
apspjParticipantThank you very much for your time and patience, Jeremy!
I understand now the issue with the first
SequenceIt works fine. Now I will make the adjustments.Thank you once again,
Ana.
April 3, 2021 at 1:06 pm #6829
apspjParticipantHi Jeremy,
The experiment works really well.
But now, as an exercise, I performed my own experiment around 3 times just to check the results. I followed the steps on https://doc.pcibex.net/how-to-guides/data-transformation/ but I keep getting the following error:
Error in count.fields(filepath, sep = ",", quote = NULL) : 'file' must be a character string or connectionI’ve already verified if Windows somehow changed the comma separated file downloaded from PCIbex is into semicolon but I keep getting this error. And I don’t know if it is something related to the function.
Thank you,
Ana.
April 3, 2021 at 9:07 pm #6830
apspjParticipantHi Jeremy,
Never mind, got it! I was downloading the .cvs file in “download file” in “results”. But now I decided to just open and save as “.txt” and it actually worked well with the function read.pcibex. I don’t know why it just worked for me with txt, but maybe it could be a note in the tutorial.
Best,
Ana.
April 5, 2021 at 11:45 am #6831
JeremyKeymasterHi Ana,
Glad to see that the issue has been fixed. However it shouldn’t matter whether you open your results file in a new tab and save it as a .txt file, or whether you click “download” to directly get a .csv file: the content is the same in both cases, it’s a comma-separated table.
Judging from the error message that you got, I suspect that something went adrift with the filename that was passed to
read.pcibex. Maybe saving the file with a.txtextension somehow helped in passing the proper value to the functionBest,
JeremyApril 12, 2021 at 5:49 pm #6861
apspjParticipantHi, Jeremy!
I created a csv table with a column “group” A, B, C, which are the lists to participants. I tested the demo link with a friend and it seems that we are getting the same list. Does the automatic arrangement of lists for each even-odd participant only works in the experiment link?
Thanks,
Ana.
-
AuthorPosts
- You must be logged in to reply to this topic.