<div dir="ltr">Thank you <span style="font-family:arial,sans-serif;font-size:13px">Nietzsche!</span><div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:13px">I added it where you suggested and now this is the error I get:</span></div><div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><div><font face="arial, sans-serif">Error using feval</font></div><div><font face="arial, sans-serif">Invalid function name 'trialfun_bit2dec(cfg)'.</font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">Error in definetrial (line 105)</font></div><div><font face="arial, sans-serif"> trl = feval(cfg.trialfun, cfg);</font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">Error in process_ERP_1_fieldtrip (line 97)</font></div><div><font face="arial, sans-serif"> cfg = definetrial(cfg);</font></div></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">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?</font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">Thanks again!</font></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Sep 26, 2014 at 11:05 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 Ana Laura,<br>
<br>
In general, you need to determine which trial function (Trialfun) to use when using definetrial (see this tutorial: <a href="http://fieldtrip.fcdonders.nl/tutorial/preprocessing" target="_blank">http://fieldtrip.fcdonders.nl/tutorial/preprocessing</a> under "do the trial definition for the fully incongruent (FIC) condition).<br>
<br>
Please try adding this: "cfg.trialfun = 'trialfun_bit2dec(cfg)". to your code before calling definetrial (see below).<br>
<span class=""><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>
</span> 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 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.<br>
<br>
Best,<br>
Nietzsche<br>
<div><div class="h5"><br>
<br>
<br>
<br>
----- Original Message -----<br>
> From: "Ana Laura Diez Martini" <<a href="mailto:diezmartini@gmail.com">diezmartini@gmail.com</a>><br>
> To: "FieldTrip discussion list" <<a href="mailto:fieldtrip@science.ru.nl">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 of<br>
> my script. This is my trial definition part. Where should I add it 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>
</div></div>> _______________________________________________<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>
<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">n.lam@fcdonders.ru.nl</a><br>
<a href="tel:%2B31-24-3668219" value="+31243668219">+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">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>