Howdy, Stranger!

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

Supported by


Hi! Im very new in OpenSesame and Python, so please, be patient with me.
Im traying to follow the steps in the video that talks about Counterbalancing but Im stuck with IndetationError.
Can someone helping to undeerstand what is happening¿?


  • Hi Atenas,

    An indentation error happens when you have not properly indicated the structure of your code using indentation (tab or spaces at the start of a line). This is a fundamental property of Python, so if you feel that you don't have a clear grasp on indentation, then I would first take a step back and start a basic Python tutorial. That will save you a lot of time and frustration later!


    Thanked by 1Atenascampbell

    There's much bigger issues in the world, I know. But I first have to take care of the world I know.

  • Hi, Sebastian.
    Thanks a lot for your help!. I´m very grateful for OpenSesame. I´m from México, my university doesn´t have economic resources to acquires softwares like e-prime. So OpenSesame is saving me and making my life so much easier.
    Have a good day!

    Thanked by 1sebastiaan
  • Hi, again, @sebastiaan !
    So, I finally could got the counterbalancing, just like the tutorial shows. But:
    I have four blocks in total, I need that the first block runs across all the participants (Loop_NoT), the next three are the blocks where I putted the inline_script to get the counterbalance, but, with this code all the blocks runs across the participants. I need just one of the three blocks runs:
    Participant 1 : Loop_ Not and b1 but I don´t want to run the block 2 and 3.
    Participant 2 : Loop_ Not and b2 but I don´t want to run the block 1 and 3
    and so on,
    ¿what do I need to modify?


  • Hi Atena,

    It looks like you're counterbalancing the order of the blocks right now (and not which participant does which block) although the details are a bit difficult to tell from your screenshot. I'm assuming that you have three blocks, and three groups of participants, and that you want to counterbalance like this:

    • Subject 1 → block1
    • Subject 2 → block2
    • Subject 3 → block3
    • Subject 4 → block1
    • Etc.


    In that case, you can simplify the structure quite a bit, and put the blocks directly into the experiment sequence. And then you can use a Run If statement that checks the subject number and determines which block should be executed. So the structure would look something like this:

    - Loop_NoT, run if: always
    - block1, run if: var.subject_nr % 3 == 1
    - block2, run if: var.subject_nr % 3 == 2
    - block3, run if: var.subject_nr % 3 == 0

    Note a few things:

    • The 'new' way to refer to experimental variables is var.[name], rather than self.get().
    • The modulo (%) operator gives the remainder of an integer division. This is useful for doing cyclical things like counterbalancing.


    Thanked by 1Atenascampbell

    There's much bigger issues in the world, I know. But I first have to take care of the world I know.

  • Right! Thanks a lot for your time, @sebastiaan !
    After many try I got it!

    So, I gonna let the printscreen if someone like me without experience with codes see this post.

    The best way to understand Sebastian´s explanation is consulting this two things:

    And the result looks something like this:


Sign In or Register to comment.