[FieldTrip] Where to add a trialfun?
Lam, Nietzsche
n.lam at fcdonders.ru.nl
Mon Sep 29 10:45:53 CEST 2014
Hi Ana Laura,
I've now noticed that you use "definetrial(cfg)" instead of "ft_definetrial", it was probably about 5 years ago that we used "definetrial". We do maintain backward compatibility, but from what I can see "trialfun_bit2dec" was only written this year, so that is probably why "definetrial" doesn't recognize it, and you get the error message "Error using feval Invalid function name 'trialfun_bit2dec(cfg)".
For a bit more background, we constantly change, and update these changes in FieldTrip, so it would be best to get the newest version of Fieldtrip, and adjust your script(s) accordingly.
You also referred to "this trialfun" in your email. Both "trialfun_bit2dec" and "ft_trialfun_general" are trialfuns (trial functions).
Ft_definetrial is not (strictly) a trial function. Ft_definetrial gets information from a trial function (like one of the two aforementioned, or you can custom write your own) and then segments the data accordingly.
Best,
Nietzsche
----- Original Message -----
> From: "Ana Laura Diez Martini" <diezmartini at gmail.com>
> To: "FieldTrip discussion list" <fieldtrip at science.ru.nl>
> Sent: Saturday, 27 September, 2014 7:18:25 PM
> Subject: Re: [FieldTrip] Where to add a trialfun?
> Thank you Nietzsche!
>
>
> I added it where you suggested and now this is the error I get:
>
>
>
> Error using feval
> Invalid function name 'trialfun_bit2dec(cfg)'.
>
>
> Error in definetrial (line 105)
> trl = feval(cfg.trialfun, cfg);
>
>
> Error in process_ERP_1_fieldtrip (line 97)
> cfg = definetrial(cfg);
>
>
> Something I was worried about is that I use an old version of
> Fieldtrip for my scripts because I wrote them long ago and this
> trialfun uses the new format (with 'ft_s',etc.). Could this affect it
> in any way?
>
>
> Thanks again!
>
>
> On Fri, Sep 26, 2014 at 11:05 PM, Lam, Nietzsche <
> n.lam at fcdonders.ru.nl > wrote:
>
>
> Hi Ana Laura,
>
> In general, you need to determine which trial function (Trialfun) to
> use when using definetrial (see this tutorial:
> http://fieldtrip.fcdonders.nl/tutorial/preprocessing under "do the
> trial definition for the fully incongruent (FIC) condition).
>
> Please try adding this: "cfg.trialfun = 'trialfun_bit2dec(cfg)". to
> your code before calling definetrial (see below).
>
> % TRIAL DEFINITION
> cfg=[];
> cfg.filename = ['my/folders/', subject, '.RAW'];
> cfg.headerfile = ['my/folders/', subject, '.RAW'];
>
> cfg.trialdef.eventtype = 'STATUS';
> cfg.trialdef.eventvalue = cgrmrk;
> cfg.trialdef.prestim = 0.2;
> cfg.trialdef.poststim = 1;
> cfg.trialdef.eventtype=?;
> cfg.trialfun = 'trialfun_bit2dec(cfg) %% trialfun definition
> cfg = definetrial(cfg);
>
>
> As an addition note: based on your error message, it seemed that the
> problem was in the function trialfun_bit2dec. However, from the code
> you showed us, you haven't referenced/called this function. I was
> wondering if the code you provide corresponded to the code that
> created your error message? I'm guessing you ran [trl]
> =trialfun_bit2dec(cfg) directly (i.e. not via definetrial). In which
> case, it was looking for cfg.trialdef.eventtype. You can call
> trialfun_bit2dec as long as you have all the relevant information in
> the cfg (which is in the code you showed us). Hope this helps.
>
> Best,
> Nietzsche
>
>
>
>
>
>
> ----- Original Message -----
> > From: "Ana Laura Diez Martini" < diezmartini at gmail.com >
> > To: "FieldTrip discussion list" < fieldtrip at science.ru.nl >
> > Sent: Saturday, 27 September, 2014 2:42:21 AM
> > Subject: [FieldTrip] Where to add a trialfun?
> > Hello all! I'm having a simple problem. I want to add this trialfun:
> >
> > http://fieldtrip.fcdonders.nl/faq/how_can_i_transform_trigger_values_from_bits_to_decimal_representation_with_a_trialfun
> >
> >
> >
> > I get this error:
> >
> >
> >
> > Reference to non-existent field 'trialdef'.
> >
> >
> > Error in trialfun_bit2dec (line 52)
> > if strcmp(event(i).type, cfg.trialdef.eventtype)
> >
> >
> > I'm quite sure it's because I'm not writing it in the correct part
> > of
> > my script. This is my trial definition part. Where should I add it
> > and
> > how should I write the line?
> >
> >
> >
> > % TRIAL DEFINITION
> > cfg=[];
> > cfg.filename = ['my/folders/', subject, '.RAW'];
> > cfg.headerfile = ['my/folders/', subject, '.RAW'];
> >
> >
> > cfg.trialdef.eventtype = 'STATUS';
> > cfg.trialdef.eventvalue = cgrmrk;
> > cfg.trialdef.prestim = 0.2;
> > cfg.trialdef.poststim = 1;
> > cfg.trialdef.eventtype=?;
> >
> >
> > cfg = definetrial(cfg);
> >
> >
> > trl = cfg.trl;
> > cfg=[];
> > cfg.dataset = ['my/folders/', subject, '.RAW'];
> > cfg.trl = trl;
> > cfg.reref = 'yes';
> > cfg.refchannel = ['all'];
> >
> >
> > THANKS!
> > _______________________________________________
> > fieldtrip mailing list
> > fieldtrip at donders.ru.nl
> > http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>
> --
> Nietzsche H.L. Lam, MSc
> PhD Candidate
>
> Max Planck Institute for Psycholinguistics
> Wundtlaan 1, 6525 XD Nijmegen, The Netherlands
>
> Donders Institute for Brain, Cognition and Behaviour,
> Centre for Cognitive Neuroimaging,
> Kapittelweg 29, 6525EN Nijmegen, The Netherlands
>
> n.lam at fcdonders.ru.nl
> +31-24-3668219
>
>
> neurobiologyoflanguage.com
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl
> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>
>
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl
> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
--
Nietzsche H.L. Lam, MSc
PhD Candidate
Max Planck Institute for Psycholinguistics
Wundtlaan 1, 6525 XD Nijmegen, The Netherlands
Donders Institute for Brain, Cognition and Behaviour,
Centre for Cognitive Neuroimaging,
Kapittelweg 29, 6525EN Nijmegen, The Netherlands
n.lam at fcdonders.ru.nl
+31-24-3668219
neurobiologyoflanguage.com
More information about the fieldtrip
mailing list