Back to the main page.

Bug 1081 - ft_read_header.m eyelink ascii 2000Hz data reading error

Status CLOSED FIXED
Reported 2011-10-27 10:20:00 +0200
Modified 2019-08-10 11:46:27 +0200
Product: FieldTrip
Component: fileio
Version: unspecified
Hardware: PC
Operating System: Linux
Importance: P1 normal
Assigned to: Stephen Whitmarsh
URL:
Tags:
Depends on:
Blocks:
See also:

Diego Lozano Soldevilla - 2011-10-27 10:20:14 +0200

Created attachment 179 code and sample data at 1000hz(diegoxxx.asc) and 2000hz(litcal.asc) Specific problem reading eyelink data sampled at 2000hz but not with data sampled at 1000hz. At 2000hz, eyelink seems to save new information in x, y and pupil channels in to consecutive SAME samples. See the following piece of data: Samples x chan y chan pupil chan 5198103 469.7 56.2 1955.0 ... 5198103 470.4 56.8 1957.0 ... 5198104 470.6 56.3 1956.0 ... 5198104 470.6 56.2 1954.0 ... 5198105 470.5 55.3 1951.0 ... 5198105 470.4 54.0 1950.0 ... 5198106 470.3 52.8 1951.0 ... 5198106 470.4 52.6 1952.0 ... 5198107 470.4 52.3 1952.0 ... 5198107 470.4 51.9 1950.0 ... Importantly, I only record one eye, so one can discard the possibility that eyelink was recording at the same sample both eyes (might be with 2000hz eyelink assumes this last option I wasn't able to figure out). With data sampled at 1000hz this problem disapears because each sample has an unique x, y and pupil output. The problem come reading the data with ft_read_header: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% cfg = []; cfg.trialfun = 'eyelink_trialfun2'; cfg.dataset = '/home/electromag/dieloz/Desktop/eyetrackerpilot/litcal.asc'; %cfg.headerformat = 'eyelink_asc'; cfg.trialdef.prestim = 1; cfg.trialdef.poststim = 3; cfg.trialdef.events = [111:119]; cfg = ft_definetrial(cfg); evaluating trialfunction 'eyelink_trialfun2' Warning: creating fake channel names >> In fileio/private/warning_once at 81 In ft_read_header at 507 In eyelink_trialfun2 at 4 In ft_definetrial at 161 found 80 events created 9 trials the call to "ft_definetrial" took 29 seconds and an estimated 11 MB >>cfg.trl ans = -Inf Inf -Inf -Inf Inf -Inf -Inf Inf -Inf -Inf Inf -Inf -Inf Inf -Inf -Inf Inf -Inf -Inf Inf -Inf -Inf Inf -Inf -Inf Inf -Inf %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Inside eyelink_trialfun2.m (an adaptation of Stephen function) I call ft_read_header.m like this: hdr=ft_read_header(cfg.dataset,'headerformat','eyelink_asc','dataformat','eyelink_asc','eventformat','eyelink_asc'); and there's a problem reading the sampling rate (line 503): hdr.Fs = 1000/median(diff(asc.dat(1,:))); As diff is used and the samples are twice the same, the output is zero. I tried to solve it doing the following crappy solution hdr.Fs = 1000/median(diff(asc.dat(1,1:2;end))); but then I get problems with begin and endsamples definition and I get lost. Although this data come from a short pilot and I can now change my new recording to 1000hz, could be a problem reading the 2 eyes. Best Diego


Robert Oostenveld - 2011-10-28 13:53:23 +0200

I made a change in the code, Stephen will check whether it now works.


Stephen Whitmarsh - 2011-10-28 14:58:56 +0200

works for me


Stephen Whitmarsh - 2011-10-28 15:00:21 +0200

oh wait...


Robert Oostenveld - 2011-10-28 15:17:44 +0200

(In reply to comment #3) > oh wait... I hope this won't become the cliffhanger for the weekend...


Stephen Whitmarsh - 2011-10-28 17:07:47 +0200

Ah, it works! Only thing is that one has to round the trl so as not to get errors with ft_fetch_data later on ('inconsitent trial lenghts').


Diego Lozano Soldevilla - 2011-11-29 12:28:19 +0100

Created attachment 194 data and trialfunction


Diego Lozano Soldevilla - 2011-11-29 12:30:01 +0100

(In reply to comment #5) I get an error when I call ft_preprocessing: cfg = []; cfg.trialfun = 'eyelink_trialfun2'; cfg.dataset = [gendir dgendir(subj,1).name indir d(1,1).name]; cfg.headerformat = 'eyelink_asc'; cfg.trialdef.prestim = 1; cfg.trialdef.poststim = 2; cfg.trialdef.events = [2 3 4 5 6]; cfg = ft_definetrial(cfg); cfg.channel = {'2' '3'}; cfg.dataformat = 'eyelink_asc'; cfg.headerformat = 'eyelink_asc'; cfg.demean = 'no'; %cfg.baselinewindow = [-0.5 0.5]; eye = ft_preprocessing(cfg); processing channel { '2' '3' } reading and preprocessing reading and preprocessing trial 1 from 240 ??? Error using ==> ft_read_data at 136 cannot read data after the end of the file Error in ==> ft_preprocessing at 503 dat = ft_read_data(cfg.datafile, 'header', hdr, 'begsample', begsample, 'endsample', endsample, 'chanindx', rawindx, 'checkboundary', strcmp(cfg.continuous, 'no'), 'dataformat', cfg.dataformat) Now it seems that the epoch time window is correct cfg.trl ans = 9006156 9009155 -1000 1 9012169 9015168 -1000 2 9018050 9021049 -1000 3 9023832 9026831 -1000 4 9030048 9033047 -1000 5 9036395 9039394 -1000 6


Stephen Whitmarsh - 2011-11-29 12:40:33 +0100

According to Diego it also works.


Stephen Whitmarsh - 2011-11-29 12:41:35 +0100

His previous comment might be 1) another bug, or 2) his mistake. We'll just have to wait and see.


Robert Oostenveld - 2019-08-10 11:46:27 +0200

This closes a whole series of bugs that have been resolved (either FIXED/WONTFIX/INVALID) for quite some time. If you disagree, please file a new issue describing the issue on https://github.com/fieldtrip/fieldtrip/issues.