I want to do saccade contingent work in my experiment?

Antje Nuthmann wrote a long message on the forum related to this with some interesting thoughts and questions. Some answers and remarks can be found after this message:

I'm working with eyelink II, Mac OS 9.2, MATLAB 5.2.1.1421,
PsychToolbox 2.52 as well as the Eyelink Toolbox.
I want to work saccade contingent in a reading experiment.
I think I could control for the delay caused by the eyelink system as
well as for the restrictions set by the monitor refresh rate (120 Hz)
quite well.

My main problem now is MATLAB. It's slow. Setting the PixelSize
(color depth) from 32 down to 16 seemed to make things faster. Still,
according to my timing by using getSecs it takes on average 10 ms
(!!!) (sometime up to 20 ms) to run the relevant code used for online
saccade detection etc. By the way, this is not due to CopyWindow,
since I change only a small part of the screen during the saccade.

To begin with I was encouraged by reading in Cornelissen et al.
(2002) that "only a fraction of a millisecond is due to the overhead
of MATLAB...". As I now understand, the functions of the Eyelink
Toolbox are fast because they rely on underlying C functions, BUT the
functions I programmed myself are slow since I use "native MATLAB
code".
What can I do about it?

THOUGHTS:

1) SpeedTest by the Psychophysics Toolbox made some suggestions for
optimizing the MATLAB code (e.g., ~= is slower than 2 equal signs). I'm
working not only with scalars and arrays, but also with structured
arrays.
Does anybody know whether accessing structured arrays costs more time
than accessing normal arrays? I'm also wondering whether working
with global variables is less time consuming than passing variables
as arguments of a function? Any suggestions in general?

2) Since there is quite a big variability in the time it takes to run
the relevant code, I thought it might be helpful to use the RUSH
function.
I finally found out how to use it but I am still puzzled.
Obviously it is possible to rush eyelink commands like eyelink
(`newestfloatsample'), at least I didn't get any error messages.
I'm puzzled about MaxPriority. Obviously I cannot pass my self-
programmed functions. But I cannot pass `eyelink' either, maybe
because it is not a function (but a MEX file)? Maybe I can use
MaxPriority for inbuilt functions only? I sort of sense that the Mac
needs to know what kind of priority the eyelink system needs or has.
Maybe it is set somewhere?
Anyway, I finally succeeded in using rush (in terms of not getting
any error messages anymore), but it also led to the highly undesired
fact that no messages were written in the message file ("xxx messages
lost" appeared at the end of the file).
So I ended up rushing only part of the relevant code, but according
to timing by using getSecs that didn't help.

3) I've heard that one can 'c compile' matlab functions. Would that
help and how can I do that?

4) In example code by SR research I saw the functions
begin_realtime_mode &
end_realtime_mode
Is there an equivalent in the Eyelink Toolbox? Or am I supposed the
handle it with the rush function?

... any suggestions, explanations, own experiences are highly
appreciated

thanks a lot
Antje Nuthmann

A few short remarks:

Maxpriority doesn't know about eyelink because it is not part of the Psychtoolbox per se.

Are you refering to the online saccade detection by the eyelink (operator PC) itself, or did you program this code yourself?

I am not aware of begin_realtime_mode & end_realtime_mode functions. I presume these are part of the new API's. If so, they're not part of the eyelinktoolbox (for that reason).

In the eyelinktoolbox code there are two examples (eyelinkexample.m & eyelinkeventexample.m) of how to create reasonably fast gaze contingent experiments.

But, c will always out perform matlab code. So, if you need to do a lot in real-time, and can't prepare your stimuli, I would suggest to use c. You can of course also use a hybrid approach, and only c-code the time critical part of your experiment, and create a mex file for that.
I don't believe you can compile PsychToolbox and eyelink toolbox code as such (I have never tried).

There's also a few ways in which you can improve performance of the eyelink, e.g. do not use filtering, shaves 4 ms of the response time (but gives less accurate saccade estimates).

Valid XHTML :: Valid CSS: :: Powered by WikkaWiki