| Reference | Downloads | Github

Dropping items from list based on performance


I am using psychopy version 1.84.2 standalone on mac OSX and trying to build the AB-AC-AD task in which participants first have to learn word pair and then get tested using the first word as a cue. The only thing I could do so far was showing the items on the list :flushed: and I am already stuck.

What I need to do is this:
During the test phase of the experiment,

  1. participants need to see the first words of the pairs in the list one by one
  2. they should be able to write down the second word of the pair
    3.If a word pair is answered correctly for 3 times, that pair should be dropped from the list.
  3. This dropping stage should continue until every pair in the list is completed correctly for 3 times.

This is my first experiment in psychopy and it is the first time I use a program like this. So, I am completely lost.

I will appreciate any help



1 Like

As for keeping track of items and removing them based on a criterion, I just recently suggested a solution to someone about that. You can download the experiment and tinker with it:

For typing a response, there are several solutions out there. I made a mockup of one here, please let me know if it works. Unfortunately my system just broke, so I can’t run any experiments at the moment:

typingDemo.psyexp (6.3 KB)

1 Like

This is brilliant! Thank you very much. It solved all my problems :slight_smile:

For typing response I tried to run it and received this warning as soon as I pressed a key:

line 162 in
typingStim.setText(textStim.text + key)
NameError: name ‘typingStim’ is not defined

It had a typo, hopefully this works.

typingDemo.psyexp (6.3 KB)

So I got my machine working again, this should be better:

typingDemo.psyexp (7.8 KB)

I’m assuming you’re Turkish (forgive me if I’m wrong), so I would guess you might need accented characters, which right now this doesn’t do. So do you need them? And how are they typed on the keyboards you’ll be using? If they use ‘dead’ keys (like to get ü you press ’ shift + " ’ , then ‘u’) then that’s doable, but extra code would be needed.

Well, that is a perfect assumption :slight_smile:
I will try to use no accented characters if possible if I cannot manage to do that, then I will need them. If I use them people are going to write them using the actual keys on the keyboard (ü key for ü).
But if I understand you correctly, that might not be possible, so I will try my best to avoid such characters.

It’s not a problem, it will just require a little more tweaking.

So to get a ü, there’s just one key to press? Or do you press a modifier key (like shift) and then another key. Do you have to hold shift while you press the other key, or is it released first?

You could give us a little list, using + for when they’re held together, and a comma for when they’re sequential. Like on my international keyboard, some characters would be like this:

’ , e = é
shift + ` , a = ã

But also, you’d be expecting them all to use the accents correctly, it might not be a bad idea in some cases to just ask them not to use them.

they all have their own keys, they don’t need a modifier key. the characters are these:

ı - ğ - ü - ş - ö - ç

And I know I keep asking questions but I have another problem now :confused:

I need to have 4 of the criterion learning loops you generously sent me. so I tried creating the same loop using different names when necessary.

First loop is practice and stimuli are digits and letters. I changed the variable names and since I need them to perform 3 times correctly, I changed 2 into 3 (with a vague feeling of doing something possibly right) and I keep receiving this error message:

if scoreDict[digit] >= 3:
KeyError: 123L
Do you have any idea about what I am doing wrong?

Thank you so much for your time and efforts


About the keys, that should be a quick fix, but first you need to find the name of the key press that will be sent. There should be a demo called keyNameFinder if you’re using a recent version of Psychopy. Run it, press those keys and write down their names.

Once you have their names, you just go into the code component and add them to the list of accepted keys we made:

# This is what's there now
entryChars = string.ascii_letters

# Add this below it, changing the key names
# of course

# list of characters to add
turkishChars = ['umlaut_u', 'cedilha', ]
# add them to entryChars

As for the error you’re getting, that means that you looked for an item named ‘123L’ in the dictionary, but it wasn’t there. You should check out a tutorial, maybe like this one to learn about dictionaries. You would probably have to upload some more info (screenshots, or an experiment with your conditions file(s)) for us to know why exactly what happened, if you can’t figure it out on your own.

thank you very much. Thanks to you, I’ve learned a lot :smiley:

Daniel Hi,
Unfortunately I am back :confused:
I tried to use words that did not contain turkish characters. But I did not foresee that participants might use turkish characters by mistake. Any time someone hits a turkish character psychopy stopped responding. So I decided it would be better to add those characters to the accepted keys. I have 3 questions regarding this:

  1. My computer is a MacPro but the computers in the lab are windows (7) desktops. Will the key names change across different keyboards or systems?
  2. I used the keyfinder in the demos it gave me these names:
    ‘apostrophe’ = i
    ’bracketleft’ = ğ
    ’bracketright’ = ü
    ’semicolon’ = ş
    ’comma’ = ö
    ’period’ = ç.
    Since these are the names of other keys that are present in my keyboard I think I might be doing something wrong.
  3. ‘ı’ and ‘i’ are different characters in Turkish. but psychopy thinks they are both i. How can I change this?

Hope you are having a great day

1 Like

Hi Burcu,

  1. I think it is quite possible that they will use different key names, you should definitely test them. I ran into this in an experiment of my own and added an option to switch between one layout and another on the experiment info window that pops up before they take the experiment.

  2. Okay, that makes sense. It looks like psychopy thinks your keyboard is more or less a US English keyboard. I would think this would be a simple thing to add, whereby if the key is ‘apostrophe’, we add ‘i’ to the textstim. I’ll come up with something specific later today if I get in front of a computer with psychopy installed.

  3. What exactly makes you say “psychopy thinks they are both i”?

My day’s not bad so far, hope the same is true for you!

Daniel you are as fast as superman!

I’ll run a second pilot on Wednesday so I have a little bit of time to prepare (first one was a mess :slight_smile: ).

As for the third question, I am sorry I should be more clear.

the character ı has the keyname i. so if someone presses the ‘ı’ key, it show as i (since in English i is the lower case for I) But in Turkish these are different letters as I - ı and İ - i.

I felt like this could complicate things that’s why I asked. But at this point everything is very confusing for me :confounded:

So this is an easy fix. typingDemo.psyexp (8.5 KB)

All we need to do is add those keynames to the list of keys that will be accepted, and additionally create a dictionary containing what we want to display if one of those keys is pressed. Check out the turkishKeyMap below, and the “extend()” call used below it (I also had to modify how “entryChars” was first created):

Begin routine

import string

# Get a list of all upper and lowercase
# letters.
entryChars = [x for x in string.ascii_letters]
# A dictionary of keynames sent to psychopy
# (found with keyNameFinder demo), with the character
# we want to display when pressed
turkishKeyMap = {
    'apostrophe':  u'i',
    'bracketleft': u'ğ',
    'semicolon':   u'ş',
    'comma':       u'ö',
    'period':      u'ç',
    'i':           u'ı',
# Get a list of the dictionary keys and add to the 
# list of key presses that will be accepted

Now when we are checking for keypresses, we first see if that keyname is in our dictionary. If it is, we add the value from the dictionary to the TextStim, instead of the name of the keypress:

Each Frame

#### See attached file for complete code
    elif key in entryChars:
        if key in turkishKeyMap:
            key = turkishKeyMap[key]
        typingStim.setText(typingStim.text + key)

This takes care of your worry about “ı” not showing up. Note that if we didn’t use this dictionary lookup code and you typed a word like ‘için’, it would appear as ‘iperiodin’ . Hopefully that now makes sense to you.

Lastly, I would be diligent and test all of those lab computers individually, since hardware is not as uniform for Windows computers. If the keynames are different, you can add an additional dialog before the experiment starts where you can select what computer you’re using, and then reset turkishKeyMap . Here’s a version that does that, note that I moved the definition of turkishKeyMap to a different routine with a code component:

typingDemo-chooseKeyboard.psyexp (9.7 KB)

One more thing you should definitely think about as well, is if you’re marking responses as correct or incorrect, you’ll have to make decisions about multiple possible correct answers.

Hi again,

It works perfectly by itself. I tried to add it to the criterion learning loop you perfectly created but I am failing. Attached are the files I use for my experiment. I want my participant to be able to use Turkish characters for the “test” and “trials_4” loops. For that where should I put the import code you sent?

0.xlsx (28.7 KB)
1.xlsx (28.7 KB)
2.xlsx (28.7 KB)
blocks.xlsx (27.5 KB)
innerConditions.xlsx (9.5 KB)
selecttasks.xlsx (27.9 KB)
letterConditions.xlsx (35.6 KB)
FlankerConditionsText.xlsx (39.4 KB)
experiment1ldwopract.psyexp (126.9 KB)

Well for one there’s a typo “innerConditionsp.xlsx” in the code component in the trial2 routine, and the loop trials_8 is looking for an excel sheet called letterconp.xlsx , which I assume is “letterConditions.xlsx”.

If you want help you really need to just send an experiment with the problem isolated. If I can’t easily run (and I unfortunately don’t speak Turkish) it’s not something I’ll be able to work on. So if you can send a sample experiment just with the part you’re having trouble with I’ll be able to help.

I was able to make a little sense of what was happening, but again can’t yet run it.

Looking at trial2s, right now the text of the TextStim “block_1_input2s” is set by having $’’.join(key_resp_12s.keys) run on every frame. Again, since pressing the i key on your keyboard produces “apostrophe”, this method will no longer work. If you want to use the method I suggested, you’ll have to take a little time to make sense of how it works, because it uses a different approach.

You will need a “u” in front of this string to make it accept unicode characters:

msg = u'Yanlis. Dogru cevap {0}'.format(corrResp)

Well I really didn’t feel like grading papers, so I think I figured it out, but in the future you will need to give us Minimal (emphasis on Minimal :slight_smile: ) working examples.

I made a copy of your experiment and chopped most everything out so I could look at the issue. I added a routine that you should put at the very beginning of your experiment to setup the keyboard (called setupKeynames). You’ll have to go to your experiment settings (click on this):

and make sure it looks like this:

This adds another field where you can specify the name of the computer, in case the keyboard layouts are different. If it’s not typed correctly the experiment will quit with an error (which is a good thing).

Other than that, I only modified the routine “trial2”. Study it very carefully to see how it’s different from yours. One thing you’ll have to do is right-click on the keyboard icon and move it to the top.

experiment1ldwopract (copy).psyexp (100.6 KB)

1 Like