Hi Francois,
I tried to import an eyelink *.edf in brainstorm and I get this error:
Line 116: Reference to non-existent field ‘Fixations’.
Call stack:
>in_fopen_eyelink.m at 116
>in_fopen.m at 93
>import_raw.m at 124
>bst_call.m at 28
>tree_callbacks.m>@(h,ev)bst_call(@import_raw,[],[],iSubject) at 587
Also, during the experiment, we sent multiple messages to the eyelink using this command:
Eyelink(‘Message’,‘Trigger ID %d’,mytrigger);
I then used the edf2asc tool, which converted the *.edf file into a *.asc ascii file. This file has lines such as:
MSG 1639411 Trigger ID 2
MSG 1648846 Trigger ID 44
etc.
However brainstorm cannot see these events. Can you help?
Both files are available here:
https://1drv.ms/f/s!AqzBy35-OGPEhd4PGR4iOb0TgE3nVQ
Thank you!
Dimitrios
Hi Dimitrios,
I simply added a check if the field “Fixations” exists, and it seems to work fine.
You can update Brainstorm and try again.
Cheers,
Francois
Hi Francois,
Thank you 
I realized that the function in_fread_eyelink.m has a problem. Line 55 assumes the variable Trials.Samples.(chname) is a vector, however it is (or can be) a 2 x ntimes matrix, where 2 indexes the two eyes (I believe 1 is for left and 2 is for right).
line 55:
F(i,
= double(Trials(iEpoch).Samples.(chname)(iSamples));
should be replaced with:
F(i,
= double(Trials(iEpoch).Samples.(chname)(1,iSamples)); %left eye data
F(i,
= double(Trials(iEpoch).Samples.(chname)(2,iSamples)); %right eye data
I am not sure how the variable behaves if only one eye is recorded. I should try and send you sample data.
You should probably modify the channel definition to include separate names for left and right eye.
I attach some data for your convenience:
https://www.dropbox.com/sh/jeu3wlxv734h35b/AACVNXZ42bTNlE5_1sGaqwwfa?dl=0
It includes a *.fif file (with analog eye tracking data in misc7-12) and an eyelink *.edf file with digital eye tracking data. I also include a screenshot showing that the two are aligned if you make the suggested modification.
Cheers,
Dimitrios
Hi Dimitrios,
I modified in_fread_eyelink and in_fopen_eyelink to read the two eyes as two separate channels for each field.
Can you update Brainstorm and let me know if it works correctly?
Cheers,
Francois
Thank you Francois. A final correction and I think we are all set.
On file in_fread_eyelink.m, please replace line 67 from
TimeVector = Trials(iEpoch).Samples.time(iSamples);
to:
TimeVector = double(Trials(iEpoch).Samples.time(iSamples))/1000;
The TimeVector is originally in milliseconds (uint type) and your subsequent scripts interpret it as seconds.
Cheers,
Dimitrios
Done.
Thanks for debugging this!
Some more information that might be useful:
The edfImport.m function returns information whether L, R, or both eyes were recorded:
Trial.Header.rec.eye == 1 if left eye
Trial.Header.rec.eye == 2 if right eye
Trial.Header.rec.eye == 3 if left and right eye
Even if only one eye was recorded, it always returns data for both eyes (gx is 2 x time, gy is 2 x time, etc). However the missing eye has -32768 value over the whole time. You may want to keep it as is, or just replace these values with NaN or something?
Plotting could be improved in brainstorm. Currently it shows all time series in the same axis with the extremely strong ones (e.g. the missing eye -32768 ) dominating the plot and the real data appearing as zeros.
If you press ctrl+T to view topography you get an error. Perhaps create a surrogate channel structure?
Since the information for the eyes is know, how about replacing the names gx1 and gx2 for gx_l and gx_r, etc?
I hope this is helpful : )
If you want to test brainstorm, I have uploaded 3 edf files, for only left, only right, and both eye recordings:
https://www.dropbox.com/sh/8gr83g7tn277sv0/AAACCtohD3x-fhuVAV7iIYJOa?dl=0
Best,
Dimitrios
Done:
- the channel names should now be adapted to the eye
- the channels are now normalized by their maximum value (all the values are between 0 and 1, maybe it’s bad if you need the actual values that are recorded… I can change that easily)
No, it cannot be represented as a 2D map of sensors, because these are not sensors.
What did you expect to see with this CTRL+T?
Francois
Hi Francois,
Thank you for all this work.
Please don’t normalize the channels by their maximum value! This is digital data containing the pixel coordinates on screen, so the actual values are important.
Best,
Dimitrios
Hi from Seoul 
Ok, I removed this last one part.
You can create montages to display the channels with lower amplitudes separately.
http://neuroimage.usc.edu/brainstorm/Tutorials/MontageEditor#Channel_selection
Francois