[FieldTrip] Where to add a trialfun?

Ana Laura Diez Martini diezmartini at gmail.com
Mon Sep 29 19:00:26 CEST 2014


Thank you again Nietzsche!!

Yes, I was referring to trialfun_bit2dec. I followed your advice and I
changed definetrial to ft_definetrial and I confirm the function was added
to my paths. After doing this, the error I get is:

Attempted to access trl(:,1); index out of bounds because size(trl)=[0,0].

Error in trialfun_bit2dec (line 66)
idx = any(diff(trl(:,1),1,1),2);

Error in ft_definetrial (line 169)
    trl   = feval(cfg.trialfun, cfg);

Error in process_ERP_1_fieldtrip (line 95)
    cfg = ft_definetrial(cfg);

This is again the trial definition part in which I think I added what I
think are useless lines but I was just trying to make it run it.

  % TRIAL DEFINITION
    cfg=[];
    cfg.filename = ['myfolders/subject.RAW'];
    cfg.headerfile = ['myfolders/subject.RAW'];
    cfg.dataset = ['myfolders/subject.RAW'];
    cfg.trialfun   = 'trialfun_bit2dec';  %% trialfun definition
    cfg.trialdef.eventtype    = 'STATUS';
    cfg.trialdef.eventvalue   = cgrmrk; % stimulus triggers
    cfg.trialdef.prestim      = 0.2; % latency in seconds
    cfg.trialdef.poststim     = 1;   % latency in seconds
    cfg = ft_definetrial(cfg);

    trl = cfg.trl;
    cfg=[];
    cfg.dataset = ['myfolders/subject.RAW'];
    cfg.trl           = trl;
    cfg.reref         = 'yes';
    cfg.refchannel    = ['all'];

Unfortunately using this function is crucial to my analysis because I would
like to use only Fieldtrip to analyse all my data. Thank you for taking all
this time.

On Sun, Sep 28, 2014 at 10:53 PM, Lam, Nietzsche <n.lam at fcdonders.ru.nl>
wrote:

> Hi again Ana Laura,
>
> One other thing that I thought of was to make sure that the function
> "trialfun_bit2dec" is added to your paths in matlab, so that ft_definetrial
> can find this function.
>
> By updating your fieldtrip to the most recent version "trialfun_bit2dec"
> is *not* included. So you'll need to store that as a separate .m file in a
> location that can be accessed by the paths set in matlab.
>
> 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
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl
> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20140929/5aff585e/attachment-0001.html>


More information about the fieldtrip mailing list