[FieldTrip] [EXTERNAL]Re: ft_definetrial Error on Field trip

Vanessa Oluwato Ayo-Jibunoh vayojibunoh at gradcenter.cuny.edu
Sat Jun 22 23:47:49 CEST 2024


Thank you for your response. The problem was indeed my trigger sequence and I have been able to write the code for it and rectify that. This was helpful advice though and I will procure the debugger and use it for future purposes.

Thank you very much.

As for the line you mentioned as a side, I got the specific order from the field trip link helping me write my trialfun function and it didn't seem to give me any issues (at least that I know of). I believe the order doesn't matter in this case then.


Get Outlook for iOS<https://aka.ms/o0ukef>
________________________________
From: fieldtrip <fieldtrip-bounces at science.ru.nl> on behalf of Schoffelen, J.M. (Jan Mathijs) via fieldtrip <fieldtrip at science.ru.nl>
Sent: Saturday, June 22, 2024 3:48:48 PM
To: FieldTrip discussion list <fieldtrip at science.ru.nl>
Cc: Schoffelen, J.M. (Jan Mathijs) <janmathijs.schoffelen at donders.ru.nl>
Subject: [EXTERNAL]Re: [FieldTrip] ft_definetrial Error on Field trip

***ATTENTION: This email came from an external source. Do not open attachments or click on links from unknown senders or unexpected emails.***

Dear Vanessa,

I don’t know the structure of your trigger sequence, but the error that you get suggests, that the logic that you use in trialfun_orientation_trigger is never fulfilled.
specifically, the line ‘if trg1==10 && trg2==50, does never yield a ’true’ value, so not trials are defined.

Do you know how to use the matlab debugger? If not, please look it up on google, and specify a breakpoint in your code where you define the value variable. As a side note ( I am not sure) should this line not read strcmp({event.type},’trigger’), rather than strcmp(’trigger’,{event.type}) ?

Once you have the debugger switched on, you can explore the execution of your code line by line. Specifically, you could explore the sequence of trigger values, which - according to your code - apparently assumes that a trigger with value ’10’ will be followed by a ’50’, not as the next value, but as the second trigger down the line.

Good luck,
Jan-Mathijs


On 20 Jun 2024, at 00:28, Vanessa Oluwato Ayo-Jibunoh via fieldtrip <fieldtrip at science.ru.nl> wrote:

Good evening,

Hope your day is going well.

My name is Vanessa Ayo- Jibunoh and I am working in the Perception Lab at the CUNY Graduate Center in New York city on Ensemble Perception. I am currently analyzing data for this project, where we recorded using EEG.

I'm reaching out because I keep getting this error message "Error using ft_definetrial (line 209)
no trials were defined, see FT_DEFINETRIAL for help" when I try to define my trials.

I'm working with a .set datafile from EEGlab and I'm trying to separate my EEG data by trials using the ft_definetrail function.

Provided below are the cfg details I'm working with.

cfg =

  struct with fields:

    datafile: 'Acquisition 09.set'
    trialfun: 'trialfun_orientation_trigger'
    trialdef: [1×1 struct]


And, as it is an EEG datafile, this is the event structure.

event =

  1×1798 struct array with fields:

    type
    value
    sample
    offset
    duration
    urevent


I have written the code for the "trialfun" function that precedes the ft_definetrialfunction and it seems to be written just fine and according to the code provided by this link on the fieldtrip website itself  "Making your own trialfun for conditional trial definition - FieldTrip toolbox<https://www.fieldtriptoolbox.org/example/trialfun/>" . This is the code;

function [trl, event] = trialfun_orientation_trigger(cfg);
cfg.dataset = 'Acquisition 09.set'
cfg.trialdef.prestim = 0.5
cfg.trialdef.poststim = 1
hdr = ft_read_header(cfg.dataset)
event = ft_read_event (cfg.dataset)
value = [event(find(strcmp('trigger', {event.type}))).value]'
sample = [event(find(strcmp('trigger', {event.type}))).sample]'
pretrig = -round(cfg.trialdef.prestim * hdr.Fs)
posttrig = round(cfg.trialdef.poststim * hdr.Fs)
trl = []
for j = 1:(length(value)-1)
trg1 = value(j);
trg2 = value (j+2);
if trg1==10 && trg2==50
trlbegin = sample(j) + pretrig;
trlend = sample(j) + posttrig;
offset = pretrig;
newtrl = [trlbegin trlend offset];
trl = [trl; newtrl];
end
end
end
However, when I plug this function into another code to define the trial, it gives me the error "Error using ft_definetrial (line 209) no trials were defined, see FT_DEFINETRIAL for help".

I will also provide the final code that is giving me a problem below
cfg = []
cfg.datafile = 'Acquisition 09.set' ;
cfg.trialfun = 'trialfun_orientation_trigger';
cfg.trialdef.eventtype = 'trigger';
cfg.trialdef.eventvalue = [0 10 20];
cfg.trialdef.prestim = .5;
cfg.trialdef.poststim = 1;
ft_definetrial(cfg);
I'm not sure if it is a syntax error or I would have to write another code separately to define the 'trigger' in the event type as well to get the ft_definetrial function to work. I would like assistance from someone who is better experienced with this please.

Thank you,
God bless you.
_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://doi.org/10.1371/journal.pcbi.1002202

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20240622/87c4b829/attachment.htm>


More information about the fieldtrip mailing list