Using MovieStim

Hi there,

I am very novice in coding but I was trying to find an example of how to actually used the MovieStim(). I want to use it in a simple application to rate short soundless videos (full scripts/application from https://dl.dropboxusercontent.com/u/57834968/vid_rating_app.zip ), but I could not figure out how it works (I have seen some people use MovieStim2 or 3 -do these actually exists? I couldn’t find them in the documentation).

I would really appreciate it if somebody provided me with an example. I’m including below the key components of what I’ve tried so far:

from psychopy.visual import ImageStim, MovieStim, FINISHED

self.videos = MovieStim(pygaze.expdisplay, pos = (0, 100))

video_list = os.listdir(“vids”)
random.shuffle(video_list)

for video_name in video_list:
----self.disp.fill(self.fixation)
----self.disp.show()
----libtime.pause(500)

----self.videos.loadMovie(video_name)
----self.videos.play()
----while True:
--------self.disp.fill(self.visual_stimuli)
--------self.disp.show()
--------if self.videos.status != FINISHED:
------------break

Many thanks in advance

Santi

Start with the psychopy demos menu. That has many demos of different stimuli including moviestim. You appear to be using something else here because self.disp.fill() is not a PsychoPy function.

Hi Jon,

Thanks for the suggestion, I will definitely have a look at the demos menu (I must’ve missed it) and, if still unsuccessful, I will drop you another line.

I’m also using pygaze libraries (I hope that won’t represent a problem).

Santi

That depends on what you’re using to create the window and perform the rendering. I believe pygaze users sometimes use simple pygame windows without OpenGL acceleration and those are incompatible with psychopy stimuli. If you use PsychoPy for all your window/stimulus controls and just use pygaze for eyetracking then I think you’ll be fine.

I’m glad that you mentioned it. I’ll bear that in mind.

Thanks a lot!

Hi there again,

I think I figured out how to use the MovieStim2 now, but I keep getting the error message below… Any thoughts? (I have made sure that I have all prerequisites and installed necessary packages).

from psychopy.visual import ImageStim, MovieStim2, FINISHED

   self.visual_stimuli = libscreen.Screen()
   self.video = MovieStim2(pygaze.expdisplay, filename = 'vids/spv1.avi', pos = (0, 100), loop = False) 
   self.visual_stimuli.screen.append(self.video)

    video_list = os.listdir("vids")
    random.shuffle(video_list)
    
    for video_name in video_list:
        self.disp.fill(self.fixation)      
        self.disp.show()
        libtime.pause(500)
        print(video_name)
        self.video.loadMovie(video_name)
        self.video.play()
        while True:
            self.disp.fill(self.visual_stimuli)
            self.video.draw()
            self.disp.show()
            if self.video.status != FINISHED:
                break

File “E:/Santi/Stimuli_rating_app/stimuli_rating2.py”, line 60, in initialize_screens
self.video = MovieStim2(pygaze.expdisplay, filename = ‘vids/spv1.avi’, pos = (0, 100), loop = False)

File “C:\Python27\lib\site-packages\psychopy-1.84.0-py2.7.egg\psychopy\contrib\lazy_import.py”, line 120, in call
return obj(*args, **kwargs)

File “C:\Python27\lib\site-packages\psychopy-1.84.0-py2.7.egg\psychopy\visual\movie2.py”, line 235, in init
self.loadMovie(self.filename)

File “C:\Python27\lib\site-packages\psychopy-1.84.0-py2.7.egg\psychopy\visual\movie2.py”, line 318, in loadMovie
raise RuntimeError(“Error when reading image file”)

RuntimeError: Error when reading image file

If you just use the code in the movie demo and use you file name/path does it work then? (I don’t know what this display.fill() thing is and whether it could cause a problem for you)

Also, there are 3 different movie stimulus options, each using a different library for loading movies. You’re currently using MovieStim2 but you could try MovieStim and Moviestim3 with no other changes to your code to test them instead.

Hi Jon, it must be then that the pygaze line of code is interfering (I did tried all of the other functions and their respective libraries).

I will try to just used psychopy to display this part...

Many thanks!

Well it might be your movie file is the problem, which is why I suggested that you try loading that just using the code from the movie demo script in PsychoPy Coder

Hi there again,

Unfortunately, I haven’t been able to get to the bottom of this problem with MovieStim2().

For the sake of testing I have tried to play some of my videos using your MovieStim2() demo script but I still get the same error (below). So I guess I have to accept that the problem is related to the files I am using… Is there any particular characteristics of the videos that make them “readable” (by the way my videos are played just fine using the standalone vlc application) or do you have a “readable” video sample I can use (to see its properties)?.

Once again, I’d really appreciate any help in this regard.

File “<ipython-input-1-eba62c432ceb>”, line 1, in <module> runfile(‘C:/Users/15238039/Documents/Experiments/MovieStim_try.py’, wdir=‘C:/Users/15238039/Documents/Experiments’)

File “C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py”, line 685, in runfile execfile(filename, namespace)

File “C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py”, line 71, in execfile exec(compile(scripttext, filename, ‘exec’), glob, loc)

File “C:/Users/15238039/Documents/Experiments/MovieStim_try.py”, line 19, in <module> loop=False)

File “C:\Python27\lib\site-packages\psychopy-1.84.1-py2.7.egg\psychopy\contrib\lazy_import.py”, line 120, in call return obj(*args, **kwargs)

File “C:\Python27\lib\site-packages\psychopy-1.84.1-py2.7.egg\psychopy\visual\movie2.py”, line 242, in init self.loadMovie(self.filename)

File “C:\Python27\lib\site-packages\psychopy-1.84.1-py2.7.egg\psychopy\visual\movie2.py”, line 325, in loadMovie raise RuntimeError(“Error when reading image file”)

RuntimeError: Error when reading image file