mercredi 26 août 2015

Psychopy: Key response lagging, causing problems within script

I have a component of an experiment that asks participants to choose between earning 10 immediate points or a larger point amount in two weeks (points are later converted to dollar amount to provide incentive to the "larger later" choice). The later amount offered varies based on previous choices. The participant is given feedback on the choice he/she just made in the next routine. To set this up, I generated this in the code component in builder:

if key_resp_4.keys == 'left':
    feedback = 'You chose 10 points immediately'
    TotalNow = TotalNow + 10
    add = (amount - 10)/2 
    amount = add + amount
elif key_resp_4.keys == 'right':
    feedback = 'You chose more points in two weeks'
    TotalLater = TotalLater + amount
    amount = (amount + 10)/2 
elif key_resp_4.keys in ['', [], None]:
    feedback = 'You did not make a choice. No reward given.'
    amount = amount

The "amount" variable generates a numeric value, which is updated based on a left or right response. "TotalNow" and "TotalLater" keep track of the total points earned for each condition and are displayed in the next screen. These variables are working just fine.

My problem lies within the feedback variable. I've run through the script quite a few times to better understand what is happening. For most of the trials (though not all)--regardless of whether or not I make a key press--the feedback screen prints the message designated for a non response: "You did not make a choice..." Here's the strange part, though. On the feedback screen, the "TotalNow"/"TotalLater" variables display point values indicating that I DID make a key response, even though the "feedback" text variable reports that I didn't. Further, the next trial shows the updated "amount" variable correctly.

Therefore, there seems to be some disconnect between the key response and the result shown by the "feedback" variable in the next routine. I suspect that the key response may be lagging. I suspect this because I have found that I am able to make two key responses in one trial (as evidenced by extra points appearing in the point total shown in the next routine). I have set the key response component to force the end of the routine, store only the first key, and discard any previous responses. Even with these settings, though, it is possible to make two responses.

Does anybody have ideas as to why these events are occurring? I'm puzzled by this myself. Any help is much appreciated.

-Ben

Aucun commentaire:

Enregistrer un commentaire