<div dir="ltr"><div>Hey Ana Laura,<br><br></div><div>Seems from the error message you're getting <br><br>"Attempted to access trl(:,1); index out of bounds because size(trl)=[0,0]."<br><br></div><div>that none of the triggers were found in your event data. You might wanna check why this is happening, by debugging 'trialfun_bit2dec' on your input.<br><br></div><div>Best,<br>Arjen<br></div><div><br><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2014-09-29 19:00 GMT+02:00 Ana Laura Diez Martini <span dir="ltr"><<a href="mailto:diezmartini@gmail.com" target="_blank">diezmartini@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Thank you again Nietzsche!! <div><br></div><div>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:</div><div><br></div><div><div>Attempted to access trl(:,1); index out of bounds because size(trl)=[0,0].</div><div><br></div><div>Error in trialfun_bit2dec (line 66)</div><div>idx = any(diff(trl(:,1),1,1),2);</div><div><br></div><div>Error in ft_definetrial (line 169)</div><div> trl = feval(cfg.trialfun, cfg);</div><div><br></div><div>Error in process_ERP_1_fieldtrip (line 95)</div><div> cfg = ft_definetrial(cfg);</div></div><div><br></div><div>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.</div><div><br></div><div><div> % TRIAL DEFINITION</div><div> cfg=[];</div><div> cfg.filename = ['myfolders/subject.RAW']; </div><div> cfg.headerfile = ['myfolders/subject.RAW']; </div><div> cfg.dataset = ['myfolders/subject.RAW'];</div><div> cfg.trialfun = 'trialfun_bit2dec'; %% trialfun definition</div><div> cfg.trialdef.eventtype = 'STATUS';</div><div> cfg.trialdef.eventvalue = cgrmrk; % stimulus triggers</div><div> cfg.trialdef.prestim = 0.2; % latency in seconds</div><div> cfg.trialdef.poststim = 1; % latency in seconds</div><div> cfg = ft_definetrial(cfg);</div><div><br></div><div> trl = cfg.trl;</div><div> cfg=[];</div><div> cfg.dataset = ['myfolders/subject.RAW']; </div><span class=""><div> cfg.trl = trl;</div><div> cfg.reref = 'yes';</div><div> cfg.refchannel = ['all'];<span style="white-space:pre-wrap"> </span></div></span></div><div><span style="white-space:pre-wrap"><br></span></div><div><span style="white-space:pre-wrap">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. </span></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Sep 28, 2014 at 10:53 PM, Lam, Nietzsche <span dir="ltr"><<a href="mailto:n.lam@fcdonders.ru.nl" target="_blank">n.lam@fcdonders.ru.nl</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi again Ana Laura,<br>
<br>
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.<br>
<br>
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.<br>
<span><br>
Nietzsche<br>
<br>
----- Original Message -----<br>
> From: "Ana Laura Diez Martini" <<a href="mailto:diezmartini@gmail.com" target="_blank">diezmartini@gmail.com</a>><br>
> To: "FieldTrip discussion list" <<a href="mailto:fieldtrip@science.ru.nl" target="_blank">fieldtrip@science.ru.nl</a>><br>
</span><span>> Sent: Saturday, 27 September, 2014 7:18:25 PM<br>
</span><div><div>> Subject: Re: [FieldTrip] Where to add a trialfun?<br>
> Thank you Nietzsche!<br>
><br>
><br>
> I added it where you suggested and now this is the error I get:<br>
><br>
><br>
><br>
> Error using feval<br>
> Invalid function name 'trialfun_bit2dec(cfg)'.<br>
><br>
><br>
> Error in definetrial (line 105)<br>
> trl = feval(cfg.trialfun, cfg);<br>
><br>
><br>
> Error in process_ERP_1_fieldtrip (line 97)<br>
> cfg = definetrial(cfg);<br>
><br>
><br>
> Something I was worried about is that I use an old version of<br>
> Fieldtrip for my scripts because I wrote them long ago and this<br>
> trialfun uses the new format (with 'ft_s',etc.). Could this affect it<br>
> in any way?<br>
><br>
><br>
> Thanks again!<br>
><br>
><br>
> On Fri, Sep 26, 2014 at 11:05 PM, Lam, Nietzsche <<br>
> <a href="mailto:n.lam@fcdonders.ru.nl" target="_blank">n.lam@fcdonders.ru.nl</a> > wrote:<br>
><br>
><br>
> Hi Ana Laura,<br>
><br>
> In general, you need to determine which trial function (Trialfun) to<br>
> use when using definetrial (see this tutorial:<br>
> <a href="http://fieldtrip.fcdonders.nl/tutorial/preprocessing" target="_blank">http://fieldtrip.fcdonders.nl/tutorial/preprocessing</a> under "do the<br>
> trial definition for the fully incongruent (FIC) condition).<br>
><br>
> Please try adding this: "cfg.trialfun = 'trialfun_bit2dec(cfg)". to<br>
> your code before calling definetrial (see below).<br>
><br>
> % TRIAL DEFINITION<br>
> cfg=[];<br>
> cfg.filename = ['my/folders/', subject, '.RAW'];<br>
> cfg.headerfile = ['my/folders/', subject, '.RAW'];<br>
><br>
> cfg.trialdef.eventtype = 'STATUS';<br>
> cfg.trialdef.eventvalue = cgrmrk;<br>
> cfg.trialdef.prestim = 0.2;<br>
> cfg.trialdef.poststim = 1;<br>
> cfg.trialdef.eventtype=?;<br>
> cfg.trialfun = 'trialfun_bit2dec(cfg) %% trialfun definition<br>
> cfg = definetrial(cfg);<br>
><br>
><br>
> As an addition note: based on your error message, it seemed that the<br>
> problem was in the function trialfun_bit2dec. However, from the code<br>
> you showed us, you haven't referenced/called this function. I was<br>
> wondering if the code you provide corresponded to the code that<br>
> created your error message? I'm guessing you ran [trl]<br>
> =trialfun_bit2dec(cfg) directly (i.e. not via definetrial). In which<br>
> case, it was looking for cfg.trialdef.eventtype. You can call<br>
> trialfun_bit2dec as long as you have all the relevant information in<br>
> the cfg (which is in the code you showed us). Hope this helps.<br>
><br>
> Best,<br>
> Nietzsche<br>
><br>
><br>
><br>
><br>
><br>
><br>
> ----- Original Message -----<br>
> > From: "Ana Laura Diez Martini" < <a href="mailto:diezmartini@gmail.com" target="_blank">diezmartini@gmail.com</a> ><br>
> > To: "FieldTrip discussion list" < <a href="mailto:fieldtrip@science.ru.nl" target="_blank">fieldtrip@science.ru.nl</a> ><br>
> > Sent: Saturday, 27 September, 2014 2:42:21 AM<br>
> > Subject: [FieldTrip] Where to add a trialfun?<br>
> > Hello all! I'm having a simple problem. I want to add this trialfun:<br>
> ><br>
> > <a href="http://fieldtrip.fcdonders.nl/faq/how_can_i_transform_trigger_values_from_bits_to_decimal_representation_with_a_trialfun" target="_blank">http://fieldtrip.fcdonders.nl/faq/how_can_i_transform_trigger_values_from_bits_to_decimal_representation_with_a_trialfun</a><br>
> ><br>
> ><br>
> ><br>
> > I get this error:<br>
> ><br>
> ><br>
> ><br>
> > Reference to non-existent field 'trialdef'.<br>
> ><br>
> ><br>
> > Error in trialfun_bit2dec (line 52)<br>
> > if strcmp(event(i).type, cfg.trialdef.eventtype)<br>
> ><br>
> ><br>
> > I'm quite sure it's because I'm not writing it in the correct part<br>
> > of<br>
> > my script. This is my trial definition part. Where should I add it<br>
> > and<br>
> > how should I write the line?<br>
> ><br>
> ><br>
> ><br>
> > % TRIAL DEFINITION<br>
> > cfg=[];<br>
> > cfg.filename = ['my/folders/', subject, '.RAW'];<br>
> > cfg.headerfile = ['my/folders/', subject, '.RAW'];<br>
> ><br>
> ><br>
> > cfg.trialdef.eventtype = 'STATUS';<br>
> > cfg.trialdef.eventvalue = cgrmrk;<br>
> > cfg.trialdef.prestim = 0.2;<br>
> > cfg.trialdef.poststim = 1;<br>
> > cfg.trialdef.eventtype=?;<br>
> ><br>
> ><br>
> > cfg = definetrial(cfg);<br>
> ><br>
> ><br>
> > trl = cfg.trl;<br>
> > cfg=[];<br>
> > cfg.dataset = ['my/folders/', subject, '.RAW'];<br>
> > cfg.trl = trl;<br>
> > cfg.reref = 'yes';<br>
> > cfg.refchannel = ['all'];<br>
> ><br>
> ><br>
> > THANKS!<br>
> > _______________________________________________<br>
> > fieldtrip mailing list<br>
> > <a href="mailto:fieldtrip@donders.ru.nl" target="_blank">fieldtrip@donders.ru.nl</a><br>
> > <a href="http://mailman.science.ru.nl/mailman/listinfo/fieldtrip" target="_blank">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br>
><br>
> --<br>
> Nietzsche H.L. Lam, MSc<br>
> PhD Candidate<br>
><br>
> Max Planck Institute for Psycholinguistics<br>
> Wundtlaan 1, 6525 XD Nijmegen, The Netherlands<br>
><br>
> Donders Institute for Brain, Cognition and Behaviour,<br>
> Centre for Cognitive Neuroimaging,<br>
> Kapittelweg 29, 6525EN Nijmegen, The Netherlands<br>
><br>
> <a href="mailto:n.lam@fcdonders.ru.nl" target="_blank">n.lam@fcdonders.ru.nl</a><br>
> <a href="tel:%2B31-24-3668219" value="+31243668219" target="_blank">+31-24-3668219</a><br>
><br>
><br>
> <a href="http://neurobiologyoflanguage.com" target="_blank">neurobiologyoflanguage.com</a><br>
> _______________________________________________<br>
> fieldtrip mailing list<br>
> <a href="mailto:fieldtrip@donders.ru.nl" target="_blank">fieldtrip@donders.ru.nl</a><br>
> <a href="http://mailman.science.ru.nl/mailman/listinfo/fieldtrip" target="_blank">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br>
><br>
><br>
> _______________________________________________<br>
> fieldtrip mailing list<br>
> <a href="mailto:fieldtrip@donders.ru.nl" target="_blank">fieldtrip@donders.ru.nl</a><br>
> <a href="http://mailman.science.ru.nl/mailman/listinfo/fieldtrip" target="_blank">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br>
<br>
--<br>
Nietzsche H.L. Lam, MSc<br>
PhD Candidate<br>
<br>
Max Planck Institute for Psycholinguistics<br>
Wundtlaan 1, 6525 XD Nijmegen, The Netherlands<br>
<br>
Donders Institute for Brain, Cognition and Behaviour,<br>
Centre for Cognitive Neuroimaging,<br>
Kapittelweg 29, 6525EN Nijmegen, The Netherlands<br>
<br>
<a href="mailto:n.lam@fcdonders.ru.nl" target="_blank">n.lam@fcdonders.ru.nl</a><br>
<a href="tel:%2B31-24-3668219" value="+31243668219" target="_blank">+31-24-3668219</a><br>
<br>
<br>
<a href="http://neurobiologyoflanguage.com" target="_blank">neurobiologyoflanguage.com</a><br>
_______________________________________________<br>
fieldtrip mailing list<br>
<a href="mailto:fieldtrip@donders.ru.nl" target="_blank">fieldtrip@donders.ru.nl</a><br>
<a href="http://mailman.science.ru.nl/mailman/listinfo/fieldtrip" target="_blank">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br>
</div></div></blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
fieldtrip mailing list<br>
<a href="mailto:fieldtrip@donders.ru.nl">fieldtrip@donders.ru.nl</a><br>
<a href="http://mailman.science.ru.nl/mailman/listinfo/fieldtrip" target="_blank">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br></blockquote></div><br></div>