Using pick with several conditions

PennController for IBEX Forums Support Using pick with several conditions

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #7141
    Josiane212
    Participant

    Hi,
    I’m trying to create an experiment and I’m a little stumped on how to proceed.
    I read a lot on this forum but I’m not sure which solutions best apply to my experiment.

    There are two different experiments (one with a slider, one with radio buttons), each with different items, fillers and conditions. I created two .csv files for now. My first issue is that every time a participant would start an experiment, the next one would get the other experiment. I believe the use of setCounter or setGroupsColumn would be useful here, but I’m unsure how to proceed if I have two .csv files. I thought of using two different Sequences, but I don’t know how to create and “if…else” that would go with the counter.

    My main problem is with the items shown. For instance, the first experiment consists of 18 items “families” each with 3 conditions (so 18*3 rows). The goal is to show only 9 items (selected randomly for each participant), but to show 3 times each condition, never in the same “family”. Here’s an example of what my .csv file looks like (these are not my items, just showing how it looks) :

    .Family,Condition,Item,Evaluation,Experiment
    1,normal,Yan likes apples,He likes apples,Exp1
    1,weird,Yan likes apples,He dances with apples,Exp1
    1,opposite,Yan likes apples,He hates apples,Exp1
    2,normal,The cat wants a hat,He wants a hat,Exp1
    2,weird,The cat wants a hat,He plays with a hat,Exp1
    2,opposite,The cat wants a hat,He does not want a hat,Exp1

    So for each family, we would show one condition, but that condition cannot be repeated more than 3 times. The fillers would then all be shown in a random order.
    For the other experiment, it’s almost the same, but there are 18 items with 6 conditions each. We would once again show one item for each family (but all 18 items this time) and 3 times each condition. There are then 36 fillers, each with 2 conditions that would have to be shown approximately 50/50. The alternation between items and fillers should be randomized.

    On the forum, I found experiments that looked like mine (here and here), where some people used the function pick, and others the functions subsequence and repeat.
    I’m really unsure which one would be the best for my experiments, and also unsure of how to use them properly for what I plan to do.

    I hope it’s clear enough, but I can explain more if needed!
    Any kind of advice, will be greatly appreciated 🙂
    Josiane

    • This topic was modified 2 years, 9 months ago by Josiane212.
    #7144
    Jeremy
    Keymaster

    Hi Josiane,

    I think your design will require some tailored coding. What I can propose is you use a single CSV table and rename your column Experiment as Group, so that PennController knows to pick only the Exp1 or Exp2 rows at a time

    Now doing just that would include all the items of one experiment, but you actually have specific requirements for your sequence of trials. What I suggest is you label your trials Family+Condition: we can create a javascript array containing all the labels ("1normal","1weird","1opposite","2normal", etc.) shuffle the array, and pick the first N entries from this array (with an additional trick to handle conditions distribution)

    On top of that, if I understood your description correctly, you have different numbers of conditions in exp1 vs exp2, and also an essentially different sequence of trials, since for exp1 you want the test trials in a randomized order followed by all the filler trials in a randomized order, whereas for exp2 you want a subset of the trial and of the filler items intertwined in a randomized order. In order to handle the two differently, we will need to look up the value of the internal counter (__counter_value_from_server__) and execute distinct pieces of javascript code base on it (using a switch statement)

    Here is an example, assuming a simpler table with just 8 non-filler items, 2 conditions in exp1 (“a” and “b”) and 4 in exp2 (“a,” “b,” “c” and “d”). For exp1, we show 4 trials (2 repetitions of each condition) followed by all the filler items; for exp2 we show 8 trials (again, 2 repetitions of each condition) intertwined with 8 filler items (50/50 in condition “a”/”b”)

    
    switch (__counter_value_from_server__ % 2) {
        case 0:
            n_families_total = 8;
            n_families_keep = 4;
            conditions = ["a","b"];
            families = [...new Array(n_families_total)].map((v,i)=>conditions.map(c=>String(i+1)+c));
            fisherYates(families);
            Sequence(
                randomize(anyOf(...families.slice(0,n_families_keep).map((v,i)=>v[i%conditions.length]))),
                randomize(startsWith("filler"))
            );
            break;
        case 1:
        default:
            n_families_total = 8;
            n_families_keep = 8;
            conditions_families = ["a","b","c","d"];
            families = [...new Array(n_families_total)].map((v,i)=>conditions_families.map(c=>String(i+1)+c));
            fisherYates(families);
            n_fillers_total = 16;
            conditions_fillers = ["a","b"];
            fillers = [...new Array(n_fillers_total)].map((v,i)=>conditions_fillers.map(c=>"filler"+String(i+1)+c));
            Sequence(
                rshuffle(
                    anyOf(...families.slice(0,n_families_keep).map((v,i)=>v[i%conditions_families.length]).flat()),
                    anyOf(...fillers.slice(0,n_families_keep).map((v,i)=>v[i%conditions_fillers.length]).flat())
                )
            );
            break;
    }
    
    Template( row=>
        newTrial( row.Family + row.Condition ,
            newText(row.Item + row.Group).print(),
            newButton(row.Evaluation).print().wait()
        )
    )
    

    Here’s an edited excerpt of the table I’m using:

    
    
    Family,Condition,Item,Evaluation,Group
    1,a,item 1a,eval 1a,exp1
    1,b,item 1b,eval 1b,exp1
    2,a,item 2a,eval 2a,exp1
    2,b,item 2b,eval 2b,exp1
    filler1,a,filler item 1a,filler eval 1a,exp1
    filler1,b,filler item 1b,filler eval 1b,exp1
    filler2,a,filler item 2a,filler eval 2a,exp1
    filler2,b,filler item 2b,filler eval 2b,exp1
    1,a,item 1a,eval 1a,exp2
    1,b,item 1b,eval 1b,exp2
    1,c,item 1c,eval 1c,exp2
    1,d,item 1d,eval 1d,exp2
    2,a,item 2a,eval 2a,exp2
    2,b,item 2b,eval 2b,exp2
    2,c,item 2c,eval 2c,exp2
    2,d,item 2d,eval 2d,exp2
    filler1,a,filler item 1a,filler eval 1a,exp2
    filler1,b,filler item 1b,filler eval 1b,exp2
    filler2,a,filler item 2a,filler eval 2a,exp2
    filler2,b,filler item 2b,filler eval 2b,exp2
    

    And here is a link to a demo project so you can see it live and inspect its code: https://farm.pcibex.net/r/tmXZTo/

    Let me know if you have questions

    Jeremy

    #7145
    Josiane212
    Participant

    Hi Jeremy,

    Thank you for your answer, it helps so much!
    After a few tests, I’m able to make Case 1 work like a charm, but when it’s Case 0’s turn, it says there’s an error in the running order.

    I tried switching the content of Case 1 with Case 0 and it worked fine, so it really seems to be the Case 0 : that stops everything from working. I can make both experiment work when they are in Case 1, but never in Case 0.

    switch (__counter_value_from_server__ % 2) {
        case 0:
            n_families_total = 18;
            n_families_keep = 18;
            conditions_families = ["a","b","c","d", "e", "f"];
            families = [...new Array(n_families_total)].map((v,i)=>conditions.map(c=>String(i+1)+c));
            fisherYates(families);
            n_fillers_total = 36;
            conditions_fillers = ["Reg","NPI", "NPIWeird", "ConnOK", "ConnWeird", "Pléonasme", "NoPléonasme"];
            fillers = [...new Array(n_fillers_total)].map((v,i)=>conditions_fillers.map(c=>"Leurre"+String(i+1)+c));
            Sequence(
                "counter",
                "Intro",
                rshuffle(
                    anyOf(...families.slice(0,n_families_keep).map((v,i)=>v[i%conditions_families.length]).flat()),
                    anyOf(...fillers.slice(0,n_families_keep).map((v,i)=>v[i%conditions_fillers.length]).flat())
                )
            );
            break;
        // Expérience Argumentation : Shuffled : 18 trials (3 x 6 conditions) / 36 fillers (18 Reg, 18 autres (x2 conditions))
        case 1:
            n_families_total = 18;
            n_families_keep = 9;
            conditions = ["cond1","cond2", "cond3"];
            families = [...new Array(n_families_total)].map((v,i)=>conditions.map(c=>String(i+1)+c));
            fisherYates(families);
            Sequence(
                "counter",
                "Intro",
                rshuffle(
                    randomize(anyOf(...families.slice(0,n_families_keep).map((v,i)=>v[i%conditions.length]))),
                    randomize(startsWith("Leurre")))
            );
            break;
    } 
    
    SetCounter("inc",1).label("counter");
    
    newTrial("Intro", 
        newText("TexteIntro", "Bonjour, merci").print(),
        newButton("BoutonIntro", "Iciici").print().wait()
    );
    
    Template("AllFinalExpV2.csv", row => 
        newTrial(row.Famille + row.Cond, 
           (row.Group == "A" ? [
                newText( 
                     ...

    The (row.Group == "A" ? [ line is to have different experiment (slider VS scale). I tried to remove it (and what comes with it) to see if it was the problem, but even without it the same thing happens.
    Any help is appreciated 🙂
    Thank you very much,
    Josiane

    #7146
    Jeremy
    Keymaster

    Hi Josiane,

    At this point it would be much easier for me to help you if you could share your project’s demonstration link (Share > Copy Demonstration Link, in the right menu of your project’s page)

    I am not sure what your table looks like, but I have created a variant of the project I shared above, this time with a base of 18 items and using your code (just slightly edited). You can directly test both groups here:

    There is one fatal error in your case-0 code: you reference an array named conditions where it should be conditions_families (on the line where you set families)

    Let me know whether you were able to fix the situation

    Jeremy

    #7147
    Josiane212
    Participant

    Hi Jeremy,

    Everytime is working great now!!
    That conditions_families seemed to be the problem.
    Thank you so much for your help!

    Have a wonderful week
    Josiane

    #7148
    Josiane212
    Participant

    Hi Jeremy,

    Everytihing is working great now!!
    That conditions_families seemed to be the problem.
    Thank you so much for your help!

    Have a wonderful week,
    Josiane

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.