portugueslab / stytra

A modular package to control stimulation and track behaviour
http://www.portugueslab.com/stytra/
GNU General Public License v3.0
41 stars 26 forks source link

How to record stimuli movies? #67

Closed birtezuidinga closed 2 years ago

birtezuidinga commented 2 years ago

I am sorry, this is probably a trivial question, but I cannot figure out how to use the record_stimuli.py code to save a video of a certain stimulus.

When I just run the record_stimuli.py file, it finishes without errors but I cannot find any videos on my computer. Do I need to run it in a different way? Should I define the directory somewhere?

Thank you in advance!

vilim commented 2 years ago

The script you mentioned record_stimuli.py is actually just used to generate the stimulus movies for the documentation, we should add a proper example on how it's to be used. Briefly, when instantiating Stytra, supply an record_stim_framerate parameter (30 is usually a reasonable number), and the movie will be recorded as a h5 - a lossless format which is then easy to read in python. You can also specify mp4 in the stim_movie_format parameter, this then you can view in any video player.

All in all it would work like this:

# define some experimental protocol here, let's call it MyProtocol
...

if __name__ == "__main__":
    st = Stytra(protocol=MyProtocol(), record_stim_framerate=30, stim_movie_format="mp4")

After running the experiment, the stimulus video will be in the same folder as all the output files of the experiment, specified through the user interface. Please let us know if anything is still unclear

birtezuidinga commented 2 years ago

Thanks a lot! Works like a charm!