How to extract eye tracking data by trial ID

5 ビュー (過去 30 日間)
jlouise2022
jlouise2022 2023 年 2 月 14 日
編集済み: dpb 2023 年 2 月 15 日
Hi there,
I have lots of eye tracking data from a 2 alternate forced choice experiment. In total, 496 trials per participant.
The data are in .asc format, and include MSGs for every forced choice onset. For example:
I would like to extract the data for each 2AFC trial. Such that my ideal data set would include only saccades/fixations/blinks within the 2AFC period, per trial (Trial ID 1 2AFC : Trial ID 496 2AFC).
Whilst i've been able to extract saccade/fixation/etc information using a toolbox, I'm stuck on how to filter the data by trial.
Maybe this can't even be achieved! But would appreciate any insights.

採用された回答

dpb
dpb 2023 年 2 月 14 日
編集済み: dpb 2023 年 2 月 15 日
Easiest would be to read the file line-by-line, looking for the magic value and then save data until the next, adding the trial as a variable...
You forgot to attach any usable data for anybody to actually demonstrate, but "air code" would look something like --
fid=fopen('YourFile.Dat');
ID=input('Enter the magic ID to look for, please; ','s')
ID=upper(ID);
pat="MSG"+wildcardPattern+digitsPattern(7)+wildcardPattern+"TRIALID"+wildcardPattern+digitsPattern(1,4)+wildcardPattern+upper(ID);
j=0; % the counter
d=[]; % empty accumulator for data
l=fgetl(fid);
while ~feof(fid)
if matches(l,pat)
j=j+1; % increment counter
l=fgetl(fid); % get first data line in section
end
try
d=[d;[j str2double(l)]]; % convert line to data; add trial number and array
l=fgetl(fid); % record for next loop
catch % presume failure means next section
% do nothing special, pass on to next test if in wanted section
l=fgetl(fid); % record for next loop
end
end
fid=fclose(fid);
will (hopefully) leave you with the array of values with the trial # as first variable; save as a matrix or convert to a table as desired.
  1 件のコメント
jlouise2022
jlouise2022 2023 年 2 月 15 日
Hi,
Thanks for your insight. Accepted as answer as this may help someone else.
I'm now working with .edf files as they are easier to convert into mat files.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Import and Export についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by