<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
Hi Mathew,
<div class=""><br class="">
</div>
<div class="">I am a bit surprised that you think that you need to adjust the ft_trialfun_general. The idea is that this function is quite generic, and given the scenario that you sketch, you probably don’t need to change any fieldtrip function. The partial
 error that you report is difficult to evaluate, since it’s only partial. Right now it’s just random guessing as to what might be going on. The error looks as if MATLAB tries to access a structure’s field called headerfile, but for some reason in does not exist
 in the struct that it is evaluating.</div>
<div class=""><br class="">
</div>
<div class="">for instance, if you define on the matlab command line the following struct:</div>
<div class=""><br class="">
</div>
<div class="">x.a = 1;</div>
<div class=""><br class="">
</div>
<div class="">and then query x.b, you get the error you report. </div>
<div class=""><br class="">
</div>
<div class="">What is the full error stack, i.e. which line in which matlab function is throwing the error?  And what is the code that you try to execute (i.e. the specification of the cfg, and the fieldtrip function you are calling).<br class="">
<div><br class="">
</div>
<div>Good luck,</div>
<div>Jan-Mathijs</div>
<div><br class="">
</div>
<div><br class="">
<blockquote type="cite" class="">
<div class="">On 19 Apr 2023, at 16:27, Varghese Mathew 1881002 via fieldtrip <<a href="mailto:fieldtrip@science.ru.nl" class="">fieldtrip@science.ru.nl</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div dir="ltr" class="">Hi
<div class="">I am doing analysis on Netstation EGI .mff file using Fieldtrip, I have tried using .mff file directly and after converting to EDF. However, I am getting error in defining trials. Mostly I get an error message 
<span style="color:rgb(52,53,65);font-family:Söhne,ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,Ubuntu,Cantarell,"Noto Sans",sans-serif,"Helvetica Neue",Arial,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";font-size:16px;white-space:pre-wrap" class="">
Unrecognized field name "headerfile" </span> . </div>
<div class="">I would like to know how to go about this in EDF or .mff format.</div>
<div class="">It will also be helpful if someone can help with how to modify ft_trialfun_general for .mff file as well.</div>
<div class="">I am pasting the code I used, below.</div>
<div class="">
<div class="">
<div class="gmail-rtcContent" style="padding:30px">
<div class="gmail-lineNode" style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace">
<span style="white-space:pre" class="">cfg=[]</span></div>
<div class="gmail-lineNode" style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace">
<span style="white-space:pre" class="">cfg.dataset = <span style="color:rgb(167,9,245)" class="">
'E:\FT\OP17.mff'</span>;</span></div>
<div class="gmail-lineNode" style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace">
<span style="white-space:pre" class="">cfg.dataformat = <span style="color:rgb(167,9,245)" class="">
'egi_mff_v3'</span></span></div>
<div class="gmail-lineNode" style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace">
<span style="white-space:pre" class="">cfg.headerformat = <span style="color:rgb(167,9,245)" class="">
'egi_mff_v3'</span></span></div>
<div class="gmail-lineNode" style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace">
<span style="white-space:pre" class="">cfg.trialdef.eventtype = <span style="color:rgb(167,9,245)" class="">
'stim'</span>;</span></div>
<div class="gmail-lineNode" style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace">
<span style="white-space:pre" class="">cfg.trialdef.prestim = 1;</span></div>
<div class="gmail-lineNode" style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace">
<span style="white-space:pre" class="">cfg.trialdef.poststim =1;</span></div>
<div class="gmail-lineNode" style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace">
<span style="white-space:pre" class="">cfg.trialdef.eventvalue = {<span style="color:rgb(167,9,245)" class="">'01''02''03''04'</span>};</span></div>
<div class="gmail-lineNode" style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace">
<span style="white-space:pre" class="">cfg.trialfun = <span style="color:rgb(167,9,245)" class="">
'ft_trialfun_general_stimmod'</span>;</span></div>
<div class="gmail-lineNode" style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace">
<span style="white-space:pre" class="">cfg = ft_definetrial(cfg)</span></div>
<div class="gmail-lineNode" style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace">
<span style="white-space:pre" class=""><br class="">
</span></div>
<div class="gmail-lineNode" style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace">
<span style="white-space:pre" class=""><br class="">
</span></div>
<div class="gmail-lineNode" style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace">
<span style="white-space:pre" class="">For modifying trialfun_general</span></div>
<div class="gmail-lineNode" style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace">
<div class="gmail-rtcContent" style="padding:30px">
<div class="gmail-lineNode" style="font-size:10pt"><span style="white-space:pre" class=""><span style="color:rgb(14,0,255)" class=""><br class="">
</span></span></div>
<div class="gmail-lineNode" style="font-size:10pt"><span style="white-space:pre" class=""><span style="color:rgb(14,0,255)" class="">function
</span>[trl, event] = ft_trialfun_general_stimmod(cfg)</span></div>
<div class="gmail-lineNode" style="font-size:10pt"></div>
<div class="gmail-lineNode" style="font-size:10pt"><span style="white-space:pre" class="">event = ft_read_event(cfg.dataset,
<span style="color:rgb(167,9,245)" class="">'headerformat'</span>, <span style="color:rgb(167,9,245)" class="">
'egi_mff_v3'</span>);</span></div>
<div class="gmail-lineNode" style="font-size:10pt"></div>
<div class="gmail-lineNode" style="font-size:10pt"><span style="white-space:pre" class=""><span style="color:rgb(0,128,19)" class="">% Find trigger values</span></span></div>
<div class="gmail-lineNode" style="font-size:10pt"><span style="white-space:pre" class="">trigger = [event(strcmp(<span style="color:rgb(167,9,245)" class="">'stim'</span>, {event.type})).value]';</span></div>
<div class="gmail-lineNode" style="font-size:10pt"><span style="white-space:pre" class=""><span style="color:rgb(0,128,19)" class="">% Note: Replace 'STI101' with the label of the trigger channel that</span></span></div>
<div class="gmail-lineNode" style="font-size:10pt"><span style="white-space:pre" class=""><span style="color:rgb(0,128,19)" class="">% contains the trigger values for your data</span></span></div>
<div class="gmail-lineNode" style="font-size:10pt"></div>
<div class="gmail-lineNode" style="font-size:10pt"><span style="white-space:pre" class=""><span style="color:rgb(0,128,19)" class="">% Define trial segments</span></span></div>
<div class="gmail-lineNode" style="font-size:10pt"><span style="white-space:pre" class="">trl = [];</span></div>
<div class="gmail-lineNode" style="font-size:10pt"><span style="white-space:pre" class=""><span style="color:rgb(14,0,255)" class="">for
</span>j = 1:length(trigger)</span></div>
<div class="gmail-lineNode" style="font-size:10pt"><span style="white-space:pre" class=""><span style="color:rgb(14,0,255)" class="">if
</span>any(trigger(j) == [01 02 03 04])</span></div>
<div class="gmail-lineNode" style="font-size:10pt"><span style="white-space:pre" class="">trlbegin = event(j).sample;</span></div>
<div class="gmail-lineNode" style="font-size:10pt"><span style="white-space:pre" class="">trlend = trlbegin + 1000;
<span style="color:rgb(0,128,19)" class="">% define trial length as 1 second</span></span></div>
<div class="gmail-lineNode" style="font-size:10pt"><span style="white-space:pre" class="">offset = 0;
<span style="color:rgb(0,128,19)" class="">% no offset</span></span></div>
<div class="gmail-lineNode" style="font-size:10pt"><span style="white-space:pre" class="">newtrl = [trlbegin trlend offset trigger(j)];</span></div>
<div class="gmail-lineNode" style="font-size:10pt"><span style="white-space:pre" class="">trl = [trl; newtrl];</span></div>
<div class="gmail-lineNode" style="font-size:10pt"><span style="white-space:pre" class=""><span style="color:rgb(14,0,255)" class="">end</span></span></div>
<div class="gmail-lineNode" style="font-size:10pt"><span style="white-space:pre" class=""><span style="color:rgb(14,0,255)" class="">end</span></span></div>
</div>
</div>
</div>
</div>
<div class="">Please help with the issue, as I am trying to pick up analysis using Fieldtrip and I do not have a coding background.<br class="">
</div>
<div class="">
<div class="">Looking forward for a response, </div>
</div>
<div class=""><br class="">
</div>
<div class="">Sincerely</div>
<span class="gmail_signature_prefix">-- </span><br class="">
<div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div dir="ltr" class="">Varghese Mathew</div>
<div dir="ltr" class=""><br class="">
</div>
</div>
</div>
</div>
</div>
</div>
_______________________________________________<br class="">
fieldtrip mailing list<br class="">
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" class="">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br class="">
https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!8eNI3v7br-aNv3JFKJb7V4Q_aWWLR3pG3xSWq653eKc8M3szkc7gmh51AkzytjbLsNllQtMkOdF4QKsVIokOhTwtxZRljnjlhEkwJA$
<br class="">
</div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>