Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recording a video of 8 bars with blanks #9

Open
ahmadi123 opened this issue Mar 5, 2018 · 2 comments
Open

Recording a video of 8 bars with blanks #9

ahmadi123 opened this issue Mar 5, 2018 · 2 comments

Comments

@ahmadi123
Copy link

Dear Vistalab,
I'd like to record a video of pRF mapping stimuli but haven't been successful in forcing Psychtoolbox to do so. I have tried adding VideoRecordingDemo('pRF.avi',0, 0,1,1) at the beginning of doRetinotopyScan.m. It starts recording but fails to continue due to codec issues. Although this is a Psychtoolbox, not a Vistadisp issue, I would greatly appreciate your advice on how to record a video of bar stimuli?
Many thanks in advance and kind regards,
Ahmadi

@JWinawer
Copy link
Member

JWinawer commented Mar 5, 2018

Try this.

Note that it will take a lot of memory, though, since concatenating all the images makes for a very large array before it gets compressed into an MP4. Once saved, it is about 5 MB.

% Get PRF directory (requires Remote Data Toolbox)

erniePRF = mrtInstallSampleData('functional', 'erniePRF');

cd(erniePRF);

 

% Load  images and parameters from the pRF experiment

load('8_bars_images');

load('8_bars_params');

 

% Get frame rate

isi = median(diff(stimulus.seqtiming));

frameRate = round(1/isi);

 

% Initialize a movie

myMovie = images(:,:,stimulus.seq);

 

% Pad with singleton dimension so Matlab knows it's a gray-scale movie

%   ( x * y * 1 * n)

sz = size(myMovie);

myMovie = reshape(myMovie, sz(1),sz(2),1,sz(3));

 

% Initialize a video writer

v = VideoWriter('PRF.mp4', 'MPEG-4');

v.FrameRate = frameRate;

 

% Open it, write it, and close it

open(v);

writeVideo(v,myMovie)

close(v);

@ahmadi123
Copy link
Author

Many thanks! It worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants