PennController for IBEX › Forums › Support › Randomization by feature and by item
- This topic has 8 replies, 3 voices, and was last updated 2 years, 3 months ago by
MKonrad.
-
AuthorPosts
-
October 18, 2022 at 8:47 am #9586
BenG
ParticipantHi Jeremy,
I am designing an experiment in which participants will be shown a list of semantic features. For each feature, the participant will be shown a list of items and will have to decide whether the feature fits that item (e.g. does feature “is round” apply to item “pear”). All items are presented for each feature.
I would like participants to see all features and all items randomly, however, when each feature is presented I would like all the items (in a random order) to be presented before moving on to the next feature. I have tried doing so by having separate .csv files (Features_SemVer.csv and Items_SemVer.csv) as well as by creating a combined excel in which every possible combination of feature and item is presented in columns (Features_SemVerMixed). I have not been able to make this work so far.
Any help would be greatly appreciated!
Demo link: https://farm.pcibex.net/r/RTusyr/
October 19, 2022 at 6:51 pm #9594Jeremy
KeymasterHi,
One option is to report the features in your table (as you are currently doing in Features_SemVerMixed.csv) and label your items accordingly:
newTrial( row.Feature + "-" + row.Item ,
Then you can reference the labels in your
Sequence
command. This would show items 1-to-5 in a fixed order for each feature, with the feature groups of items randomized:features = [...new Array(10)].map((v,n)=>startsWith("Feature "+Number(n+1))) fisherYates(features) Sequence("WelcomeConsent", "counter", "demographics", "instructions1", "exercise", "startofexp", ...features, SendResults(), "Bye");
If you would like to additionally randomize the order of the items within each feature group, replace the first line with:
features = [...new Array(10)].map((v,n)=>randomize(startsWith("Feature "+Number(n+1))))
Jeremy
October 21, 2022 at 10:25 am #9608BenG
ParticipantHi Jeremy,
Thank you for your detailed response, that works perfectly! My only issue is that now the column “Instructions” in Features_SemVerMixed.csv appears to be randomized along with the other columns. Is there any way for this column to run in order while the others are randomized?
I am trying to print the text “Attention: New Feature” whenever the feature changes – that is what is contained in this column.
Thank you!
October 25, 2022 at 4:20 pm #9616Jeremy
KeymasterHi,
The columns are not randomized: the
features
array is randomized, which contains predicates over labels of trials; in effect, it is the order in which the trials are inserted in the sequence that is randomized, not the table or its columns, and not the way the trials are created more generallyIf you want to detect a change in feature upon runtime, you can use a global Var element to remember the value of the
Feature
column from the trial that was run before the current one, and compare the value of that Var element with the current value ofrow.Feature
: if they are different, it means the current trial is starting a new feature block:newTrial( row.Feature + "-" + row.Item , newText("instruct_exerc", "Bitte bewerten Sie, ob beide Tiere gleich gut Verursacher oder Empfänger der Handlung sein können.") .css({'font-family': "helvetica"}) .center() .print() , newVar("feature") .global().test.is( row.Feature ).failure( newText("feature_change", "Attention: New Feature ") .cssContainer({"margin-top":"2em", "margin-bottom":"2em", 'font-family': "helvetica"}) .css("font-size", "1.2em").color("Red").bold().center() .print() ) .set( row.Feature ) ,
Jeremy
October 28, 2022 at 8:37 am #9639BenG
ParticipantThat works perfectly, thank you!
November 1, 2022 at 10:22 am #9655BenG
ParticipantHi Jeremy,
One last question: is there any way to use the pick function with the features array? I would like to add a few breaks, but am not sure how to do this without the pick function. I have tried the following, however it causes the experiment not to run:
pick(features,500),”break”,
pick(features,500),”break”,
pick(features,500),Thank you!
November 1, 2022 at 12:49 pm #9660Jeremy
KeymasterHi,
The
pick
function only accepts IBEX-style predicates as an argument (eg.randomize("label")
) butfeatures
is a 10-ary array, so passing it topick
directly won’t workYou can create a (sub)sequence from it though, using IBEX’s
seq
function:seq(...features)
So you could do that:
featuresSeq = seq(...features) Sequence("WelcomeConsent", "counter", "demographics", "instructions1", "exercise", "startofexp", pick(featuresSeq,500),"break", pick(featuresSeq,500),"break", pick(featuresSeq,500), SendResults(), "Bye");
Jeremy
November 7, 2022 at 6:59 am #9685BenG
ParticipantHi Jeremy,
That works perfectly, thank you!
I noticed that when I increase the number of Features (currently 119), the code mistakes larger numbers beginning with the same number (e.g. 60, 63, 67, 69, etc.) as one feature (i.e., Feature 6). When this happens, instead of presenting one feature and all the items in a random order, it presents a different feature (beginning with that number) each time along with a random item. This happens a few times per experiment.
Is there any way I can specify that the whole number (up to three digits) of Feature be taken into account?
Thank you in advance.
November 16, 2022 at 4:06 am #9712MKonrad
ParticipantHi,
I think the problem lies in the prefix specified in
startsWith
. Since all features “Feature 60” to “Feature 69” start with “Feature 6” they’re mixed up. Adding “-” to the common prefix after the number should fix this.Change the line 40 as follows **and delete line 41** and it should work:
features = [...new Array(119)].map((v,n)=>randomize(startsWith("Feature "+Number(n+1)+"-")))
Best,
Markus -
AuthorPosts
- You must be logged in to reply to this topic.