Howdy, Stranger!

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

Supported by

Counting points in OpenSesame



I am creating an experiment for my studies. The task of the subjects is to declare in colored circles (red, green or blue) the line presented in the following as horizontal or vertical. For this they have to tap on C (horizontal) or M (vertical). After each circle, the subject should receive feedback. Depending on the circle, the possible scores differ.

If the circle is red and the respondent taps correctly, he does not get a point. However, if he taps incorrectly, 20 points are deducted.

If the circle is green and the respondent guesses correctly, he gets 20 points. If he guesses wrong, however, no points are deducted.

If the circle is blue, the respondent gets one point if he guesses correctly. If he guesses wrong, one point is deducted.

After each circle the respondent automatically gets a feedback if his answer was correct or wrong. For this I created 6 different sketchpads, which have a condition assigned in the sequence. As an example: If the circle is green and the respondent types correctly, he receives the sketchpad response_green_correct as feedback.

In one run, all combinations of color and alignment of the line should then be presented twice.

Afterwards, the respondent should receive feedback on the total of 12 processed circles. For this, however, the score mentioned above must be taken into account.

Is it possible to calculate in the syntax how often certain sketchpads were displayed and then multiply this number with the score?

I hope you can help me. I thank you in advance!

If you have any further questions about the experiment or something was incomprehensible, please feel free to ask.

Thank you very much!

Jonas πŸ˜‰


  • Hi @jonase,

    What kind of feedback would you like to present to participants after a block? Just an overall score based on the rules you described or a more detail feedback (such as a count of each type of trial and the points corresponding to each)?

    The general idea

    Whether the first of the second, the solution requires some coding in Python or in Javascript (if you're planning to run your experiment online, you'd be use Javascript).

    Let's focus on the first option (calculating a general score) for now... (The second option would follow the same overall logic as below, but it'd require programming more variables)

    It looks as if you're using a colour variable to code for the circle's color for every trial, and you can access whether the response is correct or incorrect using the correct variable. So, the solution is to implement code that would do something like this:

    You'd have to set the score to a baseline level before the block starts. Presumably, subjects start with zero points. Let's say we want to store the points in a variable we call game_score. So you'd set the game_score to zero before the block. Then, on every trial, you'd run If the color is red and the response is incorrect inline_script (Python) or an inline_javascript object. Use whichever language you're most familiar with (unless you plan to run the task in a browser, in which case you'd have to go for Javascript). In that code, you'd specify something like:

    If the colour is red and the response is incorrect, then game_score = game_score - 20

    If the colour is green and the response is correct, then game_score = game_score + 20

    If the colour is blue and the response is correct, then game_score = game_score + 1

    If the colour is blue and the response is incorrect, then game_score = game_score - 1

    Now, there is actually something simpler and more flexible: to define the reward and penalty in columns within the loop table (say, reward and penalty) and apply these systematically in every trial:

    If response is incorrect, then game_score = game_score + penalty

    If response is incorrect, then game_score = game_score + reward

    That option offers three advantages:

    (1) is takes less code - no more checking what colored circle was presented in the current trial (faster execution and most of all, less risk of programming error or confusion)

    (2) you get to see the reward and penalty for each trial in your data output (provided that the logger includes it, which it does it you leave it set to "Log all variables", otherwise you'd have to add it manually to the variables being logged)

    (3) it gives you the flexibility to use different reward and penalty regimes across blocks without having to edit the code.


    Here's how to I implemented it in a scaled-down version of your task based on your description (I used some Python code, but you could achieve the same result with Javascript):

    (1) I set up the game_Score to 0 before the block

    var.game_score = 0

    (2) I defined a number of useful variables in the loop, which will be used to keep track of the score while minimizing the need for code

    (3) In side the trial sequence, I use this code to update the game_score using information from the loop:

    if var.correct == 0 :
        var.game_score = var.game_score + var.penalty
        var.game_score = var.game_score + var.reward

    Note that I add the penalty (I don't subtract it) because the penalty is defined with a negative value in the loop table.

    (4) I display feedback, both trial by trial, and for the whole block. The trial feedback is delivered by showing one of two feedback objects, depending on response accuracy:

    I displayed quite a bit of information on the trial feedback, so that you can see how to do it should you decide to display that much information:

    Hopefully that solves your problem. You can download my example here:

    Need more detailed block feedback?

    If you wanted to display more specific feedback (e.g., display the number of errors for each circle color, the score per circle color etc.), you could do it by using some more advanced coding to implement variables. For example, if you wanted to count the number of errors for red circles, you'd set up a red_errors variable to zero before the block:

     var.red_errors = 0

    And inside the trial, ine the Python inline object, you'd have to use some code like:

    if var.colour == 'red' and var.correct == 0 :
             var.red_errors += 1

    and the same for the other colors. You get the idea...

    Hope this helps. Good luck with your experiment!


    PS: In your description, you don't mention counterbalancing the response keys but it'd be a good thing to do (you can use code to allocate one key arrangement to odd-numbered subjects and the reverse arrangement for even-numbered subjects). You can see how to do that and another example of scoring based on condition in this post:

    If you found my reply helpful and wish to invite me to a coffee, you can do so here πŸ˜‰ Buy Me A Coffee

  • Hi,

    first of all I thank you very much! The points are now counted but if there is the second circle of the same colour I get a error report saying "TypeError: this._variables[i[0]] is undefined. See the console for further details"

    I don´t know how to handle this problem.

    Yes I want that it can be used online.

    To the feedback: I would like to give a feedback after every circle simpy saying "Correct" or "Incorrect" and after each block a feedback with the game_score.

    Maybe you can also help me with this!

    Thank you


  • FabFab
    edited September 15

    Hi @jonase,

    Glad I could help. In the example I sent you, each circle was presented twice and no error comes up. Can you confirm my example works correctly on your computer too? If you run it in a browser, it won't work because OSWeb does not support coding in Python. If you use Python code in your task and run it in the browser, you'll get errors. Otherwise, if you run it in an OS window and still get that error message, there must be some error in the code you implemented in your task, but I can't tell without seeing the actual task (could you possibly upload it to this forum?). OS should display information about the object and the line where the error occurs. Can you pinpoint the origin?

    About the feedback, just edit the correct and incorrect feedback object to display "Correct" and "Incorrect" respectively.

    To run your task online, you want to use OSWeb. I recommend making sure you're using the latest version. The easiest is to download the latest version of OS (3.3.10), which comes with OSWeb 1.4:

    OSWeb 1.4 includes new features not previously supported. This said, it is important that you read a little about the features of OS that OSWeb does not support, so that you can design your task with that in mind:

    You would need to translate the Python code into Javascript ( This is not very difficult, now that know the logic of the solution you want to apply. Just note that your should declare variables using vars. instead of var. to make the variable available beyond the object in which it is defined. I'm pressed for time right now but if you get stuck, I'll take a look and post the javascript code here later on.



    PS: for questions about experiment you intent to run in a browser, the OSWeb forum section might be more relevant (you'll also find lots of interesting threads there that might be helpful). Otherwise, if you post on the OS forum, best to indicate that your task should run in a browser (so that you get replies that take it into account)

    PPS: When replying in the forum, you might want to use the handlers so that your correspondent gets notified of your message (otherwise they won't know unless they manually revisit the thread). You just need to type @ followed by the first letters of your correspondent's username and a pulldown menu will pop up. For example, if you type @fa, this will appear:

    If you found my reply helpful and wish to invite me to a coffee, you can do so here πŸ˜‰ Buy Me A Coffee

  • Hi @Fab,

    maybe the best option is to upload my experiment. I tried to use java language but im not sure if its correct. Now there are no problems with the colour but OSWeb says that there is no variable called game_score.

    Sometimes the language is german i hope that this is not a problem. The structure is in english.

  • Hi @jonase,

    Thanks for uploading your task. I spotted a couple of problems right away with your code...

    (1) You tried to use Javascript in a inline_script object instead of an inline_javascript object... That can't work... Use the inline_script for Python code, and inline_javascript for Javascript code. Writing Javascript in a Python code object (or vice versa), will not work.

    (2) Your Javascript code contains errors. For some reason you added parentheses everywhere you use the variable: game_score(). That won't work... Any reason you added the parentheses? Parentheses are used for functions, not variables. Also, when testing the condition of the "if" statement, you have to use "==" instead of "=". Here's the corrected code:

    if (vars.correct == 0) {
    vars.game_score = vars.game_score + vars.penalty;
    } else {
    vars.game_score = vars.game_score + vars.reward;

    Some further problems I spotted:

    (3) You're using two different loggers. That is not a good idea as it can create messy output file and can result in errors. You should use one and the same logger throughout (if you copy and past it in different places, use a linked copy). I fixed that to have only one logger.

    Since you're using different tasks in the same experiment (circle, probe task and some other yet not programmed task), it would be a good idea to define a variable that would appear in the data log and would code for the task currently running. That way, your output will contain a column coding for the task (will make it easier to process the data separately for each task).

    You'll need to make sure to include task_stage into the list of variables being logged (see next point)

    (4) You must set the logged variables manually in OSWeb. Check the diagnostic of the OSWeb compatibility check (Tools OSWeb). It'll give you some indication of whether something in your experiment is incompatible with OSWeb. You may want to read the documentation about OSWeb; it'll safe you time and possible problems. Apart from using inline_script objects (Python), another thing that is problematic is how to have the logger configured. By default, its "Log all variables" is checked. This is great when you run the task in an OS window in the lab, but not for running it in a browser (because logging everything takes a toll on the bandwidth and can slow the browser), so you must disable the "Log all variables options" and specify which variables you want to log in the data output. The easiest way to do this is by opening the variable inspector and then dragging the variables you want in the data output. Please do this carefully, as you need to make sure to include all the variables that will be necessary for your analysis of the data.

    Here, I inserted a few but you might want to revisit this to make sure you have what you want...

    (5) Wrong penalty values in your loop table. The rewards and penalties you implemented in the task do not correspond to the rules you described in your initial post, as you use positive values...

    As I mentioned in my earlier post, if you use the code I suggested, you must define the penalties as negative values. Alternatively, you need to change the code to subtract penalties instead of adding them.

    I corrected it to:

    Some more considerations:

    Responses measured to the keyboard object, not to the circle

    I noticed that you display the circles for 195 ms before the fixation cross returns. That should work out if you don't expect participants to respond faster than 195 ms. They probably won't be, but if they were, their response would not be recorded (because the keyboard object only starts after the 195 ms have gone by). If you wanted to make sure that responses can be recorded from the onset of the presentation of the circle, you'd have to use something a little more complicated that consists in using two keyboard objects which I described in this post:

    Note that if response times matter in your experiment, your task currently measures RTs from the onset of the keyboard object, not that of the circle. That means that if a subject presses C or M 450 ms after the onset of the circle, the RT recorded by your task will be 255 ms (450 ms - 195 ms). So in that case you need to remember to add 195 ms to all RTs before your analyze your data.

    Debugging in the browser

    When developing a task to be executed in a browser, do test it in the browser:

    ... and use your browser's console to check output to the console and error messages.

    Counterbalancing the response keys across subjects

    Your task currently sets the responses in a fixed way: C for horizontal bars and M for vertical bars in the game task. Unless you have specific reasons to do it this way, I would recommend counter balancing the responses across subjects. You would need to use code to do this. See for an example using Javascript code. I took the liberty to include it in your task. You'll see that I added an instruction screen for the game's task to show you that the instructions can be adapted dynamically to display whatever keys are appropriate for a specific subject. I used this code to create variables storing the correct responses for horizontal and vertical bars. the code runs at the onset of the experiment.

    if (vars.subject_parity == "odd") {
    vars.horizontal_response = "c";
    vars.vertical_response = "m"
    } else {
    vars.horizontal_response = "m";
    vars.vertical_response = "c"

    Note that when running an experiment online using JATOS, the subject number will be sampled from the configuration you set in the OSWeb section:

    To use the subject's parity as a key to counterbalance the response keys, you must make sure to include at least one odd and one even number there. Note that JATOS will not sample these equally, though. So you may not end up with exactly the same number of participants with each keys arrangement. There may be ways to get around this playing around with JATOS features, but I'm not sure how to do this yet (might be something to check in the JATOS documentation/forum).

    That's all I have time for, I'm afraid. But I believe your task now runs and that I fixed the existing problems. Hopefully this should provide you with enough information to finish programming your task.

    Your can download my version of your experiment here:

    The forum and the web site contain a lot of useful information, and you can find a lot of information about Javascript online too (I started using OS in March and had no idea of Javascript or Python, but found a lot of useful information out there).

    Good luck!


    If you found my reply helpful and wish to invite me to a coffee, you can do so here πŸ˜‰ Buy Me A Coffee

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games