Alternating duration of dots stimulus

What are you trying to achieve?:
I currently have 4 blocks of RDK trials, 2 speed and 2 accuracy. I want the duration of the dots to be indefinite in the accuracy condition until the participant enters a keyboard response. I want the dots to disappear after 1.375 seconds in the speed condition and the task to move onto the feedback routine.

What did you try to make it work?:
I tried if statements such as if “quickly” was found in the readymsg the dots_2.duration = 1.375 but the dots remained until a key was pressed. I also tried implementing an if statement that implemented a timer and when that time counted 1.375 seconds continueRoutine = False. This then created a traceback on my reaction times used in feedback.

Currently my dots task and keyboard response is set to start at 0.2 seconds and the duration is blank.

You could have a variable duration for your keyboard and dots which is set to either 1.375 or 9999

Thank you

I added a column to both of my excel files, one in the order of accuracy, speed, accuracy, speed and the other speed, accuracy, speed, accuracy.

Then I added this condition to the duration in both keyboard and dots components

I then attempted to run the experiment and got this traceback:
line 706, in
if trialResp_3.rt < 0.25:
TypeError: ‘<’ not supported between instances of ‘list’ and ‘float’
################ Experiment ended with exit code 1 [pid:18620] #################

I’m not sure how to interpret this as the experiment was running perfectly prior to alternating the duration time in each condition

Try reattaching your spreadsheet. PsychoPy may not have noticed the new variable.

Hi I noticed the error in spreadsheet and now it’s informed me of a new traceback - I have edited the above comment to reflect this :slight_smile:

if trialResp_3.rt < 0.25:
TypeError: ‘<’ not supported between instances of ‘list’ and ‘float’

trialResp_3 is set to end the routine. On the data tab have you set it to record all responses? That makes a list. Set it to record the first or last response (no difference).

It’s currently set to record the last key press

I’d expect it to be float already then.

You could have a look using print(‘RT’,trialResp_3.rt) and also try fixing the issue with if trialResp_3[0].rt < 0.25:

sorry I’m not too sure where to enter your first suggestion as the task crashes before the onset of the stimulus

As for the second part I added the [0] and am now getting this traceback
line 706, in
if trialResp_3.rt[0] < 0.25:
IndexError: list index out of range
################# Experiment ended with exit code 1 [pid:2664] #################

You’ve made a small error in implementing my suggestion Change it to if trialResp_3[0].rt < 0.25:

Oh apologies! I’ve been staring at code too long haha!

I ran it again with the right code and now have this traceback
line 706, in
if trialResp_3[0].rt < 0.25:
TypeError: ‘Keyboard’ object is not subscriptable
################ Experiment ended with exit code 1 [pid:26608] #################

That shows that trialResp_3.rt[0] was correct and I was wrong to suggest trialResp_3[0].rt, but list index out of range shows it isn’t a list.

Are you sure you are still getting TypeError: ‘<’ not supported between instances of ‘list’ and ‘float’ when you just have if trialResp_3.rt < 0.25: ?

yes that error still occurs. However, it only occurs when I add in the dot_duration condition. There isn’t a problem with it running the code when the duration is indefinite for all conditions

When I go back to the original of trialResp_3.rt and the dot_duration condition the experiment runs and shows the first trial for 1.375 seconds and then the task crashes and gives that traceback. I just tried keyboard response for the limited time the stimuli is on screen and it accepts that and moves onto the next trial. However, when there is no response the task crashes

I’ve been looking at the wrong issue.

Your error will be occurring when the trial ends because there isn’t a reaction time.

add to your elif clause in the row above and trialResp_3.keys

Then the RT will only be checked if a key was pressed.

I changed the code to the below and all appears to be working now, many thanks for your help!
image