[FieldTrip] using ft_definetrial

Nikola Valchev nikola.valchev.umcg at gmail.com
Fri Jul 17 15:48:44 CEST 2015


Dear Stan, 

Thank you very much for your help. I think I found where the problem is. The
format of my data is EEProbe and apparently fieldtrip doesn’t red it
correctly. I managed to import it in eeglab and then use the magic function
eeglab2fieldtrip. 

 

Best

Nikola

 

From: fieldtrip-bounces at science.ru.nl
[mailto:fieldtrip-bounces at science.ru.nl] On Behalf Of Pelt, S. van (Stan)
Sent: 14 July 2015 14:53
To: FieldTrip discussion list
Subject: Re: [FieldTrip] using ft_definetrial

 

Hi Nikola,

 

I have no experience with EEG data myself. But If I understand correctly,
the relevant trigger information is in your .trg-file.

So, if you can define variable triggers as below, it should be relatively
straigthforward:

 

triggers= [  0.000000         0 0

20.568359   2490491 1

23.787109   2879419 9

28.597656   3460687 1

33.056641   3999475 3

45.923828   5554243 1

...]

It seems that you have 118*1024 samples (segments) per second, is that
correct? And your EEG-data is time-labeled in segments, not seconds?

 

Now, your trigger values of interest (1) are in column 3, not in 2, that is
the crucial bit probably:

 

u1=find(ismember(triggers(:,3),[1])); 

 

And then you can do

 

trl= [triggers(u1,2)-.2*1024 triggers(u1,2)+6*1024
repmat(-.2*1024,numel(u1),1)];

 

You might want to change 0.2 into e.g. 0.25, since otherwise you might end
up with non-integer values.

 

To get rid of your last error, make sure that there are no negative sample
numbers in your cfg.trl (since there’s no data befor sample nr 0).

 

Best,

Stan

 

From: fieldtrip-bounces at science.ru.nl
[mailto:fieldtrip-bounces at science.ru.nl] On Behalf Of Nikola Valchev
Sent: dinsdag 14 juli 2015 14:36
To: 'FieldTrip discussion list'
Subject: Re: [FieldTrip] using ft_definetrial

 

Hi Pelt, 

Thanks a lot for the help. Somehow I forgot that I can specify my own trl
matrix manually... 

(I’m sorry for the long email but I try to be as clear as possible so that
it takes less time.)

 

 

 

However, there is still something wrong which I don’t understand. What I do
is to use ft_read_event to read all the triggers and events from the cnt
file. What I get is the event structure with the fileds 

type

sample

value

offset

duration

 

I presume that these are read from the trg file (i.e. s14_CI_1.trg which is
associated with the s14_CI_1.cnt). 

 

Inside that file I have: 

  0.000000         0 0

20.568359   2490491 1

23.787109   2879419 9

28.597656   3460687 1

33.056641   3999475 3

45.923828   5554243 1

...

 

 

First column should be the times, second the segment and the third the
trigger. I use your commands to create the matrix: 

u1=find(ismember(triggers(:,2),[1])); 

 

trl= [triggers(u1,2)-.2*1024 triggers(u1,2)+6*1024
repmat(-.2*1024,numel(u1),1)];

 

And at the end I get a matrix:  

 

  1.0e+003 *

 

   -0.2038    6.1450   -0.2048

   -0.2038    6.1450   -0.2048

   -0.2038    6.1450   -0.2048

   -0.2038    6.1450   -0.2048

...

 

Then I attempt to preprocess again: 

cfg=[];

cfg.dataset='C:\eeg_anita\data\S14\s14_CI_1.cnt';

cfg.headerfile='C:\eeg_anita\data\S14\s14_CI_1.cnt';

cfg.trl=trl;

cfg_test=ft_preprocessing(cfg);

 

 

and I get an error: 

??? Error using ==> ft_read_data at 206

cannot read data before the begin of the file

 

Error in ==> ft_preprocessing at 563

      dat = ft_read_data(cfg.datafile, 'header', hdr, 'begsample',
begsample, 'endsample', endsample, 'chanindx', rawindx,

      'checkboundary', strcmp(cfg.continuous, 'no'), 'dataformat',
cfg.dataformat)

 

 

Nikola

 

 

 

From: fieldtrip-bounces at science.ru.nl
[mailto:fieldtrip-bounces at science.ru.nl] On Behalf Of Pelt, S. van (Stan)
Sent: 14 July 2015 09:25
To: FieldTrip discussion list
Subject: Re: [FieldTrip] using ft_definetrial

 

Hi Nikola,

 

You might also try a workaround:

     

% read the events from the data

event = ft_read_event('C:\eeg_anita\data\S14\s14_CI_1.cnt');

    

% search for "trigger" events

triggers=[];

for i=1:size(event,1) 

     a=find(strcmp(event(i).type,'trigger')==1); 

     if a>0

         triggers=[triggers; event(i).value event(i).sample]; 

     end 

end

 

% make cfg.trl: I think this is where things go wrong in your script. You
could check what’s in triggers(:,1). Otherwise, what’s below should work:

u1=find(ismember(triggers(:,1),[1 3 6 9])); % select your eventvalue(s) of
interest

 

trl= [triggers(u1,2)-.2*fs triggers(u1,2)+6*fs repmat(-.2*fs,numel(u1),1)];
% 0.2 prestim, 6s post-stim, with fs being your sampling frequency

 

% next, do preprocessing, with cfg.trl=trl;

 

 

From: fieldtrip-bounces at science.ru.nl
[mailto:fieldtrip-bounces at science.ru.nl] On Behalf Of Jörn M. Horschig
Sent: dinsdag 14 juli 2015 8:38
To: 'FieldTrip discussion list'
Subject: Re: [FieldTrip] using ft_definetrial

 

Hi Nikola,

 

seems to be a nasty problem. I’d start with using event =
ft_read_events(cfg.dataset) and then check up the event-structure on how
they are defined there. ft_trialfun_general is literally checking that
event-structure, so defining them like they are specified in there might
help. 

 

Best,

Jörn

 

--

 

Jörn M. Horschig, PhD, Software Engineer

 <http://www.artinis.com/> Artinis Medical Systems  |  +31 481 350 980 

 

From: fieldtrip-bounces at science.ru.nl
[mailto:fieldtrip-bounces at science.ru.nl] On Behalf Of Nikola Valchev
Sent: Monday, July 13, 2015 9:51 PM
To: 'FieldTrip discussion list'
Subject: Re: [FieldTrip] using ft_definetrial

 

Nope. That’s not it. No matter if I declare it as a double or string when I
call the eventtype ‘trigger’ instead of ‘?’ they are not read. 

 

Nikola

 

 

 

From:  <mailto:fieldtrip-bounces at science.ru.nl>
fieldtrip-bounces at science.ru.nl [ <mailto:fieldtrip-bounces at science.ru.nl>
mailto:fieldtrip-bounces at science.ru.nl] On Behalf Of Pelt, S. van (Stan)
Sent: 13 July 2015 19:30
To: FieldTrip discussion list
Subject: Re: [FieldTrip] using ft_definetrial

 

What about

 

cfg.trialdef.eventvalue     = 1;

 

Op 13 jul. 2015, om 18:36 heeft Eelke Spaak <
<mailto:eelke.spaak at donders.ru.nl> eelke.spaak at donders.ru.nl> het volgende
geschreven:

 

cfg.trialdef.eventvalue     = {'1'};

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20150717/32990d1e/attachment-0002.html>


More information about the fieldtrip mailing list