Retrieving eyetracker data in the background
Currently, I am facing an issue of retrieving the pupil diameter data from the eyetracker during the "DISP"-condition. It seems MATLAB is struggling to retrieve the pupil diameter data in the background/in parallel while the experiment continues to run.
Approach: Use MATLABs “backgroundPool” and “parfeval” tools to run functions in the background. https://ch.mathworks.com/help/matlab/ref/parallel.backgroundpool.html
https://ch.mathworks.com/help/matlab/ref/parfeval.html
- Initialize the backgroundPool as a parallel pool with process-based workers in loadJsonProtocol.m (Code Line 136-144)
- Use parfeval and backgroundPool to start function “retrieve_pupil_diameter_data.m” in the background (“SCR”-condition in nfbCalc.m, Code Line 306). Save as a future variable for future output fetching. The experiment continues to run while the function runs in the background (retrieving pupil diameter data).
- Use “fetchOutputs” to fetch the outputs of the pupil diameter data (end of “DISP”-condition in nfbCalc.m, Code Line 329).
Problem: While the above approach seems to work fine in dummy mode (pseudo/random eyetracker data), for real eyetracker data matlab throws an error when trying to fetch the Outputs. See image below. Since I am already using MATLABs parallel computing toolbox, I am not sure on how to solve this problem.
![]()
Possible Solution: Re-write the “retrieve_pupil_diameter_data.m” function to be "MATLAB parallel computing compatible". However I suspect that accessing the eyetracker hardware in a parallel pool is the real problem.