A
MATLAB-based
eye
tracking
control
system
using
non-invasive
helmet
head
restraint
in
the
macaque
Paolo
De
Luna
1,
Mohamed
Faiz
Bin
Mohamed
Mustafar
1,
Gregor
Rainer
∗VisualCognitionLaboratory,DepartmentofMedicine,UniversityofFribourg,CheminduMusée5,FribourgCH-1700,Switzerland
h
i
g
h
l
i
g
h
t
s
•WehavedevelopedaMATLABbasedeyetrackingcontrolsystemwithexcellenttimingperformance.
•Theexperimentwasperformedusingnon-invasiveheadrestraint.
•Thesystemperformancereportedadequatestabilityinbothshortandlongtimescales.
Background:Trackingeyepositionisvitalforbehavioralandneurophysiologicalinvestigationsinsystems andcognitiveneuroscience.Infraredcamerasystemswhicharenowavailablecanbeusedforeyetracking withouttheneedtosurgicallyimplantmagneticsearchcoils.Thesesystemsaregenerallyemployedusing rigidheadfixationinmonkeys,whichmaintainstheeyeinaconstantpositionandfacilitateseyetracking. Newmethod:Weinvestigatetheuseofnon-rigidheadfixationusingahelmetthatconstrainsonly gen-eralheadorientationandallowssomefreedomofmovement.WepresentaMATLABsoftwaresolution togatherandprocesseyepositiondata,presentvisualstimuli,interactwithvariousdevices,provide experimenterfeedbackandstoredataforofflineanalysis.
Comparisonwithexistingmethod:Oursoftwaresolutionachievesexcellenttimingperformancedueto theuseofdatastreaming,insteadofthetraditionallyemployeddatastoragemodeforprocessinganalog eyepositiondata.
Results:Wepresentbehavioraldatafromtwomonkeys,demonstratingthatadequateperformancelevels canbeachievedonasimplefixationparadigmandshowhowperformancedependsonparameterssuch asfixationwindowsize.Ourfindingssuggestthatnon-rigidheadrestraintcanbeemployedforbehavioral trainingandtestingonavarietyofgaze-dependentvisualparadigms,reducingtheneedforrigidhead restraintsystemsforsomeapplications.
Conclusion:Whiledevelopedformacaque monkey,oursystemofcoursecanworkequallywellfor applicationsinhumaneyetrackingwhereheadconstraintisundesirable.
1. Introduction
Thescleralsearchcoil(Judgeetal.,1980;Robinson,1963)has
beenusedextensivelysinceitsintroductioninthe1960sfor
mon-itoringofeyepositioninthecontextofstudiesofvisually-based
behaviorinmacaquemonkeys.Itsuserequiresa surgical
inter-vention,whereaninsulatedwirecoilisattachedtothescleraby
glueorsutures,andthewireislinkedtoaconnectorimplanted
∗ Correspondingauthor.Tel.:+41263008689;fax:+41263009734. E-mailaddress:gregor.rainer@unifr.ch(G.Rainer).
1 Theseauthorscontributedequallytothiswork.
ontheanimal’shead.Suchimplantshavealimitedlifespanand
oftenrequire repairor replacement,potentially involving
addi-tionalinterventions.Inthelate1990sopticaleyetrackingsystems
becameavailable;theytrackthepositionofthepupililluminated
byanappropriatelightsourceusinganinfraredsensitivecamera.
Infraredeyetrackingsystemsarenon-invasiveanddonotrequire
anysurgical procedures,and are therefore increasinglyused in
behavioralandneurophysiologicalstudies.Itisimportanttonote
thatwhile theeyetrackingitself isnon-invasive,it isgenerally
usedin conjunction witha head-postthat is implantedon the
skullof themonkey andattachedtotheexperimentalsetupby
arigidconnection.Thehead-postensuresthatthepositionofthe
headandparticularlytheeyeremainsfixedduringthebehavioral
Published in -RXUQDORI1HXURVFLHQFH0HWKRGV±
which should be cited to refer to this work.
session.Analternativetothismightbeanon-rigidhead
restrain-ingsystem,whichmaintainstheheadinanapproximatelyconstant
positionwithoutarigidconnectiontothesetup,thuspermitting
somemovements.Indeed,eyetrackinginhumansubjectsoften
employsnon-rigidheadrestraintusinga chin-restandbitebar.
Eye-trackingusinghead-mountedeyetrackers,asitisalsoused
inhumansubjects,arenot easilytoleratedbymonkeysubjects.
Non-rigidheadrestraintwouldallowthetrainingofmonkeyson
gazedependentbehavioralparadigmswithouttheneedof
surgi-calinterventionssuchthatthesecouldbepostponedtoafterthe
trainingiscompleted.Arecentpublicationhasdescribeda
thermo-deformableplastichelmetthatcanbeeasilyadaptedtotheshape
ofindividualmonkeys’head(MachadoandNelson,2011).Inthis
study,wedemonstratethateyetrackingofsufficientqualityfor
manyapplicationsispossibleusingsuchahelmet-basedrestraint
system,anddescribeperformancecharacteristicsandlimitations
ofeyetrackingundertheseconditions.
Forcontrollingthesequenceofeventsduringavisualtask,
com-putersoftwareisnecessarytogathereyepositiondatafromtheeye
tracker,presentvisualstimuli,anddeliverrewardsatappropriate
timeswhileatthesametimeprovideonlinefeedbacktothe
exper-imenter.Therearenumerousproprietaryaswellasopen-source
softwarepackagesavailableforthispurpose.Foreaseof
program-mingandadaptationofcode,solutionswritteninawidelyused
high-levelinterpretedprogramminglanguagesuchasMATLABare
preferable,particularlysincePsychophysicstoolbox,awidelyused
packageforvisualstimulusdisplay isalsoavailablein this
pro-grammingenvironment.UsingMATLABtoperformonlinecontrol
isinherentlysomewhatproblematic, becausethis programming
languagewasnotdesignedforreal-timecontrol.Nevertheless,we
areawareoftwosoftwaresolutionsthatemployMATLABtogether
withPsychophysics Toolbox for the control of gaze-dependent
behavior(AsaadandEskandar,2008;Asaadetal.,2013;Meyerand
Constantinidis,2005).Ourownsoftwareimplementationisbased
onthesetwosystems.Wehaveintroducedseveralnewelements
thatenhanceperformanceandreliability,makingaparticulareffort
toproducecompactcodethatcanberelativelyaccessiblefor
begin-ners.
2. Materialsandmethods
2.1. Subjects
Two11year-oldmalemacaquemonkeys(Macacafascicularis),
referredtoasMonkeyC(6.8±0.2kg,mean±standarddeviation)
andMonkeyD(8.2±0.1kg),participatedintheexperiments.
Ani-mals were maintained on a diet of fresh fruit, vegetablesand
monkeychowwithwateravailableadlibitum.Duringthe
exper-iments,foreachsuccessfulfixationthemonkeyswererewarded
witha45mgpurifieddustlesspellet(Bananaflavor5TUQtab,
Test-Diet,1050ProgressDrive,RichmondIN48384,USA),deliveredvia
ametaltube.Monkeysperformedanaverageof183±11(S.E.M.)
trialsperexperimentalsession, andhadnohead-postsorother
implants.Headrestraintwasachievednon-invasivelyusing
ther-moplastichelmets(Uni-frameThermoplasticsMTAPUI2232,Civco
MedicalSolutions)adjustedtoeachindividualmonkey(Machado
andNelson,2011).Thethermoplasticmaterialwasmadeflexible
bysubmergingthesheetina80◦Cwaterbathfor2min.Duringthe
next2min,beforethematerialregaineditshardness,thehelmet
waspre-shapedonatoydollhead,finelyadjustedbyhand,andtwo
openingsforeyesandmouthwerecutwithscissors.Final
adjust-mentofthehelmettoeachmonkeydidnotrequiresedationofthe
animals,andwasperformediterativelysuchthatagoodfitthat
permittedchewingmovementswasobtainedafteraboutfour
iter-ations.Importantly,thehelmetfitwasadjustedtogivemonkeys
acertainamountoffreedominheadposition,bothlaterallyaswell
asvertically,toallowforchewingofrewardsaswellas
minimiz-ingdiscomfort.Allanimalprocedureswereinfullcompliancewith
SwissandEuropeanUnionanimalexperimentalregulationsand
approvedbytheFribourgcantonalveterinaryauthorities.
2.2. Setup
Themonkeywasseatedinaprimatechair(custom-madeat
Uni-versityofFribourg),onawheeledtrolleyatthebasewhichcouldbe
lockedinafixedpositioninsideawoodenrecordingboxasshown
inFig.1A. Aninfra-red camera(ISCANETL-200system,x2 lens
attached)wasmountedatanelevationangleof27◦atadistanceof
65cmfromtheanimal.Theinfraredlightsourcewasattachedto
theleftsideofthecameraobjectivelens,andtiltedforoptimal
illu-minationofthelefteye(Fig.1B).Theinsideoftheboxwascovered
withmatteblackplasticpanels.Visualtargetswerepresentedona
cathoderaytube(CompaqP90019-inchCRTmonitoratresolution
of1280×1024pixels,withtherefreshrateof75Hz)monitor
pos-itioned65cmdirectlyinfrontoftheanimal.Weemployedblack
squaresof0.5◦diameter(20×20pixels),arrangedalongacircleof
radiusof6◦regularlyspaced45◦ aroundtheninthsquareinthe
centerofthecircle(Fig.1C).Targetswerepresentedona
back-groundofintermediateintensity(50%grayscale),correspondingto
aluminanceof13cd/m2,measuredusingaMinoltaTVCA-IIcolor
analyzer.Alternatively,sixred0.8◦diameterlightemittingdiodes
(LED)onablackpanelmountedatadistanceof30cmfromthe
animalcouldalsoserveasvisualtargets(Fig.1D).Duringthe
behav-ioralsessions,auditorywhitenoise wasdeliveredviaa speaker
insidetheboxtomaskexternaldistractions.Thespeakerwasalso
usedtodelivera1kHzpuretonefor1sasauditoryfeedbackfor
eachcorrecttrial.
2.3. Hardwareconfiguration
We used an infrared eye tracking system (ISCAN ETL-200).
Indetail, thecamerawasconnectedviaaPCI acquisitionboard
(ISCANRK8X6PCI-0)toacomputerrunningtheeye-track
acquisi-tionsoftware(DQWversion1.20N).Thecomputerwasequipped
witha 2.4GHzIntel Core2Duoprocessor, 4GBofRAM anda
3-channel analog output card. The Eye-Tracking System’s analog
output was interfaced via a single PCI-6221 acquisition board
(NationalInstruments)connectedtoaBNC-2110connectorblock
(NationalInstruments)toasecondPCthathostedtheExperiment
ControlSystem(Fig.2).Weusedtwoanalogchannelstorelay
hor-izontalandverticaleyeposition.TheISCANsystemwasconfigured
totrackeyepositionusingthedifferencebetweenthepupiland
cornealreflection,asiscommonlydoneineyetrackingsystems
withoutrigidheadrestraint.Itiscrucialtousethisdifference
sig-nalfornon-invasive eyetracking,asit is lesssensitivetohead
translationsthantherawpupilsignal.
TheExperimentControlSystem(HPCompaq8200Elite,
Win-dows 7) wasequipped with a 3.3GHz Intel i5-2500 processor
and 4GB of memory. An NVidia GeForce 7300GT video card
wasinstalled for managing two displays at a resolution up to
1280×1024pixels.Thesubjectdisplayviewedbytheanimalwas
duplicatedusingaVGAsplitter tobevisiblealsotothe
experi-menter.Inaddition,anexperimenterdisplaywasusedtoprovide
onlinefeedbackabouttheanimal’sbehaviortotheexperimenter.
The“Extend these displays”option of Windows 7 wasusedto
simultaneouslymanage experimenterand subject displays.The
PCI-6221boardwasalsousedtoilluminatevisualtargetLEDsand
todeliverrewardpellets(ENV-203-45pelletdispenser,Med
Asso-ciates,St.Albans,VT05478,USA).Anoverviewoftheconnections
betweenthesetupcomponentsisshowninFig.2.Tooptimize
per-formanceoftheISCANandexperimentalcontrolsystemPCs,all
Fig.1. Behavioralexperimentsetup.(A)Sideviewoftherecordingboxwherebehavioraldatawasrecorded.Monkey’sheadpositionismarkedbyaneyesymbol.Onthe lefttheCRTscreenand,ontopofit,theinfra-redcameraaredrawn;thewhiterectangleinthemiddleistheblackLEDpanel.(B)Topviewofrecordingbox.LEDpaneland CRTscreenhorizontalsizewere22◦and16◦respectively.TheCRTmonitor,theLEDpanelandtheinfra-redcamerawerecenteredonmonkey’sheadposition(eyesymbol).
(C)PositionsofvisualstimulionCRTmonitor.Eightblacksquaretargetsalonga6◦circlesurroundaninthblacksquaredcentralfixationpoint.Eachstimulusisabout0.5◦
(20×20pixels).(D)PositionsofvisualstimulionLEDpanelarrangedontworowsofthreeelements.EachstimuluswasaredLEDofapproximately0.8◦diameter(3mm).
non-criticalprocessesincludinginterface-,security-,network-and
devices-relatedoneswereterminatedandneithercomputerwas
connectedtoanynetwork.
2.4. MATLABconfiguration
AllthedatawereacquiredbyandstoredintotheExperiment
ControlSystemusingacustom-madescriptruninMATLAB
(ver-sionR2010a,TheMathworksInc.).Thescriptusedfunctionsfrom
theMATLABDataAcquisitionToolbox(DAQ,version2.16)and
Psy-chophysicsToolbox(PTB)version3.0.11(Brainard,1997;Kleiner
etal.,2007;Pelli,1997).Thescriptpresentsaseriesofrandomly
selectedsinglevisualtargetsandprovidesrewardtotheanimalif
thattargetisfixatedforapredeterminedperiodoftime.Thistype
Fig.2. Overviewofconnectionsofhardwarecomponents.Eyepositionsignalswere computedbyISCANsoftwareandsentviaaNIBNC2110connectorblocktoaNI BNC6221acquisitionboardtotheExperimentControlsystem.Thegazeposition wasmonitoredwithMATLABduringpresentationofvisualstimulieitheronaCRT monitor(andtoamirrordisplayvisibletotheexperimenter),oronanLEDpanelvia theNIPCI6221digitaloutputchannels.MATLABalsopresentedthelastacquired gazepositiontotheexperimenter.FinallyonedigitaloutputchanneloftheNIPCI 6221wasusedforcontrollinganelectricvalveforrewarddelivery.
ofscriptisroutinelyemployedforthecalibrationofeyeposition.
Threefragmentsofthesourcecodeareprovidedbelow,illustrating
importantelementsofDAQconfiguration,databufferingandonline
behavioralcontrol.Thefullscriptcanbeobtainedfromour
web-site( http://www.unifr.ch/inph/vclab/home/internal/eye-tracking-software).
2.4.1. DAQconfiguration
Ideally,onewantstostreamthemostrecentsampleacquiredby
theboardassoonaspossibleforonlinecontrolwhileatthesame
timestoringsamplesontheboardtobepickedupattheendofeach
behavioraltrial.However,simultaneousstoringandstreamingof
datathroughtheDAQtoolboxisassociatedwithsevere
perfor-manceimpairments(seeSection3).Forthisreason,oursolution
focusesonlyonstreaminganddoesnotrelyonstoringdataonthe
board.Thefollowingcodesnippetillustratesoursolutionforanalog
dataacquisition. ai=analoginput(’nidaq’,’Dev1’); addchannel(ai,[01]); ai.SampleRate=1000; ai.SamplesPerTrigger=2; ai.TriggerRepeat=0; start(ai); startLoop=GetSecs;
while(GetSecs−startLoop<time4fix), thisSample=getsample(ai); ...
end
Theboardisconfiguredtostoreonlytwosamples,the
mini-mumpermittedbyMATLAB.Afterstartingdatalogging,onlythe
firsttwosamplesarestoredontheboard,whereasallthe
subse-quentsamplesarenotstoredandthuscannotberecoveredlateron
byagetdatafunctioncall.However,subsequentsamplescanbe
pre-viewedusingthegetsamplefunction.Inthiscase,themostrecently
acquiredsampleismadeavailabletoMATLABwithout
compro-misingperformance.Ourapproachthusoptimizesdatastreaming
toMATLAB.Asaresult,onlythedatathatareactuallystreamed
toMATLABusinggetsampleforonlinecontrolcanberetainedfor
subsequentdataanalysis.
2.4.2. Circularbuffer
Since infrared eyetrackingdata canbenoisy,it is usefulto
includesometemporalaveragingtoreducethevariabilityinthe
acquireddata.ForthispurposeweuseaFirst-InFirst-Out(FIFO)
circularbuffer,withtheparameterbuffer lengththatdetermines
overhowmanysubsequentsamples,acquiredusinggetsample,the
averagingprocesstakesplace.
bufferlength=25;
Buffer=zeros(bufferlength,2);
function[Buffer,eyeX,eyeY,sampleInfo]=bufferizeSamples(ai,Buffer,Gains,Offsets) %Puttogethertheinformationaboutthelastsample
timestamp=GetSecs; thisSample=getsample(ai); sampleInfo=[thisSampletimestamp];
%Updatethebufferwiththelastdatapointandtakeanewaveragepoint Buffer=[Buffer(2:end,:);thisSample];
avgBuff=mean(Buffer,1); %Convertvoltstodegrees
eyeX=(avgBuff(1)−Offsets(1))*Gains(1); eyeY=(avgBuff(2)−Offsets(2))*Gains(2); end
In ourMATLABscript,thisfunctioniscalledseveralhundred
timeseachsecond,andtimestampedusingthePTBGetSecs
func-tion.Thelastsamplereplacesthefirstoneinthebufferandanew
gazepositioniscomputedbyconvertingtheaverageinputsignal
fromvoltagetodegrees ofvisualangle,usingadhocgainsand
offsetsforboththeaxes.
2.4.3. Mainloop
Thefollowing codefragmentillustratesthemainloopofthe
behavioralcontrolsystem,wherethesystemchecksforwhether
theeyepositioniswithinaradiusofthetargetposition.Itusesthe
circularbufferanddatastreamingelementsdescribedabove.
startLoop=GetSecs;
whileGetSecs−startLoop<time4fix %1)Getandstoreanewsample
[Buffer,eyeX,eyeY,sampleInfo]=bufferizeSamples(ai,Buffer,Gains,Offsets); Data(trial).EyeDataX(index)=sampleInfo(1);
Data(trial).EyeDataY(index)=sampleInfo(2); Data(trial).Time(index)=sampleInfo(3);
index=index+1;
%2)Updateeyepositiononexperimenter’sdisplay set(eyePosH,’XData’,eyeX,’YData’,eyeY); drawnow;
%3)Checkforfixation
ifsqrt((TargetX−eyeX)∧2+(TargetY−eyeY)∧2)<=FixWinRadius
Data(trial).FixStart=GetSecs; break;
end end
Theloopconsistsofthreecomponents:(1)usingthecircular
buffer,anewgazepositionisevaluatedaspreviouslydescribed,
andthelastsampleandcorrespondingtimestamparestoredina
trial-wisemannerinpre-allocatedmatrices;ithastobenotedthat
wealsostoredthelengthofthebuffer,thegainsandtheoffsetsin
ordertoreconstructallthegazepositionsfromtherawdata;(2)
theexperimenter’sdisplayisupdatedwiththenewgazeposition;
(3)ifthegazepositionisinsidethefixationwindowtheloopis
interrupted;inthatcaseasimilarloopwillcheckifthesubjectis
keepingthefixation.Werefertothiscodefragmentwithallofits
threepartsasthe“Mainloop”.
2.5. Eyetracking
Weusedasimplefixationtasktocalibratetheeyeposition
sig-nal,andtotestthesystemperformanceasafunctionofseveral
parameters.Asdescribedabove,weemployedasetofnine
tar-getsarrangedinacircularfashiononaCRTmonitor,aswellassix
LEDtargetspositionedonapanelmountedinfrontoftheanimal.
Monkeysneededtofixateasingletargetforabriefperiodtoobtain
arewardpellet.Wevariedboththelengthofthecircularbuffer
(values:1,10,15,20and25samples)andtheradiusofthe
fixa-tionwindow(values:1.5◦and2◦ fortheCRTscreenand2◦,2.5◦
and3.5◦fortheLEDpanel).LargervalueswerechosenfortheLED
panelfixationwindowbecausetargetsweremoreeccentricinthat
case.Duringblocksof50trials,arandomcombinationoffixation
windowradiusandbufferlengthwaschosen.
Eachsessionstartedwiththemonkeyoutsidetherecordingbox
withoutthehelmet.Thenthehelmetwasfixedontheprimatechair
andthemonkeywasmovedinthebox.Atthebeginningofeach
sessionthecamerawascenteredonthemonkey’slefteyeandabout
20trialswereusedtoadjustthegainsandtheoffsetsforthe
hor-izontalandverticaldirectionsusinga25-samplebuffer.Onlyone
setofvisualstimuli(CRTscreenorLEDpanel)waspresentedduring
thesamesession.
Duringeachtrial,aftertheappearanceofthetargetonthepanel
(LED)orCRTscreen(squaredot),themonkeyhadtostartthe
fix-ationwithin2sandholditfor200mstoobtainarewardpellet
withsimultaneousauditoryfeedback.Theinter-trialintervalwas
7s.Attheendofeachblock,themonkeywasmovedagainoutside
theboxandthehelmetwasremoved;theinter-blockintervalwas
about2min.
3. Results
Weranextensivetestsonoursystem,andobservedthatthe
choiceof MATLABDAQacquisitionparameters hadavery large
impact on system performance, with non-optimal parameters
introducing substantial lags between acquisitions of individual
samplesaswellastiminginaccuracies.
3.1. Timingconsiderations
We first compared the performance of DAQ storing mode
(parametersettingai.SamplesPerTrigger=Inf;)thathasbeen
previ-ouslyproposedinseveralreportstoDAQstreamingmodewithout
storing(parameterai.SamplesPerTrigger=2;seeSection2).In
stor-ingmodetheboardiscollectingdataandmakingthemavailable
toMATLABatthesametime,whereasinstreamingmodeallthe
samplesarediscardedbytheboardand canonly bepreviewed
withgetsamplefunctioncalls.Forthistest,weusedtheMainloop
describedabove,andswitchedfromdatastoringtodatastreaming
attimet=0ms.Asynthesizedsinewaveat50Hzproducedbya
signalgenerator(GWInstekSFG2004)wasusedasaninputinthis
caseinsteadofaneyepositionsignal.Importantly,thegetsample
functionwasusedinbothmodestoobtainadatasampleforonline
eyemovementcontrol.TheresultsareshowninFig.3A.Clearly,
callinggetsampleindatastoringmodeisassociatedwith
unpre-dictablelagsbetweentheinputsignalandtheacquiredsample.
Theselagsarefurthermorevariable,andwefoundthemtobein
rangebetween10and40ms.Inaddition,previewingdatausing
getsampleindatastoringmodeproducedwidespreadsample
rep-etitions.Individualsamplescouldberepeateduptoonethousand
timesormore,becauseatthetimeofthegetsamplecalltheboard
isbusystoringdatatomemoryandthusreturnsthesame
previ-ouslyacquiredsample.Usingdatastreamingmodetheseproblems
disappear, and samples are now lying very close to the input
Fig.3.(A)Twocyclesofasynthesized1Hzsinusoidalwaveareshownintheleftpanel.Attimet=0theacquisitionboardstoppedsimultaneousdatastoringandstreaming toMATLABworkspace,anddiscardedallnewcollectedsamplesfromitsmemory.AllpresenteddatapointswerecollectedinMATLABcallingthegetsamplefunction.In therightpanel,azoomedinviewoftimet=0isshown.Duringcombinedstoring/streamingmode,samplescanberepeatedupto1000timesandtheyareacquiredafter avariabledelayofabout50ms.Instead,duringsteamingonlymode,allsamplesliecloselytotheinputsignalwithnoredundancyortimelag.(B)Stackedbarsshowtime lagsbetweentwoconsecutivesamples.Notethatthesignalsamplingratewas1kHzandtheboard’smemorysizewassetto2samples.RunningtheMainloopwithdisplay updateateachcycle(darkgraybars)generatedalagofabout4msofwhichabout3.5mswereneededtothedisplayupdateitself(lightgraybars).Updatingthescreenevery 100ms(blackbars)loweredtheaveragelagtoabout1.3ms,ofwhich1mswasauser-definedpausetobesuretoacquireanewsample.Notethatwhentheexperimenter displayupdateoccurred,anaveragelagofabout4.3mswasobserved.
signal,certainlywithoutunpredictablelagsorrepetitions.Forthese
reasons,weabandoneddatastoragemodeandreliedonlyondata
streaming.Itfollowsthatattheendofeachtrial,getdatacannot
beusedtorecoverallofthesamples,andonlythesamples
gath-eredusinggetsampleareactuallyavailabletobestoredforoffline
analysis.
Toacquireand displayone eyepositionsample,oursystem
requiredadelayofabout4ms,asshowninFig.3Bforthehistogram
correspondingto“Mainloop(frequentupdate)”.Inthiscase,the
experimenterdisplayisupdatedforeveryacquiredsample.The
slowestcomponent oftheloop is accountedfor by the
experi-menter’sdisplayupdate,whichrequiresanaveragedelayofabout
3.5msforeachcalltoMATLAB’sfunctiondrawnow.Runningthe
Mainloopwithinfrequentscreenupdate(forexampleonceevery
100ms),itispossibletoachieveaperformanceofunder1.5msfor
mostsamples.Inthiscase,onlythefewsamplesthatareactually
drawnonthescreenexhibitadelayofabout4.5ms.
Usingfrequentscreenupdatemode,whichdisplaysallacquired
samplesontheexperimenterscreen,oursoftwaresolutionexhibits
adelayof under5ms,whichwe considersuitablefor
monitor-ing eyeposition signals acquired withan infrared camera. We
thereforeusedthisconfigurationinthesubsequentexperiments
detailedbelow.
3.2. Circularbuffering
Itisusefultoemploydatasmoothingtoreducespatialvariability
ofgazepositionsandattenuatetechnicalnoisecomingfromtheeye
tracker.Thiscanbeachievedbyaveragingoverthelastnacquired
samplesstoredina(FIFO)circularbuffer.Aconsequenceofsignal
averagingisthatanalogsignalsarealsotemporallydelayed,and
thisdrawbackbecomesrelevantforstudyingtransientandrapid
phenomena,likeforexamplesaccadiceyemovements.Weuseda
synthesized0.1Hzsquarewave(GWInstekSFG2004)to
approxi-mateasaccadiceyemovement,andexaminedthetemporaldelays
introducedbycircularbuffering.Forabufferlengthof10samples,
anabruptchangeintheanalogsignalinputattime0generatesa
linearramplastingabout40msinoursystem,andthusintroduces
alaginthedetectionofthesignaltransitionofatleastt=20ms
(Fig.4A)Dependingonthefixationwindowsize,tcanbelarger
butcannotexceed40msforabufferlengthof10.Examiningthe
dependenceoftheminimumlagtonbufferlength,weobserved
Fig.4. (A)Theeffectofusingacircularbufferinonlineapplicationsisshown.The inputsignalwasasynthesized0.1Hzsquarewave.Eachsquaresymbolrepresents themeanvalueofthelast10samplesstoredinacircularbuffer(seeSection2). Thetimelineiscenteredbetweenthelastsampleofastationaryperiodandthefirst sampleofthetransitionperiod.Werefertominimumtimedelayfordetectinga saccadeast.(B)Increasingbufferlengthlinearlyincreasest.Notethataveraging acrossabufferwith1sampleislikeusingrawdata.(C)Powerdecayrelationship (R2=0.99)betweencoefficientofvariation(C
v)ofGaussiannoisewaveandbuffer
length.
alinearrelationship,asshowninFig.4B.Thisillustratesthat
tem-porallaggrowssystematicallywithbufferlength.Atthesametime,
thevariabilityofanalogsignalsisreducedwithincreasingbuffer
length.Weillustratethisbycomputingthecoefficientofvariation
(/)ofdata(100,000data-points)sampledfromanormal
distri-bution(=1,=1)thataresmoothedwithvariousbufferlengths
(Fig.4C).Itcanbeseenthatvariabilityquicklydecaysforbuffer
lengthsuptoabout15,andthencontinuestodeclinemore
grad-ually.Thissuggeststhatacircularbufferofatleast15samplesis
advisablewhenthereissubstantialnoisepresentintheinputdata.
Takentogether,averagingacrosslargecircularbuffersisoptimal
forreducingtechnicalvariabilityininfraredeyetrackinganalog
inputs. However,it introducestemporal lags in detectability of
transientsignalchanges,suchasthosethatoccurduringsaccadic
eyemovements.Theparameterchoiceforcircularbufferlength
dependsonatrade-offbetweenthesetwoeffects.
3.3. Behavioraldata
Thegazepositionsoftwomonkeys,CandD,weremonitored
duringafixationtask,whilethesubjectsfixatedatargeteitheron
aLEDpaneloronaCRTscreenfor200ms(monkeyC:50blocks
LEDpanel,26blocksCRTscreen;monkeyD:51blocksLEDpanel,
28blocksCRTscreen).Eachblockoftrialsconsistedof50trials
withrandomizedfixationlocationandafixedcombinationofbuffer
lengthandfixationwindowradius.Datapresentedherearebased
onabout4blocks oftrialsforeach parametercombination.The
monkeysweresubjectedtonon-invasiveheadrestraintusingan
individualizedthermoplastichelmet(seeSection2),thatallowed
uptoabout1cm of lateralandverticalhead movement.These
smalltranslationalmovementswerecompensatedusingthe
sig-naldifferencebetweenpupilcenterandcornealreflectionanddid
notaffecttheperformanceofthesystemsincethepositionofthe
eyesremainedwithinawindowsuitableforeyetracking.Notethat
thereisatrade-offbetweenthemagnitudeofpermissible
trans-lationalmovementsandthespatialaccuracyoftheeyetracker,
becausetheeye trackerfield of viewneedstobe expandedto
allowlargertranslationalmovements,reducingspatialresolution.
Ourchosenparametersrepresenta compromisebetween
resid-ualpermissiblemovementsandeyetrackingresolution.Monkeys
werenotpre-trainedonfixationorothertasks,sothattheycan
beconsiderednaïve. The resultsof thebehavioral experiments
areshowninFig.5.Clearly,systemperformanceispoorwithout
circularbuffering(bufferlength=1sample),wheremanybroken
fixationerrorsoccur.Asexpected,largerfixationwindows,aswell
aslongerbufferlengths,ledtohigherbehavioralperformancefor
both thesets of visualstimuli. A two-way analysis of variance
(ANOVA)revealedasignificanteffectoffixationwindowsize(FWS)
andbufferlength(BL)onbehavioralperformance(p<10−9)with
nointeractionbetweenthesefactors(p>0.1).Toobtainhigh
spa-tialresolution, temporal accuracy hastobe sacrificed and vice
versa.Forexample,monkeyDperformedsimilarlyontheLEDpanel
taskforparametercombinationsofFWS=3.5◦/BL=10samplesand
FWS=2◦/BL=25samples.ParametercombinationsforFWSandBL
willlikelydependonparticularexperimentalrequirementsandcan
beoptimizedaccordingly.
Toillustratetheperformanceofoursystem,weshowhorizontal
andverticaleyepositiontracesaroundtimeoffixationacquisition
(Fig.6AandB)forsixteencorrecttrials(FWS=2◦,BL=15samples)
takenfromtheLEDpaneltaskforthecentraltargetposition.The
tracesshowsaccadiceyemovementsmadetothetargetposition
ataroundtimet=0msfromavariableinitiallocationmostlyinthe
upperrightvisualfieldquadrant.Afteracquisitionoffixation,the
eyepositionremainsinsidethefixationwindowof±2◦.Toassess
sample-to-samplevariabilityofeyepositionestimatesduring
fixa-tion,wecomputedthedistanceofdatasamplesfromthemeaneye
positionduringthefixationtimeperiodbetween0msand200ms
foreachtrial.Thissample-to-samplevariabilityquantifieseye
posi-tionsignalstabilityatshorttimescales.Weestimateamedianvalue
of0.09±0.001◦ for both horizontaland verticaldimensions.To
assessthestabilityofoursystematalongertimescale
correspond-ingtothecourseofanentirebehavioralsession,weexaminedthe
Fig.5. PerformanceoftargetfixationformonkeysC(AandC)andD(BandD)duringblocksof50trials.Differentlinesrepresentdifferentfixationwindowradiiasshown infigureslegend.TargetswerepresentedonanLEDpanel(AandB)oraCRTmonitor(CandD)forbothanimals.
meangazepositionduringthefixationperiodsofsubsequent
tri-alsforthecentraltargetpositionsonlyinCRTandLEDpaneltasks.
Thesedataareshownforanexamplebehavioralsession lasting
aboutonehourinFig.6CandD.Alinearregressionrevealedthat
bothhorizontalandverticaleyepositiondriftedonlylittle
dur-ingthecourseofthis session,asshownbytheslopeparameter
estimates(mhorizontal=0.08◦/handmvertical=0.20◦/h).Ananalysisof
eyepositiondriftacrossallbehavioralsessionswiththreeormore
blocksisshowninFig.6E.For73%ofthesessions,thedriftwasless
than1◦/hbothhorizontallyandvertically.Theremainingsessions
exhibitedlargerdrift,whichmightnecessitatemanual
readjust-mentofgainand/oroffsetcalibrationbetweenblocksoftrials.Of
interestisalsothegenerallylargervariabilityingazepositionin
theverticalcomparedtothehorizontaldimension,whichisquite
noticeableinFig.6CandD.Toquantifythiseffect,weestimated
thedistanceofthewithin-trialmeanfixationlocationsfromthe
within-sessionmean.Thetrial-to-trialvariabilitywascomputed
asthemedianvalueofthesedistances.Consideringthe
popula-tionbehavioraldata(Fig.6F),theaveragehorizontaltrial-to-trial
variability(0.32±0.05◦)wasindeedsmallerthanthevertical
vari-ability(0.47±0.08◦)asassessedwithapairedt-test(p<0.001).We
attributethis differencetolickingmovementsinanticipationof
rewards,thatcausepreferentiallyverticalratherthanhorizontal
headdisplacementsandthereforeintroducenoisemostlyinthe
verticaldimension.
4. Discussion
Thecurrentstandardmethodforeyetrackingin non-human
primatesresearchrequires invasiveprocedureslikethe
implan-tationsof a fixedhead-postand a metal wire inthe sclera. As
Fig.6. Sixteentrialsareshown(AandB).Attimet=0targetfixationwasacquired.Horizontaldashedlinesaretheboundariesofthefixationwindowforcentraltargetonthe LEDpanel.(CandD)EachsquaresymbolrepresentstheaveragegazepositionduringthefixationtimeforthecentralpositionontheLEDpanelrecordedduringanexample session,respectivelyforthehorizontalandverticaldimension.Timelinestartsatthebeginningofthefirstblock;eachclusterofpointsispartofa50-trialsblock.Foreach sessionwithmorethanthreeblocks,driftandvariabilityofaveragegazepositionsduringfixationperiodsweresystematicallymeasuredcalculating,respectively,theslope ofthelinearregressionline(grayline)andstandarddeviationofthemeanpositions.(E)Distributionoftheabsolutevaluesofregressionlinesslopesforbothdirections.The driftwaslessthanonedegreeperhourformorethan73%ofthesessionsinbothdirections.(F)Distributionofstandarddeviationsofmeangazepositionsduringfixation periodsisshownforbothdirections.Valuesarelessthan0.5◦moreofteninthehorizontaldirection(52%ofthesessions)thantheverticalone(21%ofthesessions).The
distributionsaresignificantlydifferent(p<0.001).
recentlyshown, non-invasiveheadrestraintcanbeachievedby
employingaplastichelmet,adjustedtoeachindividualanimalthat
allowslimitedheadmovementswhileconstrainingtheoverall
ori-entationofthehead(MachadoandNelson,2011),andaninfrared
camera-basedsystemfortrackingeyeposition.Thisapproachis
howeveralsouseful forneurophysiological work,sincesurgical
procedurescanbecarriedoutafterappropriatebehavioraltraining,
reducingthedurationthatdevicesneedtoremainimplantedonthe
animaltoachievetheexperimentalobjectives.Forthebehavioral
datareportedhere,monkeyswererewardedwitha45mgpelletfor
correcttrials,andmadechewingmovementsduringthe
consump-tionoftheserewards,aswellasfrequentlyattimesduringthe
taskandpriortorewarddelivery.Nevertheless,thissystemcan
functiondespitethesechewingmovements,mainlybecausethe
infraredeye-trackingdeviceemploysthedifferencesignalbetween
thepupilcenterandthecornealreflection,whichisinsensitiveto
chewingaswellastranslationalheadmovements.Wenoticed
how-ever,thatspatialaccuracyofoursystemisgreaterinthehorizontal
thanintheverticaldimension;aneffectthatwepartiallyattribute
tothemorefrequentoccurrenceofverticalcomparedtohorizontal
headmovementsbothinthecontextofchewingaswellas
gen-eralbehavior.Inadditionhowever,theplacementofthecamera
isnon-optimalfortrackingverticaleyemovements.Wechosethis
positionbecausethespacebelowthemonitor,whichisgenerally
recommendedforpositioningthecamera,isoccupiedby
experi-mentaldevicesinoursetup.Onemightconsideranabove-mounted
camerainconjunction witha45◦ slantedmirrorasan
alterna-tiveconfiguration(Kimmeletal.,2012)toimproveverticalgaze
tracking.
Our behavioral control system is implemented in MATLAB
(Mathworks,NatickMA,USA)andusestheMATLABdata
acqui-sitiontoolboxaswellasthefreePsychophysicstoolbox.Forthe
behavioraldatareportedhere,weuseda singlem-filescript of
about400linesofcode,whichcollectsanalogeyepositiondata
fromtheeyetrackerforonlinecontrolandstorage,displaysvisual
targets and monitors their fixation, delivers rewards, provides
onlinefeedbacktotheexperimenteraboutcurrenteyeposition
andtrialspecificdata.Ourimplementationissimilartothe“WaVE”
system(MeyerandConstantinidis,2005),inthatthecodeis
basi-callycontainedinasinglescript,whichhasadvantagesforeaseof
modificationsandadaptationsforuserswhoareskilledin
MAT-LAB.OtherMATLABsolutionssuchas“MonkeyLogic”(Asaadand
Eskandar, 2008; Asaad et al., 2013)provide a generalpurpose
environment that utilizesa multitude of scripts,and provide a
graphicaluserinterfaceformodifyingexperimentalparameters.
Animportantdifferencebetweenthesetwosystemsandour
imple-mentationconcernsthewaythatdataarecollectedfromthedata
acquisitionboard.Whereasboth“WaVE”and“MonkeyLogic”use
thecombinedstorageandstreamingmodeoftheboard,our
imple-mentationreliesuniquelyondatastreamingmode.Exclusiveuse
ofdatastreamingmodeavoidstiminginaccuraciesandextensive
datarepetitionthatcanoccurduringcombinedstorage/streaming
mode(Fig.3A).Itisamajoradvantageofoursystemthateye
posi-tiondatacansampledwithhightemporalaccuracyandwithout
repetition.Providingexperimenterfeedbackwheneveraneweye
positionsampleisacquired,oursystemachievesatiming
perfor-manceofabout4msperupdate(Fig.3B).Over3msofthisupdate
timeisneededtorefreshtheexperimenterdisplay,andifthis
dis-playrefreshiscarriedoutinfrequently,insteadofaftereachnewly
acquireddatapoint,thetimingperformancecanbeenhanced
sub-stantially.Inourcase,wecanachieveabout1.3msperupdateon
mosttrials,andabout4msforupdatesthatincludedisplayrefresh.
Notethatthe1.3msupdatetimeincludesawaitingperiodof1ms,
thatweintroducedbecausetheDAQsamplingratewassetto1kHz
anditthereforemakesnosensetocollectdataattimeintervals
below1ms.Withoutthewaitingperiod,oursystemalsoreaches
updateintervalsunder0.5msasreportedinotherstudies(Asaad
andEskandar,2008;MeyerandConstantinidis,2005),butmostof
theseupdatesarepickingupredundantdatafromtheDAQboard.
Wenotethattimingperformanceofthebehavioralcontrolsystem
generallydoesnotneedtoexceedthetimingperformanceofthe
infraredtrackingdevice.Inourcase,weusedacamerawith120Hz
refreshrate,correspondingtoabout8msbetweenframes,such
thata configurationwithfrequentexperimenterdisplayupdate
wassuitable forthishardware.Forcameraswithhigherrefresh
rate,onemayconsiderinfrequentexperimenterdisplayupdateto
improvesystemtemporalprecision.
Anotablefeatureofoursystemistheuseofacircularbuffer,
whichreducesnoiseintheeyepositionestimatesandenhances
spatialaccuracy.Becausethebufferingmustbecausalinonline
applications,itnecessarilyintroducesatemporaldelaythatis
pro-portionaltothebufferlengthover whicheyepositions samples
areaveraged.Thechoiceofbufferlengthwilldependonparticular
experimentalconsiderations,butwehavefoundthatvaluesaround
15samples,correspondingtoabout60ms,tendtoworkwellfor
thesimpleeyepositioncalibrationtaskinvestigatedhere.For a
givenbufferlength,thedetectiondelayforfixationonsetdepends
onthedistancebetweeninitialandtargeteyepositions,andwill
haveaminimumvalueoftasshowninFig.4B.Itisimportantto
rememberthatformanyapplications,thetemporaldelaycanbe
essentiallyequatedtoaprolongationoffixationtime.We
there-foredonotviewthetemporallagintroducedbycircularbuffering
asproblematicformostapplications.Anexceptiontothisaretasks
involvingsmoothpursuiteyemovements,whicharethusoutside
thescopeoftheproceduresdescribedhere.Notethatsince the
actualacquiredeyepositionsamplesandnotthecircularbuffered
valuesaresavedforlateranalysis,asimple(non-causal)moving
averagefiltercanbeappliedofflinetodeliveraveridicalestimate
ofeyepositionwithoutanytemporaldelays.Inapplicationswhere
fasterresponsetimesarenecessary,theinfrequentupdateoption
describedabovecanbeusedtoreducethetemporallagbyafactor
ofuptoabout3,orthecameracanbeplacedinamoreoptimal
positionsuchthatcircularbufferingmaynotbenecessary.
The necessity of circular buffering is underscored by the
behavioraldata.Withoutcircularbuffering,monkeysachieved
per-formancelevelsofonlyabout60%correctwithafixationwindow
size(FWS)of3.5◦onasimplefixationtask.Withcircularbuffering,
theFWScouldbereducedtovaluesaslowas2◦,andstillpermit
behavioralperformanceofabout80%correctinmostcases.Note
thatmonkeyswerenotextensivelypre-trainedonfixationtasks
forthesetests,sothattheirperformancemightimprovewith
addi-tionaltraining.Thereportedvaluesarecertainlysuitabletoserve
asabasis oftrainingmonkeysonawide varietyofoculomotor
paradigms.
We quantifiedthe stability ofour systemboth atshort and
longtimescales,andwereabletodemonstrategenerallyadequate
stability that permitsgatheringdata over periodsof aboutone
hourwithouttheneedforrecalibrationofanyeye-tracker-related
parameters.Foreyepositionsignalstabilityatshorttimescales,we
obtaineda valueof0.09±0.001◦ forsample-to-sample
variabil-ity,whichissimilartopreviousreportsforinfraredeyetrackingon
rigidlyhead-postedmonkeys(Kimmeletal.,2012).Foreyeposition
stabilityatlongertimescales,weusedalinearregressionto
deter-minethetrial-to-trialdriftoverthecourseofbehavioralsession
lastingapproximatelyonehour.Wefoundthatdrifttendedtobe
generallysmall,withaboutthreequartersofthesessionshowing
driftoflessthan1◦/handmanysessionsshowingdriftunder0.5◦/h
(Fig.6E).Forhead-postedmonkeys,drift valuesof upto0.3◦/h
havebeenreported(Kimmeletal.,2012),whichsuggeststhatlong
timescalestabilityofeyetrackinghelmet-restrainedmonkeyscan
reachvaluesobservedintherigidlyhead-postedcondition.There
arehoweveroccasionalsessionswithlargerobserveddrift,that
willrequiremanualreadjustment ofeyecalibrationparameters
duringthesessiontoachieveoptimalperformance.The
trial-to-trialvariabilityof eye positiondatacorrespondingto thesame
fixationlocationoverthetime-courseofaboutonehourwasabout
afactoroftwolargerthanvaluesreportedforhead-postedmonkeys
(Kimmeletal.,2012),suggestingthatoursystemperformsonly
moderatelyinferiorforthisparameter.
Takentogether,wehavedescribedacompactMATLAB
imple-mentationforbehavioralcontrolandeyetrackingthatisoptimized
fornon-rigidheadrestrainedmacaquemonkeyapplications.Itis
alowcostsolutionusinga120Hzframeratetrackingsystemand
thefreelyavailablePsychophysicstoolbox.Itreliesexclusivelyon
thestreamingmodeofthedataacquisitionboard,whichconfers
substantialbenefits,particularlyintermsoftemporalfidelity,
com-paredtothewidelyusedcombinedstreamingandstoragemode.
Althoughoursystemdoesnotreachperformancecharacteristics
ofinvasiveeyecoilbasedeyetrackersorhighframerateinfrared
trackingsystemswithrigidhead-posting,itneverthelessachieves
aperformancethatissuitableformanyapplications.Wenotethat
thissystemcanofcoursealsobeusedforhumanpsychophysics
studies,particularlyinsituationswhereheadimmobilizationusing
chin-restorbite-barisnotpossibleorundesirable.
References
AsaadWF,EskandarEN.Achievingbehavioralcontrolwithmillisecond resolu-tioninahigh-levelprogrammingenvironment.JNeurosciMethods2008;173: 235–40.
AsaadWF,SanthanamN,McClellanS,FreedmanDJ.High-performanceexecution ofpsychophysicaltaskswithcomplexvisualstimuliinMATLAB.JNeurophysiol 2013;109:249–60.
BrainardDH.Thepsychophysicstoolbox.SpatVis1997;10:433–6.
Judge SJ, Richmond BJ, Chun FC. Implantation of magnetic search coil for measurement of eye position: an improved method. Vis Res 1980;20: 535–8.
KimmelDL,MammoD,NewsomeWT.Trackingtheeyenon-invasively: simulta-neouscomparisonofthescleralsearchcoilandopticaltrackingtechniquesin themacaquemonkey.FrontBehavNeurosci2012;6:49.
Kleiner M, Brainard D, Pelli D. What’s new in Psychtoolbox-3? Perception 2007;36.
MachadoCJ,NelsonEE.Eye-trackingwithnonhumanprimatesisnowmore acces-siblethaneverbefore.AmJPrimatol2011;73:562–9.
MeyerT,ConstantinidisC.Asoftwaresolutionforthecontrolofvisualbehavioral experimentation.JNeurosciMethods2005;142:27–34.
PelliDG.TheVideoToolboxsoftwareforvisualpsychophysics:transforming num-bersintomovies.SpatVis1997;10:437–42.
RobinsonDA.Amethodofmeasuringeyemovementusingscleralsearchcoilina magneticfield.IEEETransBiomedEng1963;10:137–45.