Howdy, Stranger!

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

Supported by

Correct response n-back task

edited June 2021 in Expyriment

Hello,


We are creating an experiment (n-back task) in OpenSesame in which we want to present symbols (as targets) alternated with images (as distractors). Participant has to indicate if the symbol is the same or different from the one presented twice before (2-back) by keyboard response. We have randomized the task symbols, but we are having difficulties in coding correct and incorrect responses (the answer is correct if the symbol showed at that moment matches with the one displayed twice before).


We used the following code for correct_response (var.target is the variable in the loop that contains the list of symbols): 


target = var.target
for i in range(len(target)):
  		if target[i] != target[i-2]:
    			var.correct_response = 'left'
  		elif target[i] == target[i-2]:
    			var.correct_response = 'right'
  		else:
    			raise ValueError('Invalid answer')


Unfortunately, using this code the program always recognizes as the correct response "left". Any ideas to solve this problem?


Thanks in advance for your help!  


Kind regards.

Comments

  • Hi,

    Can you share your experiment, so I can have a look? In general, these sorts of problems can best be debugged by printing out the values of the variables that are used. If you always get "left", then target[i] is never equal target[i-2]. If this surprises you, look into what Python is actually comparing by printing out these two values.

    Eduard

    Buy Me A Coffee

Sign In or Register to comment.