Howdy, Stranger!

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

Supported by

[solved] Referring only to one column of a loop

edited May 2015 in OpenSesame

Hello!

I'm using nested loops, so that cells in the main loop contains variables that refers to specific column
in the nested loop:

image

The idea (and what I need to have) is that one picture of the column is chosen randomly and than I return to the main loop,
so something like this:
(every color represent one trial):

image

But in practice, every time the nested loop is referred to, it goes through all the columns before getting back to the main loop:

image

Is there any way to avoid it? I have 32 columns and I need to add even more...

Any insight will be really helpful! (-:

P.S here is a link to the file, if that helps:
https://www.dropbox.com/s/jpr9b0fesefyk83/Ordinalitysymbolic.opensesame?dl=0

Tali

Comments

  • edited 8:37PM

    Hi Tali,

    every loop item has a break ifargument. There you can add something like: [count_nested_loop] >0.

    OpenSesame has built in variables that count how often each item was called. If I remember right, the general shape is "count_NameOfItem", you can check the it in your logger.
    Does this help?

    Good luck,

    Eduard

  • edited 8:37PM

    Hi Eduard

    Thank you for your help!
    I tried what you suggested: in my nested practice loop (in break if)
    I wrote:[count_Nested_practice] >0
    Now, I get only 2 trials (the picture that was chosen from the nested and the picture from the column to the right), and then the practice ends...
    What am I doing wrong?

    Thanks again!

    Tali

  • edited 8:37PM

    Mh, I'm not sure about the exact sequence, in which these variables are written. I suppose if this happens in the end of an iteration, the first loop is 0th trial, so, the next trial will start, too. Now, the counter reaches 1, corresponding to the 2nd trial, so that no more trials are started.
    Anyway, the exact reasoning is not really important here, just set [count_Nested_practice] =0 and you should be fine ( I hope).

    Eduard

  • edited 8:37PM

    Hello again (-:

    I tried this too, and it doesn't get out of the practice after 2 trials,
    but with or without "break if" I get the same result:
    The nested loop is sampled twice (from tasted columns) and only then returns to the main list...

    Here is the experiment if you want to see how it looks...
    https://www.dropbox.com/s/jpr9b0fesefyk83/Ordinalitysymbolic.opensesame?dl=0

    Thank you!
    Tali

  • edited 8:37PM

    Hi Tali,

    In case you can't work around this problem, you could also simply put all the picture names in a list, and then use random.shuffle(list) and list.pop[0] to take one picture every time you go through your main loop.

    Good luck!

    Cheers,
    Josh

  • edited 8:37PM

    Hi Josh

    Thank you for your suggestion!
    The problem is that I will have to create 32 different lists and use shuffle for each one of them... and while doing it I can make mistakes... That's why I preferred to use loops

  • edited 8:37PM

    Hi Tali,

    If the strategy with using the built-in counters doesn't work, you can always create your own counters and make sure that they do work. So, in the beginning of your experiment (or in the outer loop), you set a trial_counter to 0. Later, when you're in the nested_loop, you can increment it to 1 or break it right away. This you should do from within an inline_script. Alternatively, you can also leave the loop item untouched and add this breakstatement as last element in the nested sequence. In doing so, it will also not run more than once.
    Do you understand what I mean?

    Btw. I think, you have a few nested sequences too much in your experiment. Maybe you should check, whether you can remove some of them to make the experiment less complicated.

    Good luck,

    Eduard

  • edited 8:37PM

    Thank you Eduard! I'll try that!

  • edited 8:37PM

    Hi!

    With the help of Yoni Melman we found a way to have a
    nested that is very similar to that of E-prime:

    In this example, in the main loop we wanted to define the font size as a variable.
    So we wrote the name of the variable within []:
    image

    Then, the nested table will have a column by that name:
    image

    To allow font size to change as variable, in the "Target" sketchpad we edit the script so the font size will be the variable [Fs]:
    image

    (This is only an example, but it is possible to use more columns for more variables)

    Some steps to make sure that the nested loop will only be sampled once:

    1. This is how the structure suppose to look like:

    image

    1. In the "run" section of "flag_down" write:
      self.experiment.set("flag",0)

    2. in the "run" section of "flag_up" write:
      self.experiment.set("flag",1)

    3. in the "nested-loop", check "show advanced options" (see picture above) and under "break if" write: [flag]=1

    Here is a link to the file:
    https://www.dropbox.com/s/wvenrkre52tmtpq/nested.opensesame?dl=0

  • edited 8:37PM

    Hi Tali,

    Thanks for sharing!

    Eduard

Sign In or Register to comment.