Search code examples
pythonpython-2.7videopsychopy

Adding visual time markers to the player bar of a video


I'm trying to program an experiment in which I want to find out how humans cognitively segment movement streams. For example, if the movement stream could is a person climbing a flight of stairs, each step might be a single segment. The study is bascially a replication of this one here, but with another set of stimuli: http://dl.acm.org/citation.cfm?doid=2010325.2010326

Each trial should be structured like the following:

  1. Present a video of a motion stream. Display a bar beneath the video that has a marker that moves in sync with the current time of the video (very similar to GUI of a video player).

  2. Present that video again, but now let the participant add stationary markers to the bar beneath the video by pressing a key. The marker is supposed to be placed at the time point in the video bar that corresponds with the time the buttom was pressed (e.g. when the video is 100 seconds long and the buttom was pressed 10 seconds into the video, it should be placed at the 10% mark of the bar).

My instructor suggested programming the whole thing using PsychoPy. PsychoPy currently only supports Python 2.7. I've looked into the program and it looks promising. One can display a video easily and the rating scale class is similar to the bar we want to implement. However, several features are missing, namely:

  • One can only set a single marker, subjects should be able to set multiples
  • As mentioned in point (1) we want to have a marker that moves in synch with the video.
  • When a key press occurs a marker should be placed at the point in the bar that corresponds with the current time point in the video.

Hence my questions: Do you have any tips for implementing the features described above using the PsychoPy module?

I don't know how much this gets into recommendation question territory, but in case you know of a module for writing experiment GUIs that has widgets with the features we want for this experiment I would be curious to hear about them.


Solution

  • PsychoPy is a good choice for this. The rating scale however (as you note) is probably not the right tool for creating the markers. You can make simple polygon shapes though, which could serve as your multiple markers as well as the continuous time indicator.

    e.g. you could make a polygon stimulus with three vertices (to make a triangle indicator) and set its location to be something like this (assuming you are using normalised coordinates):

    $[((t/movie_duration) * 2 - 1) , -0.9]

    t is a Builder variable that represents the time elapsed in the current trial in seconds. The centre of the screen is at coordinates [0, 0]. So the code above would make the pointer move smoothly from the left hand edge of the screen to the right, close to the bottom edge of the screen, reaching the right hand edge once the move ends. Set the polygon's position field to update every frame so that the animation is continuous.

    movie_duration is a placeholder variable for the duration of the movie in seconds. You could specify this in your conditions file, or you can query the movie component to get its duration I think, something like:

    $[((t/movie_stim_name.duration()) * 2 - 1) , -0.9]

    You could leave markers on the screen in response to keypresses in a similar way, but this would require a little Python code in a code component.