URL of Experiment: Sign in · GitLab
(I don’t how to share it, without making it public. I made it public once and then all the codes disappeared).
Description of the Problem:
I am running an experiment involving a movie-watching and keypress task. The experiment includes watching three movies, which are repeated 2-3 times based on specific conditions. While the experiment works perfectly fine locally, I am encountering issues when running it online on Pavlovia. There are two loops with same routines. First loop works but the second doesn’t.
Experiment Setup:
- The experiment has two conditions. Both conditions share the same stimuli and routine flow, with only the instructions differing between them.
- Each condition starts with an instructions routine, followed by a practice round. During the practice round:
- A practice video is played (file size: 350 MB).
- Based on the number of keypresses recorded during the video, participants receive feedback.
- If the keypresses are either below or above a predefined range, the participant is required to repeat the video. This is communicated via a feedback message.
- The video can only be repeated once.
Implementation Details:
- To achieve the behavior described above, I used custom code components and a loop:
- The custom code counts keypresses and uses
if-else
statements to display feedback messages. - Another
if-else
structure determines whether to repeat the video routine or proceed to the next part of the experiment.
- The custom code counts keypresses and uses
The Issue:
- In Condition 1, this loop works as expected:
- If the keypresses meet the criteria, the experiment proceeds without repeating the video.
- If the keypresses do not meet the criteria, the video repeats once and then exits the loop, continuing the experiment (the codes for this are mentioned in additional information below)
- However, in Condition 2 (which follows two additional movie routines after Condition 1), the same loop does not work. Specifically:
-
During the first viewing of the video in the loop, the experiment stops at a specific point and does not restart.
-
Initially, I suspected the issue was related to the video file size (350 MB). However, replacing it with a smaller video file (25 MB) did not resolve the problem. The loop still works in Condition 1 but fails in Condition 2.
-
- All three videos are preloaded in the experiment.
Additional Information:
- I have attached a screenshot of the experiment flow and included the custom code components below for reference.
- Within the loop there are 2 routines, each of which has a custom code component to conditionally run the loop. The screenshots for those routines are also attached. The ‘practice_loop_event’ one is Condition 1 loop, which works but ‘practice_loop_goal’ doesn’t work.
The custom code in ‘practice_event’ routine in is:
“Begin experiment”:
practice_event_reps = 0
“Begin routine”:
key_press_count_event = 0
feedback_message_event = "No feedback available"
upper_limit_event = 10
lower_limit_event = 2
repeat_practice_event = False
“End Routine”:
# Count total keypresses recorded during the routine
if practice_movie_key_resp_event.keys: # Check if any keys were pressed
key_press_count_event = len(practice_movie_key_resp_event.keys)
else:
key_press_count_event = 0
# Set the feedback message based on the count
if key_press_count_event > upper_limit_event:
feedback_message_event = "Too many keypresses! Follow the instructions more carefully."
repeat_practice_event = True
elif key_press_count_event < lower_limit_event:
feedback_message_event = "Too few keypresses! Be more engaged."
repeat_practice_event = True
else:
feedback_message_event = "Good job! Your data has been recorded."
repeat_practice_event = False
# Save keypress data for logging
thisExp.addData('key_press_count_event', key_press_count_event)
thisExp.addData('practice_movie_key_resp_event.keys', practice_movie_key_resp_event.keys)
The custom code in ‘Practice_Feedback_Event’ routine is:
“End Routine”:
# Increment the practice repetition counter
practice_event_reps += 1
# Allow only one additional repetition if feedback is bad
if repeat_practice_event and practice_event_reps < 2:
practice_loop_event.finished = False # Continue the loop
else:
practice_loop_event.finished = True # End the loop
The codes are similar for the second loop ‘practice_loop_goal’, except that everywhere event is replaced with goal in naming routines, components and variables in code. This loop is the one which is not running the movie properly.
Does anyone know why the loop functions correctly in Condition 1 but not in Condition 2? Any advice on debugging or potential issues with online execution would be greatly appreciated.