Randomly get item from certain conditions

PennController for IBEX Forums Support Randomly get item from certain conditions

Tagged: 

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #6545
    Rick
    Participant

    Hi :-),

    I have a question on randomization of items from certain experimental conditions.

    Say I have a “Data.csv”

    Condition   Sentence
    A           This is sentence 1
    A           This is sentence 2
    B           This is sentence 3
    B           This is sentence 4
    filler      I'm filler 1
    filler      I'm filler 2

    I would like to have:

    fixed order of items in experiment trials like: A filler B, A filler B, A filler B instead of AA BB fillerfiller (given by Sequence(“Data”))

    while A , filler and B in “A filler B” are randomly extracted from each condition.

    I was trying to use Sequence() function to define the order, however, I found that Sequence() could only define the order of sessions in the whole experiment and yields:

    AA BB fillerfiller

    Then I tried:

    Sequence("Data", seq ("A", "filler", "B")), but it didn’t work.

    My original codes are as follows:

    PennController.ResetPrefix(null)
    
    Sequence("Data", seq ("A", "filler", "B"))
    
    Template( "Data.csv" ,
        // Row will iteratively point to every row in myTable.csv
        row => newTrial( "Data" ,
            newCanvas("empty canvas", 1, 40)
            .print()
            ,
            (row.Sentence?[newController("DashedSentence", {s: row.Sentence})
    			.settings.center()
                .print()
                .log()
                .wait()
                .remove()
              
            ]:null)

    If I could not realize from the global “Sequence()” function, what could I do to resolve this problem? Thanks!

    • This topic was modified 3 years, 2 months ago by Rick.
    • This topic was modified 3 years, 2 months ago by Rick.
    • This topic was modified 3 years, 2 months ago by Rick.
    • This topic was modified 3 years, 2 months ago by Jeremy. Reason: moved to support
    #6550
    Jeremy
    Keymaster

    Hi,

    I moved this topic to the Support section of the forums.

    I think what you are looking for is the rshuffle function:

    Sequence( rshuffle("A","filler","B") )
    
    Template( "Data.csv" ,
        row => newTrial( row.Condition ,
          // etc.
    

    Jeremy

    #6551
    Rick
    Participant

    Hi Jeremy,

    I’m sorry I didn’t notice the section was not Support section- -|

    Yeah, I was wondering how to rshuffle the data internally (condition in Data.csv). Finally, problem resolved with your suggestion.

    Thanks so much!

    Best,
    Rick

    #6561
    Rick
    Participant

    Hi Jeremy,

    Sorry to bother you again!

    I had tried:

    Sequence( rshuffle("A","filler","B") );

    but it seems that the trials order is random, instead of A(i) filler(i) B(i), but A B filler (all the way) or Filler B A (all the way) or other kind of orders,

    I tried to debug this for a while (to exclude other possibility and keep only A filler B)and found nothing wrong with this expression, could you offer me some suggestions like what I should check to resolve this problem? (If my understanding is not wrong, rshufulle() means keeping the order of A-filler-B, but randomly select elements from materials labelled as A, filler and B to the experiment)

    Thanks!

    Rick

    #6562
    Jeremy
    Keymaster

    Hi Rick,

    The rshuffle function will output a sequence or randomly picked, evenly spaced trials of each label, but the order of the labels is indeed random. So for rshuffle("A","filler","B") you can get six sequence types: [A,filler,B,A,filler,B,etc.], [A,B,filler,A,B,filler,etc.], [filler,B,A,filler,B,A,etc.], [filler,A,B,filler,A,B,etc.], [B,A,filler,B,A,filler,etc.] or [B,filler,A,B,filler,A,etc.].

    What do the (i)s refer to in your message?

    In any case, it sounds like you could make use of the custom subsequence function defined on this thread. Then you can do this: Sequence( subsequence(randomize("A"),randomize("filler"),randomize("B")) )

    Let me know if you have questions

    Jeremy

    #6563
    Rick
    Participant

    Hi Jeremy,

    Thanks so much for your quick reply!

    It’s great to know that I misunderstood rshuffle() haha I really appreciate for your detailed explanation!

    This subsequence() resolved my problem perfectly!(I tried once and failed, then I realize now that it is a new function that I need to put it on the top of code). I also tried pick() function you suggested in other place, which also works well. Thanks!

    Rick

    #6622
    KJ
    Participant

    Hello Jeremy,
    I was trying the rshuffle function but it didn’t work as I wanted.
    I have 6 conditions in total but for each sentence frame one participant should only see one condition of it.
    But when I wrote rshuffle(“A”,”B”,”C”,”D”,”E”,”F”), the experiment exhausted all my sentences, so a participant saw 6 variations of a sentence.
    What should I do?
    Is it because my csv file is in a wrong format?

    Thanks in advance.

    KJ

    #6624
    Jeremy
    Keymaster

    Hello KJ,

    The rshuffle function will always exhaust the trials whose labels are referenced. If you want to show different subsets of items to different participants, you could consider using a table for a Group/List design

    Jeremy

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