Create a fixed length Stroop task

Hi ,

I tried to create a Stroop task (which I think I managed) however I want it to be fixed at a total 30 min and not dependent on the performance and rapidity of the participant’s answers… How can I make that the whole task has a duration of 30 min?

Thanks for your help.

Jil

You need a custom clock and to break the loop when the elapsed time is over 1800.

myClock = core.Clock()
if myClock.getTime() > 1800:
     trials.finished = True

Make sure your loop repeats often enough that no-one will run out of trials in 30 minutes.

1 Like

Hi,

Thanks for your reply!
So this means I have to just insert these few lines into my code? Or how should I do that?
and where exactly in my code do I have to write this down?
Sorry for all those questions but I am really bad at coding so I am a bit lost…

Best

Try adding a code component. Create the clock in Begin Experiment. You can reset it using myClock.reset() in End Routine before the loop starts. Then put the check in End Routine of the last routine within the loop (called trials by default – change trials in the code if your loop is called something else). This should end the loop at the end of a trail when the time has been exceeded.

Hi Thanks a lot again for your help

I tried this out but it doesn’t work… when I try to start the experiment it shows the instructions and then it closes immediately… do you know what the problem could be?
I am really lost… :frowning:

Is there an error message in the runner?

This is what I get

Running: C:\Users\JilBo\OneDrive - CONDOR COURTIERS & CONSEILLERS SARL\PhD_Mental_Fatigue\Stroop Task\StroopT_lastrun.py

731.6467 EXP Imported C:/Users/JilBo/OneDrive - CONDOR COURTIERS & CONSEILLERS SARL/PhD_Mental_Fatigue/Stroop Task/conditions.xlsx as conditions, 10 conditions, 4 params
731.6500 INFO Loaded monitor calibration from [‘2022_05_15 19:11’]
731.6703 EXP Imported C:/Users/JilBo/OneDrive - CONDOR COURTIERS & CONSEILLERS SARL/PhD_Mental_Fatigue/Stroop Task/conditions.xlsx as conditions, 10 conditions, 4 params
pygame 2.1.0 (SDL 2.0.16, Python 3.8.10)
Traceback (most recent call last):
Hello from the pygame community. Contribute - pygame wiki
2.5911 WARNING We strongly recommend you activate the PTB sound engine in PsychoPy prefs as the preferred audio engine. Its timing is vastly superior. Your prefs are currently set to use [‘sounddevice’, ‘PTB’, ‘pyo’, ‘pygame’] (in that order).
11.6025 WARNING User requested fullscreen with size [1024 768], but screen is actually [1920, 1080]. Using actual size
0.9760 WARNING Monitor specification not found. Creating a temporary one…
File “C:\Users\JilBo\OneDrive - CONDOR COURTIERS & CONSEILLERS SARL\PhD_Mental_Fatigue\Stroop Task\StroopT_lastrun.py”, line 222, in
trials = data.TrialHandler(nReps=None, method=‘random’,
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\data\trial.py”, line 147, in init
self.nReps = int(nReps)
TypeError: int() argument must be a string, a bytes-like object or a number, not ‘NoneType’
################ Experiment ended with exit code 1 [pid:27764] #################
749.6061 EXP Imported C:/Users/JilBo/OneDrive - CONDOR COURTIERS & CONSEILLERS SARL/PhD_Mental_Fatigue/Stroop Task/conditions.xlsx as conditions, 10 conditions, 4 params
749.6119 INFO Loaded monitor calibration from [‘2022_05_15 19:11’]

What value do you have for nReps for the trials loop? I’d recommend a large number like 9999.

I tried with not putting any number in it at first then it didn’t work and then I put 10000000 and then it crashed… could it be that the number is too big?
You said to use a high number but how can I make sure the number is big enough?

The number needs to be big enough so it would take longer than 30 minutes to complete all the trials.

What is the minimum duration of each trial (in seconds)?
How many trials are displayed if nReps = 1?

Multiply these two numbers together.

Divide 1800 by this number and round up.

I have that the duration of each trial is 60sec
how can I adjust the number of trials displayed for nReps?

I have 10 conditions with 4 parameters (that’s what my trial window tells me)

60 seconds seems a long time for one trial – in a Stroop task you normally have a fixation, then a word, then a response, then feedback or a gap.

The number of trials displayed for each repeat is the number of lines in the associated spreadsheet (i.e. 10).

Based on the numbers you’d given then each rep will take 10 minutes (60 x 10) so you’d only need nReps to be 3 to reach half an hour. However, I suspect that 60 seconds is not what you meant to type.

Is the time for one trial not this

so the number of trials is then in my case 10?
image

or where do I have to set the duration of each trial? I was not planning on giving any feedback to the participants but I wanted them to complete the task for 30min in a row (I am trying to induce mental fatigue)

The 60 duration is the maximum duration of each trial (technically 60.5 seconds since the duration doesn’t start until 0.5). I suspect you have a keyboard response which ends the trial when a key is pressed, so the minimum trial duration is probably about 0.6 seconds. That would give a minimum of 6 seconds per repetition, so 10 reps in a minute, 300 reps in 30 minutes. Try nReps = 300.

alright thanks a lot!! I will try and let you know :slight_smile: THANK YOU SO SO MUCH

Hey

Just wanted to let you know that it seems to work now :slight_smile: thanks a lot for your help!!

One more thing… is it possible to connect a Cedrus response pad for the input/ response? this would maybe make it a bit easier for the participants to answer instead of using the keyboard of my laptop

thanks

In principle, yes Cedrus response pads should be compatible. I would check exactly what model you have an search the forum for information.

See also

https://www.psychopy.org/api/hardware/cedrus.html

1 Like

thank you