Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

rolling the variables after each trial

In my word learning experiment, participants have to see the stimuli in sequential order
S1 S2 S3 S4 S5 as a block loop.

Now I have to repeat the same block loop 5 times, each time rolling the variables (all the variables and not just the column) like

S2 S3 S4 S5 S1
S3 S4 S5 S1 S2
.
.

Where do I add the "roll 1" so that all the values in the table are rolled each time I execute the loop again.

Comments

  • Hi,

    roll is an advanced loop operation that you need to enter into the script of the loop item.

    Using a fixed roll 1 won't do the trick though, because it sounds like you want to roll the table incrementally, with a different value each time. And variables (e.g. roll [my_roll_value]) are not yet supported here.

    So you're probably best off modifying the loop table in a script:

    For example, the following code (inserted before my_loop) will roll my_loop by one.

    items['my_loop'].dm = items['my_loop'].dm[1:] << items['my_loop'].dm[:1]
    

    Cheers!
    Sebastiaan

  • Thanks Sebastiaan.
    That one line of code solved it all.

    Regards
    aswv

  • Dear Sebastiaan,

    The above code worked fine when I was adding variables directly from the interface. (loop - table option).
    But when I am reading the values of the variables from a file, the rolling process is not working.

  • That's correct. The loop.dm property corresponds to the table that you see when you open the loop item. If you use an external source, the loop table is bypassed. What you could do is load the loop table from a file in the script as well. That way, you'll still be able to operate on it before the loop is executed:

    from datamatrix import io
    # Read the loop table from my_source.csv (in the file pool)
    items['my_loop'].dm = io.readtxt(pool['my_source.csv'])
    # And roll!
    items['my_loop'].dm = items['my_loop'].dm[1:] << items['my_loop'].dm[:1]
    

    See:

  • Thanks again. Works perfect.
    I had some difficulty initially because i had selected "set source file" inside my_loop and I was also reading data from file using the above code.

    Now I set it as "set source table" and used the above code to read values from file. So it works now.

Sign In or Register to comment.