MasterScan
Lab_Matlab_control Master Branch
|
Reads ASL/serial port gaze and pupil size data.
dotsReadableEyeASL extends the dotsReadableEye superclass to acquire point of gaze and pupil size data from an ASL eye tracker connected via the serial port.
It uses the as() mex funciton (which is only for Mac OS X) to buffer and decode the streaming serial port data. as() makes a number of assumptions about the data format, including that the data frames are 12 bytes and include the frame number.
Properties and Events | |
Property | timedFrames = [] |
nx2 matrix of ASL frame numbers and clockFunction timestamps More... | |
Property | frameMaxInt = (2^16)-1 |
the largest frame number integer that ASL can represent More... | |
![]() | |
Property | x |
the current "x" position of the eye in user-defined coordinates. | |
Property | y |
the current "y" position of the eye in user-defined coordinates. | |
Property | pupil |
the current pupil size, offset and scaled | |
Property | time |
The time of the most-recent sample (in ui time) | |
Property | sampleFrequency |
frequency in Hz of eye tracker data samples More... | |
Property | readEventsOnly = true |
Flag determining whether only to read event data see readNewData for details. More... | |
Property | helpers |
helper objects including screen ensemble | |
gazeMonitor | |
Gaze monitor properties. | |
![]() | |
Property | isAvailable = false |
| |
Property | components |
| |
Property | state |
| |
Property | history |
| |
Property | isAutoRead = true |
| |
Property | eventDefinitions |
| |
Property | initialEventQueueSize = 100 |
| |
Property | clockFunction |
| |
Property | filename |
| |
Property | filepath |
| |
Property | recordDuringCalibration = true |
| |
Property | useGUI = false |
Flag to use GUI for feedback, etc. | |
Property | useExistingCalibration = false |
Flag to skip calibration routine. | |
Property | calibrationUI |
Possibly use a keyboard or other UI to help with calibration. | |
Property | deactivateEventsAtStartTrial =false |
Flag to deactivate all events at the beginning of each trial. | |
Methods | |
self | dotsReadableEyeASL () |
Constructor takes no arguments. | |
flushData (self) | |
Clear data from this object and the as() internal buffer. More... | |
![]() | |
self | dotsReadable () |
| |
initialize (self) | |
| |
calibrate (self, varargin) | |
More... | |
record (self, onFlag, filename) | |
More... | |
reset (self, varargin) | |
reset device More... | |
close (self) | |
| |
delete (self) | |
| |
read (self) | |
More... | |
flushData (self, waitForNoEvents) | |
More... | |
logData (self) | |
More... | |
stateAtTime | getState (self, time) |
More... | |
value data | getValue (self, ID) |
More... | |
event | defineEvent (self, name, varargin) |
More... | |
defineEventsFromComponents (self, names, varargin) | |
defineEventsFromComponents More... | |
defineEventsFromStruct (self, eventStruct, setName, keepExisting, inactivate) | |
defineEventsFromStruct More... | |
showActiveEvents (self) | |
Mostly for debugging. | |
activateEventSet (self, name) | |
Swap in a set of events. | |
activateEvents (self) | |
Activate all events. More... | |
deactivateEvents (self) | |
Deactivate all events. More... | |
activeFlags | getActiveFlags (self) |
Get all active flags. | |
setActiveFlags (self, activeFlags) | |
Set all active flags from array. | |
setEventsActiveFlag (self, activateList, deactivateList) | |
Set/unset activeFlag. More... | |
name data | getNextEvent (self, isPeek, acceptedEvents) |
More... | |
lastName lastID names IDs | getHappeningEvent (self, time) |
More... | |
name waitTime data | waitForEvents (self, eventNames, maxWait) |
Wait for event(s) | |
nEvents | getNumberOfEvents (self) |
More... | |
IDs | getComponentIDs (self) |
More... | |
ID | getComponentID (self, nameOrID) |
| |
name | getComponentName (self, nameOrID) |
| |
indices | getComponentIndicesByID (self, IDs) |
| |
indices | getComponentIndicesByName (self, names) |
| |
time | getDeviceTime (self) |
| |
setDeviceTime (self, val) | |
| |
startTrial (self, varargin) | |
More... | |
finishTrial (self, varargin) | |
More... | |
plotData (self) | |
More... | |
startTrialDevice (self, varargin) | |
Overloaded methods. | |
Protected Methods | |
isOpen | openDevice (self) |
Acquire ASL serial port resources. More... | |
closeDevice (self) | |
Release ASL serial port resources. More... | |
newData | readRawEyeData (self) |
Read raw ASL data from the serial port. More... | |
![]() | |
isOpen | openDevice (self) |
More... | |
closeDevice (self) | |
More... | |
resetDevice (self, varargin) | |
Reset the device. | |
status | calibrateDevice (self, varargin) |
More... | |
isRecording | startRecording (self) |
| |
isRecording | stopRecording (self) |
| |
components | openComponents (self) |
More... | |
closeComponents (self) | |
More... | |
newData | readNewData (self) |
More... | |
isEvent | detectEvents (self, data) |
More... | |
newSize | resizeEventQueue (self, minSize, doClear) |
More... | |
nEvents | enqueueEvents (self, eventValues) |
More... | |
eventValue nEvents | dequeueEvent (self, isPeek) |
More... | |
Static Methods | |
static frameNumbers | correctOverflow (frameNumbers, maxInt) |
Try to correct frame numbers which overflowed. More... | |
static frameTimes | computeFrameTimes (frameNumbers, nowTime, sampleFrequency) |
Compute frame times based on frame numbers. More... | |
static frameNumbers | reconstructFrameNumbers (frameTimes, timedFrames, sampleFrequency) |
Reconstruct ASL integer frame numbers from frame timestamps. More... | |
![]() | |
static isHappening data readable | isEventHappening (readables, eventName) |
More... | |
static didHappen waitTime data readable name | waitForEvent (readables, eventName, maxWait) |
More... | |
static data | loadDataFile (filename, varargin) |
Load data from file. More... | |
Additional Inherited Members | |
![]() | |
Property | eventQueue |
| |
Property | queueNext |
| |
Property | queueLast =0 |
| |
Property | isRecording =false |
| |
Property | didCalibrate = true |
Keep track of whether calibration occurs. | |
Property | defaultEventPrefix = 'event' |
Default prefix for event names: <prefix>_<componentName> | |
Property | eventSets |
Strutures with different named event definitions, in case we want to quickly swap between them. | |
flushData | ( | self | ) |
Clear data from this object and the as() internal buffer.
Extends the dotsReadable flushData() method to also clear out the as() internal data buffer and discard old frame timestamps.
|
protected |
Acquire ASL serial port resources.
Initializes the the as() mex function, returns true if successful, otherwise returns false.
|
protected |
Release ASL serial port resources.
Closes the as() mex function.
|
protected |
Read raw ASL data from the serial port.
Reads out any buffered data frames from the as() mex function's internal buffer. Reformats the data in the dotsReadable style.
as() reports data frames in four columns as
Converts these to the dotsReadable three-column style as
where timestamp is derived from the ASL frameNumber, sampleFrequency, and the current time.
Appends the latest frameNumber and the current time to timedFrames.
|
static |
Try to correct frame numbers which overflowed.
frameNumbers | ASL integer frame numbers |
maxInt | the largest integer ASL can represent |
Attempts to correct frame numbers that overflowed their integer representation. Assumes that frame numbers should always increase. Where they decrease, adds maxInt + 1 as though the next more significant digit were present.
|
static |
Compute frame times based on frame numbers.
frameNumbers | ASL integer frame numbers |
nowTime | the time to align with the last frame number |
sampleFrequency | ASL sample frequency |
Appends the lasts frame number in frameNumbers and the given localTime to timedFrames. Uses this pair and the ASL sample frequency to compute a frame time for each frame number in in frameNumbers.
|
static |
Reconstruct ASL integer frame numbers from frame timestamps.
frameTimes | frame times from computeFrameTimes() |
timedFrames | nx2 pairs of [frameNumber frameTime] |
sampleFrequency | ASL sample frequency |
Reconstructs the "raw" frame numbers reported by ASL, based on data saved in the nx3 dotsReadable format. This is intended to help with post-hoc validation and analysis.
Returns the frame number for each frame time in frameTimes.
Property timedFrames = [] |
nx2 matrix of ASL frame numbers and clockFunction timestamps
Each call to readRawData() adds a row to timedFrames. The first column contains frame numbers returned from as(). The second column contains a timestamp from clockFunction. dotsReadableEyeASL assumes that the numbered frame coincided with the timestamp.
Property frameMaxInt = (2^16)-1 |
the largest frame number integer that ASL can represent
ASL reports frame numbers as integers which overflow periodically. readRawEyeData() uses frameMaxInt to correct for the overflow, even if frames are dropped.