<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="">
apologies for the multiple postings: i made a typo in my previous message: the line that reads ’ft_trialfun_general’, should of course read ’ft_trialfun_show’.
<div class=""><br class="">
</div>
<div class="">Best wishes,</div>
<div class="">Jan-Mathijs</div>
<div class=""><br class="">
<div><br class="">
<blockquote type="cite" class="">
<div class="">On 24 Apr 2023, at 14:31, Jan Mathijs Schoffelen <<a href="mailto:janmathijs.schoffelen@donders.ru.nl" class="">janmathijs.schoffelen@donders.ru.nl</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
Hi Mathew,
<div class=""><br class="">
</div>
<div class="">Thanks for the additional information.</div>
<div class=""><br class="">
</div>
<div class="">Note that ft_definetrial/ft_trialfun_general will only work according to expectation if eventtype and eventvalue are correctly specified. Their correct specification depends on how the events and their values are represented in the data file.
 This is something I don’t know for the format you use, but it could be that ’stim’ should read ’Stim’, and/or that the event values ahould be numeric( e.g., [1 2 3 4], rather than {’01’ ’02’ ’03’ ’04’}. If you are unsure about how values/types should be defined
 for your data, you should use the ft_trialfun_show function:</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
<div class="">
<div dir="ltr" class="">
<div class="">
<div class="" style="padding: 30px;">
<div class="" style="font-size: 10pt; font-family: Menlo, Monaco, Consolas, "Courier New", monospace;">
<span class="" style="white-space: pre-wrap;">datapath=<span class="" style="color: rgb(167, 9, 245);">'E:\FT\OFP1.mff'</span></span></div>
<div class="" style="font-size: 10pt; font-family: Menlo, Monaco, Consolas, "Courier New", monospace;">
<span class="" style="white-space: pre-wrap;">EGIformat= <span class="" style="color: rgb(167, 9, 245);">
'egi_mff_v3'</span></span></div>
<div class="" style="font-size: 10pt; font-family: Menlo, Monaco, Consolas, "Courier New", monospace;">
<span class="" style="white-space: pre-wrap;">cfg = [];</span></div>
<div class="" style="font-size: 10pt; font-family: Menlo, Monaco, Consolas, "Courier New", monospace;">
<span class="" style="white-space: pre-wrap;">cfg.dataset = datapath;</span></div>
<div class="" style="font-size: 10pt; font-family: Menlo, Monaco, Consolas, "Courier New", monospace;">
<span class="" style="white-space: pre-wrap;">cfg.dataformat = EGIformat</span></div>
<div class="" style="font-size: 10pt; font-family: Menlo, Monaco, Consolas, "Courier New", monospace;">
<span class="" style="white-space: pre-wrap;">cfg.headerformat = EGIformat</span></div>
<div class="" style="font-size: 10pt; font-family: Menlo, Monaco, Consolas, "Courier New", monospace;">
<span class="" style="white-space: pre-wrap; font-size: 10pt;">cfg.trialfun = </span>
<span class="" style="white-space: pre-wrap; font-size: 10pt; color: rgb(167, 9, 245);">'ft_trialfun_general’</span><span class="" style="white-space: pre-wrap; font-size: 10pt;">;</span></div>
<div class="" style="font-size: 10pt; font-family: Menlo, Monaco, Consolas, "Courier New", monospace;">
<span class="" style="white-space: pre-wrap; font-size: 10pt;">cfg=ft_definetrial(cfg);</span></div>
<div class="" style="font-size: 10pt; font-family: Menlo, Monaco, Consolas, "Courier New", monospace;">
<span class="" style="font-family: Helvetica; font-size: 14px;"><br class="">
</span></div>
<div class="" style="font-size: 10pt; font-family: Menlo, Monaco, Consolas, "Courier New", monospace;">
<span class="" style="font-family: Helvetica; font-size: 14px;"><br class="">
</span></div>
<div class="">This will give you some feedback on the screen, which you can use for a properly formatted call to ft_definetrial with trialfun = ‘ft_trialfun_general’</div>
<div class=""><br class="">
</div>
<div class="">Good luck,</div>
<div class="">Jan-Mathijs</div>
</div>
</div>
</div>
</div>
</div>
<div style="" class=""><br class="">
<blockquote type="cite" class="">
<div class="">On 22 Apr 2023, at 06:33, Varghese Mathew 1881002 <<a href="mailto:varghese.mathew@res.christuniversity.in" class="">varghese.mathew@res.christuniversity.in</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div dir="ltr" class="">Thank you so much for the response.
<div class="">I have tried using ft_trialfun_general in the following code</div>
<div class="">
<div style="padding:30px" class="">
<div style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
<span style="white-space:pre-wrap" class="">datapath=<span style="color:rgb(167,9,245)" class="">'E:\FT\OFP1.mff'</span></span></div>
<div style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
<span style="white-space:pre-wrap" class="">EGIformat= <span style="color:rgb(167,9,245)" class="">
'egi_mff_v3'</span></span></div>
<div style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
<span style="white-space:pre-wrap" class="">cfg = [];</span></div>
<div style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
<span style="white-space:pre-wrap" class="">cfg.dataset = datapath;</span></div>
<div style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
<span style="white-space:pre-wrap" class="">cfg.dataformat = EGIformat</span></div>
<div style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
<span style="white-space:pre-wrap" class="">cfg.headerformat = EGIformat</span></div>
<div style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
<span style="white-space:pre-wrap" class="">cfg.trialdef.eventtype = <span style="color:rgb(167,9,245)" class="">
'stim'</span>;</span></div>
<div style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
<span style="white-space:pre-wrap" class="">cfg.trialdef.prestim = 1;</span></div>
<div style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
<span style="white-space:pre-wrap" class="">cfg.trialdef.poststim =1;</span></div>
<div style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
<span style="white-space:pre-wrap" class="">cfg.trialdef.eventvalue = {<span style="color:rgb(167,9,245)" class="">'01''02''03''04'</span>};</span></div>
<div style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
<span style="white-space:pre-wrap" class="">cfg.trialfun = <span style="color:rgb(167,9,245)" class="">
'ft_trialfun_general'</span>;</span></div>
<div style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
<span style="white-space:pre-wrap" class="">cfg = ft_definetrial(cfg)</span></div>
<div style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
<span style="white-space:pre-wrap" class=""><br class="">
</span></div>
<div style="font-size:10pt" class=""><span style="white-space:pre-wrap" class=""><font face="arial, sans-serif" class="">I am getting a following response</font></span></div>
<div style="font-size:10pt" class=""><span style="white-space:pre-wrap" class=""><font face="arial, sans-serif" class=""><br class="">
</font></span></div>
<div style="font-size:10pt" class=""><font color="#ff0000" class="">Error using ft_definetrial<br class="">
no trials were defined, see FT_DEFINETRIAL for help</font><span style="white-space:pre-wrap" class=""><font face="arial, sans-serif" class=""><br class="">
</font></span></div>
<div style="font-size:10pt" class=""><font color="#ff0000" class=""><br class="">
</font></div>
<div style="font-size:10pt" class=""><font class="">This made me think if I should change the trialfun_general. Is there something I have missed and also is there any standard format to define trials on Netstation files (.mff)?</font></div>
<div style="font-size:10pt" class=""><br class="">
</div>
<div style="font-size:10pt" class="">Thank you again for the response.</div>
<div style="font-size:10pt" class=""><br class="">
</div>
<div style="font-size:10pt" class="">Sincerely</div>
<div style="font-size:10pt" class="">Varghese Mathew</div>
<div style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
</div>
</div>
</div>
<div class=""><br class="">
</div>
</div>
<br class="">
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Wed, Apr 19, 2023 at 11:12 PM Schoffelen, J.M. (Jan Mathijs) via fieldtrip <<a href="mailto:fieldtrip@science.ru.nl" target="_blank" class="">fieldtrip@science.ru.nl</a>> wrote:<br class="">
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div 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 class=""><br class="">
</div>
<div class="">Good luck,</div>
<div class="">Jan-Mathijs</div>
<div class=""><br class="">
</div>
<div class=""><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" target="_blank" class="">fieldtrip@science.ru.nl</a>> wrote:</div>
<br class="">
<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 style="padding:30px" class="">
<div style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
<span style="white-space:pre-wrap" class="">cfg=[]</span></div>
<div style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
<span style="white-space:pre-wrap" class="">cfg.dataset = <span style="color:rgb(167,9,245)" class="">
'E:\FT\OP17.mff'</span>;</span></div>
<div style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
<span style="white-space:pre-wrap" class="">cfg.dataformat = <span style="color:rgb(167,9,245)" class="">
'egi_mff_v3'</span></span></div>
<div style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
<span style="white-space:pre-wrap" class="">cfg.headerformat = <span style="color:rgb(167,9,245)" class="">
'egi_mff_v3'</span></span></div>
<div style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
<span style="white-space:pre-wrap" class="">cfg.trialdef.eventtype = <span style="color:rgb(167,9,245)" class="">
'stim'</span>;</span></div>
<div style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
<span style="white-space:pre-wrap" class="">cfg.trialdef.prestim = 1;</span></div>
<div style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
<span style="white-space:pre-wrap" class="">cfg.trialdef.poststim =1;</span></div>
<div style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
<span style="white-space:pre-wrap" class="">cfg.trialdef.eventvalue = {<span style="color:rgb(167,9,245)" class="">'01''02''03''04'</span>};</span></div>
<div style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
<span style="white-space:pre-wrap" class="">cfg.trialfun = <span style="color:rgb(167,9,245)" class="">
'ft_trialfun_general_stimmod'</span>;</span></div>
<div style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
<span style="white-space:pre-wrap" class="">cfg = ft_definetrial(cfg)</span></div>
<div style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
<span style="white-space:pre-wrap" class=""><br class="">
</span></div>
<div style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
<span style="white-space:pre-wrap" class=""><br class="">
</span></div>
<div style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
<span style="white-space:pre-wrap" class="">For modifying trialfun_general</span></div>
<div style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
<div style="padding:30px" class="">
<div style="font-size:10pt" class=""><span style="white-space:pre-wrap" class=""><span style="color:rgb(14,0,255)" class=""><br class="">
</span></span></div>
<div style="font-size:10pt" class=""><span style="white-space:pre-wrap" class=""><span style="color:rgb(14,0,255)" class="">function
</span>[trl, event] = ft_trialfun_general_stimmod(cfg)</span></div>
<div style="font-size:10pt" class=""></div>
<div style="font-size:10pt" class=""><span style="white-space:pre-wrap" 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 style="font-size:10pt" class=""></div>
<div style="font-size:10pt" class=""><span style="white-space:pre-wrap" class=""><span style="color:rgb(0,128,19)" class="">% Find trigger values</span></span></div>
<div style="font-size:10pt" class=""><span style="white-space:pre-wrap" class="">trigger = [event(strcmp(<span style="color:rgb(167,9,245)" class="">'stim'</span>, {event.type})).value]';</span></div>
<div style="font-size:10pt" class=""><span style="white-space:pre-wrap" class=""><span style="color:rgb(0,128,19)" class="">% Note: Replace 'STI101' with the label of the trigger channel that</span></span></div>
<div style="font-size:10pt" class=""><span style="white-space:pre-wrap" class=""><span style="color:rgb(0,128,19)" class="">% contains the trigger values for your data</span></span></div>
<div style="font-size:10pt" class=""></div>
<div style="font-size:10pt" class=""><span style="white-space:pre-wrap" class=""><span style="color:rgb(0,128,19)" class="">% Define trial segments</span></span></div>
<div style="font-size:10pt" class=""><span style="white-space:pre-wrap" class="">trl = [];</span></div>
<div style="font-size:10pt" class=""><span style="white-space:pre-wrap" class=""><span style="color:rgb(14,0,255)" class="">for
</span>j = 1:length(trigger)</span></div>
<div style="font-size:10pt" class=""><span style="white-space:pre-wrap" class=""><span style="color:rgb(14,0,255)" class="">if
</span>any(trigger(j) == [01 02 03 04])</span></div>
<div style="font-size:10pt" class=""><span style="white-space:pre-wrap" class="">trlbegin = event(j).sample;</span></div>
<div style="font-size:10pt" class=""><span style="white-space:pre-wrap" class="">trlend = trlbegin + 1000;
<span style="color:rgb(0,128,19)" class="">% define trial length as 1 second</span></span></div>
<div style="font-size:10pt" class=""><span style="white-space:pre-wrap" class="">offset = 0;
<span style="color:rgb(0,128,19)" class="">% no offset</span></span></div>
<div style="font-size:10pt" class=""><span style="white-space:pre-wrap" class="">newtrl = [trlbegin trlend offset trigger(j)];</span></div>
<div style="font-size:10pt" class=""><span style="white-space:pre-wrap" class="">trl = [trl; newtrl];</span></div>
<div style="font-size:10pt" class=""><span style="white-space:pre-wrap" class=""><span style="color:rgb(14,0,255)" class="">end</span></span></div>
<div style="font-size:10pt" class=""><span style="white-space:pre-wrap" 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="">-- </span><br class="">
<div dir="ltr" class="">
<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" target="_blank" class="">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br class="">
<a href="https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!8eNI3v7br-aNv3JFKJb7V4Q_aWWLR3pG3xSWq653eKc8M3szkc7gmh51AkzytjbLsNllQtMkOdF4QKsVIokOhTwtxZRljnjlhEkwJA$" target="_blank" class="">https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!8eNI3v7br-aNv3JFKJb7V4Q_aWWLR3pG3xSWq653eKc8M3szkc7gmh51AkzytjbLsNllQtMkOdF4QKsVIokOhTwtxZRljnjlhEkwJA$</a>
<br class="">
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
_______________________________________________<br class="">
fieldtrip mailing list<br class="">
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" rel="noreferrer" target="_blank" class="">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br class="">
<a href="https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!790wNYAs95ncJkCxJN-Y7IW-_m8uyJL3R275Ib_u1vRGM4SrI4E9u_Z4hEWrprE2g27wPafiw_1TM10Qp0p9qRfsq3NgKIZmbUafB6YShGYSfqIKGH2GJw$" rel="noreferrer" target="_blank" class="">https://doi.org/10.1371/journal.pcbi.1002202</a><br class="">
</blockquote>
</div>
<br clear="all" class="">
<div class=""><br class="">
</div>
<span class="">-- </span><br class="">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div class="">
<div dir="ltr" class="">
<div dir="ltr" class="">Varghese Mathew</div>
<div dir="ltr" class="">
<div class="">
<div class="">Mobile No. 9535395896</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>