psychopy.org | Reference | Downloads | Github

Calculating the subscores of the subtasks

Hello,

My trial stage consists of 3 questions and responses for each question are supposed to be counted as 3 different subtask scores. I can get cumulative total score but I cant get subscores for subtasks.

Correct answers for each question generate subtask scores as below.

Question 1 must generate recognition subtask score,
Question 2 must generate doer subtask score,
Question 3 must generate act subtask score.

I added 3 keyboards and 3 codes for each question and also a keyboard and code for total score but It didn’t work out.



Condition File is this
Codes for the subtasks are;
Question 1
Begin expriment:
cumulative_recognition = 0
End Routine:
if keyboard1.corr:
cumulative_recognition = cumulative_recognition + RecognitionCorrPoint

#And save the data
thisExp.addData (“cumulative_recognition”, cumulative_recognition)

Question 2
Begin Experiment:
cumulative_doer = 0

End Routine:
if keyboard2.corr:
cumulative_doer = cumulative_doer + DoerCorrPoint

#And save the data
thisExp.addData (“cumulative_doer”, cumulative_doer)

Question 3
Begin Experiment:
cumulative_act = 0

End Routine:
if keyboard3.corr:
cumulative_act = cumulative_act + ActCorrPoint

#And save the data
thisExp.addData (“cumulative_points”, cumulative_points)

Total Score
Begin Experiment:
cumulative_points = 0

End Routine:
if keyboard_total.corr:
cumulative_points = cumulative_points + CorrPoint

#And save the data
thisExp.addData (“cumulative_points”, cumulative_points)

In the end data file comes like this. It stores responses for question 1 but still not exactly I responded. I dont know why It is recorded ‘none’ as a response which I highlighted in blue. It wasn’t added up to the cumulative score though.

Responses for question 2 and question 3 highlighted in green aren’t recorded as they should be too.

Any recommendations?

  1. I don’t think you should have multiple keyboard components in parallel.

  2. I think that somehow when you have no response you are getting bleed from either the previous trial or one of the other keyboard components

Thank you for your reply. May be you are right but how can I collect responses to each question without seperate keyboard components? Probably there is something to do with coding which makes me feel like an alien. I think I need a code that enables to record responses to each question seperately.

Just to try something new, I removed code1, code2 and code3 then wrote them all in code_total. It didn’t work too.

Begin Experiment:

cumulative_recognition = 0
cumulative_doer = 0
cumulative_act = 0
cumulative_points = 0

End Routine:

if keyboard1.corr:
cumulative_recognition = cumulative_recognition + RecogCorrPoint
elif keyboard1.corr:
cumulative_recognition = cumulative_recognition + IncorrPoint

#And save the data
thisExp.addData (“cumulative_recognition”, cumulative_recognition)

if keyboard2.corr:
cumulative_doer = cumulative_doer + DoerCorrPoint
elif keyboard2.corr:
cumulative_doer = cumulative_doer + IncorrPoint

#And save the data
thisExp.addData (“cumulative_doer”, cumulative_doer)

if keyboard3.corr:
cumulative_act = cumulative_act + ActCorrPoint
elif keyboard3.corr:
cumulative_act = cumulative_act + IncorrPoint

#And save the data
thisExp.addData (“cumulative_act”, cumulative_act)

if keyboard_total.corr:
cumulative_points = cumulative_points + CorrPoint
elif keyboard_total.corr:
cumulative_points = cumulative_points + IncorrPoint

#And save the data
thisExp.addData (“cumulative_points”, cumulative_points)

You code says if score=1 add a correct point else if score=1 add an incorrect point, The second option can never be true.

Ok. I deleted ‘elif’ parts of the code. It records one of the correct responses as none (highlighted in yellow) It still doesn’t count up for keyboard2, keyboard3 and keyboard_total (highlighted in green).

if keyboard1.corr:
cumulative_recognition = cumulative_recognition + RecogCorrPoint

#And save the data
thisExp.addData (“cumulative_recognition”, cumulative_recognition)

if keyboard2.corr:
cumulative_doer = cumulative_doer + DoerCorrPoint

#And save the data
thisExp.addData (“cumulative_doer”, cumulative_doer)

if keyboard3.corr:
cumulative_act = cumulative_act + ActCorrPoint

#And save the data
thisExp.addData (“cumulative_act”, cumulative_act)

if keyboard_total.corr:
cumulative_points = cumulative_points + CorrPoint

#And save the data
thisExp.addData (“cumulative_points”, cumulative_points)

It looks like the keyboard components are running in parallel and that the responses are the arrow keys in each case. How are you expecting PsychoPy to know which keyboard should be used for each response?

1 Like

Thank you very much @wakecarter ! I deleted keyboard1, 2 and 3 then changed all “keyboard.corr” into “keyboard_total.corr” in the code and it worked.

Begin Experiment:
cumulative_recognition = 0
cumulative_doer = 0
cumulative_act = 0
cumulative_points = 0

End Routine:
if keyboard_total.corr:
cumulative_recognition = cumulative_recognition + RecogCorrPoint

#And save the data
thisExp.addData (“cumulative_recognition”, cumulative_recognition)

if keyboard_total.corr:
cumulative_doer = cumulative_doer + DoerCorrPoint

#And save the data
thisExp.addData (“cumulative_doer”, cumulative_doer)

if keyboard_total.corr:
cumulative_act = cumulative_act + ActCorrPoint

#And save the data
thisExp.addData (“cumulative_act”, cumulative_act)

if keyboard_total.corr:
cumulative_points = cumulative_points + CorrPoint

#And save the data
thisExp.addData (“cumulative_points”, cumulative_points)