Skip to content

Commit 6ca0616

Browse files
committed
Fix HRD keyboard response feedback
1 parent 2a5ec42 commit 6ca0616

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

cardioception/HRD/parameters.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ def getParameters(
161161
Vector indexing stairce type (`'UpDown'`, `'psi'`, `'psiCatchTrial'`).
162162
startKey : str
163163
The key to press to start the task and go to next steps.
164+
response_keys : dict
165+
Mapping from trial conditions to keyboard response keys.
164166
respMax : float
165167
The maximum time for decision (in seconds).
166168
results : str
@@ -218,7 +220,8 @@ def getParameters(
218220
parameters["maxRatingTime"] = 5
219221
parameters["isi"] = (0.25, 0.25)
220222
parameters["startKey"] = "space"
221-
parameters["allowedKeys"] = ["up", "down"]
223+
parameters["response_keys"] = {"More": "up", "Less": "down"}
224+
parameters["allowedKeys"] = list(parameters["response_keys"].values())
222225
parameters["nTrials"] = nTrials
223226
parameters["nBreaking"] = nBreaking
224227
parameters["lambdaIntero"] = [] # Save the history of lambda values

cardioception/HRD/task.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,13 +1055,21 @@ def responseDecision(
10551055
decision = responseKey[0][0]
10561056
decisionRT = responseKey[0][1]
10571057

1058+
# Translate keyboard response to decision labels if mapping provided
1059+
response_keys = parameters.get("response_keys")
1060+
if response_keys:
1061+
key_to_condition = {key: cond for cond, key in response_keys.items()}
1062+
decision_label = key_to_condition.get(decision, decision)
1063+
isCorrect = decision_label == condition
1064+
decision = decision_label
1065+
else:
1066+
isCorrect = True if (decision == condition) else False
1067+
10581068
# Read oximeter
10591069
parameters["oxiTask"].readInWaiting()
10601070

10611071
# Feedback
10621072
if feedback is True:
1063-
# Is the answer Correct?
1064-
isCorrect = True if (decision == condition) else False
10651073
if isCorrect is False:
10661074
acc = visual.TextStim(
10671075
parameters["win"],

0 commit comments

Comments
 (0)