Hello all,
Setup:
- Psychtoolbox 2.52
- MacOS 9.2.2 (native mode, not OSX's Classic)
- Matlab 5.2.1
Problem:
I have been conducting fMRI experiments in which participants are
viewing a sequence of movies in one of several conditions. To switch
between conditions, the scanner issues mouse-clicks to the display
computer at the appropriate time. Because movies have to be displayed
continuously, mouse clicks (and key presses from the observer) must
be monitored while movies are playing. So far, the display computer
misses mouse clicks approximately 1% to 5% of the time, although the
program has yet to miss a mouse click if I issue them manually.
I have appended a dummy script that captures the essence of what we
do in the scanner: it displays a random-noise movie and detects mouse
clicks along the way.
Any insight that someone would care to share one this would be highly welcome.
Cheers,
Stéphane Rainville
%================================================
% START
clear all;
close all;
p.nReps = 25;
p.imSize = 256;
p.nFrames = 15;
% Open window and build movie
myLut = repmat([0:255]', [1 3]);
onWindow = SCREEN(0, 'OpenWindow', 0, SetRect(0, 0, p.imSize, p.imSize));
SCREEN(0, 'SetClut', myLut);
for frameIndex = 1:p.nFrames
offWindow{frameIndex} = SCREEN(0, 'OpenOffscreenWindow', 0,
SetRect(0, 0, p.imSize, p.imSize));
myImage = 255 * rand(p.imSize, p.imSize);
SCREEN(offWindow{frameIndex}, 'PutImage', myImage);
end
% Display movie and detect mouse clicks
FlushEvents('mouseUp', 'mouseDown');
downFlag = 0; upFlag = 0;
mouseClickCount = 0;
for repIndex = 1:p.nReps
for frameIndex = 1:p.nFrames
SCREEN('CopyWindow', offWindow{frameIndex}, onWindow);
SCREEN(0, 'WaitBlanking');
% Detect mouse click
if EventAvail('mouseDown')
downFlag = 1;
FlushEvents('mouseDown');
elseif EventAvail('mouseUp')
upFlag = 1;
FlushEvents('mouseUp');
end
if downFlag & upFlag
mouseClickCount = mouseClickCount + 1;
fprintf('Mouse Click #%i\n\n', mouseClickCount);
downFlag = 0; upFlag = 0;
end
end
end
% Clean up
SCREEN('CloseAll');
% END
%================================================
--
-------------------------------------------------------
Stéphane Rainville PhD
Center for Vision Research
York University
4700 Keele Street
North York ON
M3J 1P3
Canada
email: rainvill@...
phone: (416)-736-2100 x.33325
fax: (416)-736-5857
Setup:
- Psychtoolbox 2.52
- MacOS 9.2.2 (native mode, not OSX's Classic)
- Matlab 5.2.1
Problem:
I have been conducting fMRI experiments in which participants are
viewing a sequence of movies in one of several conditions. To switch
between conditions, the scanner issues mouse-clicks to the display
computer at the appropriate time. Because movies have to be displayed
continuously, mouse clicks (and key presses from the observer) must
be monitored while movies are playing. So far, the display computer
misses mouse clicks approximately 1% to 5% of the time, although the
program has yet to miss a mouse click if I issue them manually.
I have appended a dummy script that captures the essence of what we
do in the scanner: it displays a random-noise movie and detects mouse
clicks along the way.
Any insight that someone would care to share one this would be highly welcome.
Cheers,
Stéphane Rainville
%================================================
% START
clear all;
close all;
p.nReps = 25;
p.imSize = 256;
p.nFrames = 15;
% Open window and build movie
myLut = repmat([0:255]', [1 3]);
onWindow = SCREEN(0, 'OpenWindow', 0, SetRect(0, 0, p.imSize, p.imSize));
SCREEN(0, 'SetClut', myLut);
for frameIndex = 1:p.nFrames
offWindow{frameIndex} = SCREEN(0, 'OpenOffscreenWindow', 0,
SetRect(0, 0, p.imSize, p.imSize));
myImage = 255 * rand(p.imSize, p.imSize);
SCREEN(offWindow{frameIndex}, 'PutImage', myImage);
end
% Display movie and detect mouse clicks
FlushEvents('mouseUp', 'mouseDown');
downFlag = 0; upFlag = 0;
mouseClickCount = 0;
for repIndex = 1:p.nReps
for frameIndex = 1:p.nFrames
SCREEN('CopyWindow', offWindow{frameIndex}, onWindow);
SCREEN(0, 'WaitBlanking');
% Detect mouse click
if EventAvail('mouseDown')
downFlag = 1;
FlushEvents('mouseDown');
elseif EventAvail('mouseUp')
upFlag = 1;
FlushEvents('mouseUp');
end
if downFlag & upFlag
mouseClickCount = mouseClickCount + 1;
fprintf('Mouse Click #%i\n\n', mouseClickCount);
downFlag = 0; upFlag = 0;
end
end
end
% Clean up
SCREEN('CloseAll');
% END
%================================================
--
-------------------------------------------------------
Stéphane Rainville PhD
Center for Vision Research
York University
4700 Keele Street
North York ON
M3J 1P3
Canada
email: rainvill@...
phone: (416)-736-2100 x.33325
fax: (416)-736-5857