<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">.style1 {font-family: "Times New Roman";}</style></head><body dir="auto">
<div dir="ltr">Hi Hannah, 
<div><br>
</div>
<div>I checked the source code for ft_trialfunbrainvision_segmented(<a href="https://github.com/fieldtrip/fieldtrip/blob/master/trialfun/ft_trialfun_brainvision_segmented.m">https://github.com/fieldtrip/fieldtrip/blob/master/trialfun/ft_trialfun_brainvision_segmented.m</a>),
 and going backwards from line 90 where your error occurred it seems that the function is expecting at least 2 events to be located in the file(one titled ‘New Segment’ and one directly after titled ‘Time 0’.)
<b>I believe if your data is missing the ‘Time 0’ event</b> for some reason then the code would error out at this point.</div>
<div><br>
</div>
<div> I haven’t used Brain vision analyzer but I would guess this event is added automatically but for some reason got removed(during removal of artifacts in the first few samples of an epoch/trial perhaps). I would try re-rejecting data and avoiding the very
 beginning of trials, and if that doesn’t work/you haven’t rejected data, then adding an if statement at line 89 to handle an empty t0 variable should be your next step. </div>
<div><br>
</div>
<div>I don’t have matlab open to help debug, but the code seems to expect there to be some delay between the ‘New Segment’ event and the ‘Time 0’ event and this is what t0 helps to account for. You could either set t0 = 0, which will use the sample for the
 ‘New Segment’ variable as the first sample(risky, assumes the delay until the ‘Time 0’ event is negligible), or you can use matlabs continue function to skip that trial(although this approach might cause other issues in the code). </div>
<div><br>
</div>
<div>Good luck, hope this helps!</div>
<div><br>
</div>
<div>Michael Glassen</div>
<div><span style="color: rgb(13, 124, 201); font-family: Tahoma, sans-serif; font-size: 9pt; -webkit-text-size-adjust: auto;">--------------------------------------------------------------------------</span></div>
<div>
<p class="MsoNormal" style="font-size: 12pt; -webkit-text-size-adjust: auto; margin: 0in 0in 0.0001pt; font-family: "Times New Roman", serif;">
<o:p></o:p></p>
<p class="MsoNormal" style="font-size: 12pt; -webkit-text-size-adjust: auto; margin: 0in 0in 0.0001pt; font-family: "Times New Roman", serif;">
<span style="font-size: 9pt; font-family: Tahoma, sans-serif; color: rgb(46, 116, 181);">Michael Glassen, M.S.</span><o:p></o:p></p>
<p class="MsoNormal" style="font-size: 12pt; -webkit-text-size-adjust: auto; margin: 0in 0in 0.0001pt; font-family: "Times New Roman", serif;">
<span style="font-size: 9pt; font-family: Tahoma, sans-serif; color: rgb(46, 116, 181);">Biomedical Engineer</span><o:p></o:p></p>
<p class="MsoNormal" style="font-size: 12pt; -webkit-text-size-adjust: auto; margin: 0in 0in 0.0001pt; font-family: "Times New Roman", serif;">
<span style="font-size: 9pt; font-family: Tahoma, sans-serif; color: rgb(46, 116, 181);">Human Performance and Engineering Lab</span><o:p></o:p></p>
<p class="MsoNormal" style="font-size: 12pt; -webkit-text-size-adjust: auto; margin: 0in 0in 0.0001pt; font-family: "Times New Roman", serif;">
<span style="font-size: 9pt; font-family: Tahoma, sans-serif; color: rgb(46, 116, 181);">Kessler Foundation</span><o:p></o:p></p>
<p class="MsoNormal" style="font-size: 12pt; -webkit-text-size-adjust: auto; margin: 0in 0in 0.0001pt; font-family: "Times New Roman", serif;">
<span style="font-size: 9pt; font-family: Tahoma, sans-serif; color: rgb(46, 116, 181);"><a href="https://www.google.com/maps/search/1199+Pleasant+Valley+Way,+West+Orange,+NJ,+07052?entry=gmail&source=g" target="_blank" style="color: purple;">1199 Pleasant Valley Way, West Orange, NJ, 07052</a></span><o:p></o:p></p>
<p class="MsoNormal" style="font-size: 12pt; -webkit-text-size-adjust: auto; margin: 0in 0in 0.0001pt; font-family: "Times New Roman", serif;">
<span style="font-size: 9pt; font-family: Tahoma, sans-serif; color: rgb(46, 116, 181);">Tel: <span dir="ltr" style="text-decoration: underline;">(973) 324 3526</span></span><o:p></o:p></p>
<p class="MsoNormal" style="font-size: 12pt; -webkit-text-size-adjust: auto; margin: 0in 0in 0.0001pt; font-family: "Times New Roman", serif;">
<span style="font-size: 9pt; font-family: Tahoma, sans-serif; color: rgb(46, 116, 181);">Email: <u><a href="mailto:mglassen@KesslerFoundation.org" target="_blank" style="color: purple;"><span style="color: rgb(46, 116, 181);">mglassen@KesslerFoundation.org</span></a></u></span><o:p></o:p></p>
<p class="MsoNormal" style="font-size: 12pt; -webkit-text-size-adjust: auto; margin: 0in 0in 0.0001pt; font-family: "Times New Roman", serif;">
 </p>
<div><br>
<div dir="ltr"><br>
</div>
<div dir="ltr"><br>
<blockquote type="cite">On Oct 12, 2021, at 12:35 AM, Hannah Anderson via fieldtrip <fieldtrip@science.ru.nl> wrote:<br>
<br>
</blockquote>
</div>
<blockquote type="cite">
<div dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Hello all, </div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I was hoping to get some assistance with the following</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
My supervisor has segmented data pre-processed in Brain Vision Analyser which I am trying to read into fieldtrip, but when I try and define trials using ft_trialfun_brainvision_segmented I get this error</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Index exceeds the number of array elements (0).
<div><br>
</div>
<div>Error in ft_trialfun_brainvision_segmented (line 90)</div>
<div>  t0 = t0(1); % take the first one in case there are multiple</div>
<div><br>
</div>
<div>Error in ft_definetrial (line 183)</div>
    [trl, event] = feval(cfg.trialfun, cfg);<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Thanks, </div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Hannah </div>
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div id="Signature">
<div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif">
<p style="font-size:11pt; font-family:Calibri,sans-serif; margin-bottom:0px; margin-top:0px">
<font color="#000000"><b>Hannah Anderson </b></font></p>
<p style="font-size:11pt; font-family:Calibri,sans-serif; margin-bottom:0px; margin-top:0px">
<span style="font-size:10pt">​<i>My pronouns are she/her/hers </i></span><br>
</p>
<font color="#000000" style="font-size:12pt"><span style="display:inline!important; background-color:rgb(255,255,255); font-size-adjust:none"></span></font>
<p style="font-size:11pt; color:rgb(32,31,30); font-family:Calibri,sans-serif; margin-bottom:0px; margin-top:0px">
</p>
<p style="margin:0cm; font-size:11pt; text-align:start; background-color:rgb(255,255,255)">
<span style="margin:0px; font-size:10pt; color:black">Research Assistant – Healthy Brain Ageing</span></p>
<p style="margin:0cm; font-size:11pt; text-align:start; background-color:rgb(255,255,255)">
<span style="margin:0px; font-size:10pt; color:black">BBiomedSc (Accel)<br>
Thompson Institute</span><span style="margin:0px"></span></p>
<p style="margin:0cm; font-size:11pt; text-align:start; background-color:rgb(255,255,255)">
<span style="margin:0px; font-size:10pt; color:black">USC</span><span lang="EN-GB" style="margin:0px; font-size:10pt; font-family:"MS Gothic"; color:black">
</span><span style="margin:0px"></span></p>
<p style="margin:0cm; font-size:11pt; text-align:start; background-color:rgb(255,255,255)">
<span style="margin:0px; font-size:10pt; color:black">Tel: +61 5430 1133</span></p>
<p style="font-size:11pt; color:rgb(32,31,30); font-family:Calibri,sans-serif; margin-bottom:0px; margin-top:0px">
<span lang="en-US" style="border-bottom-color:currentColor; border-left-color:currentColor; border-right-color:currentColor; border-top-color:currentColor; color:black; font-size-adjust:none; margin-bottom:0px; margin-top:0px"></span></p>
<font color="#000000" style="font-size:12pt"><span style="display:inline!important; background-color:rgb(255,255,255); font-size-adjust:none"></span></font>
<p style="font-size:11pt; color:rgb(32,31,30); font-family:Calibri,sans-serif; margin-bottom:0px; margin-top:0px">
<a href="mailto:mparker4@usc.edu.au" target="_blank" rel="noopener noreferrer" style="border-bottom-color:currentColor; border-left-color:currentColor; border-right-color:currentColor; border-top-color:currentColor; font-size-adjust:none; margin-bottom:0px; margin-top:0px"><span style="border-bottom-color:currentColor; border-left-color:currentColor; border-right-color:currentColor; border-top-color:currentColor; color:blue; font-size-adjust:none; margin-bottom:0px; margin-top:0px">handerson@usc.edu.au</span></a><span style="border-bottom-color:currentColor; border-left-color:currentColor; border-right-color:currentColor; border-top-color:currentColor; color:black; font-size-adjust:none; margin-bottom:0px; margin-top:0px">
 | </span><span style="border-bottom-color:currentColor; border-left-color:currentColor; border-right-color:currentColor; border-top-color:currentColor; color:blue; font-size-adjust:none; margin-bottom:0px; margin-top:0px"><a href="http://usc.edu.au/thompson-institute">usc.edu.au/thompson-institute</a></span></p>
<div><Outlook-mbvdqpsd.png></div>
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt">
<p style="color:rgb(32,31,30); text-align:start; background-color:rgb(255,255,255); font-size:11pt; font-family:Calibri,sans-serif; margin:0px">
<span style="margin:0px; font-size:10pt; color:rgb(127,127,127)">I acknowledge the Traditional Custodians of the lands and waters upon which the University's campuses are located.</span><span style="margin:0px; color:black"></span></p>
<p style="color:rgb(32,31,30); text-align:start; background-color:rgb(255,255,255); font-size:11pt; font-family:Calibri,sans-serif; margin:0px">
<span style="margin:0px; font-size:10pt; color:rgb(127,127,127)">I acknowledge their continuing connections to country and pay my respects to Elders past, present and emerging.</span><span style="margin:0px; color:black"></span></p>
<p style="color:rgb(32,31,30); text-align:start; background-color:rgb(255,255,255); font-size:11pt; font-family:Calibri,sans-serif; margin:0px">
<span style="margin:0px; color:black"> </span></p>
<p style="color:rgb(32,31,30); text-align:start; background-color:rgb(255,255,255); font-size:11pt; font-family:Calibri,sans-serif; margin:0px">
<span style="margin:0px; font-size:10pt; color:rgb(127,127,127)">University of the Sunshine Coast  l  CRICOS 01595D</span></p>
</div>
</div>
</div>
</div>
<span>_______________________________________________</span><br>
<span>fieldtrip mailing list</span><br>
<span><a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a></span><br>
<span><a href="https://doi.org/10.1371/journal.pcbi.1002202">https://doi.org/10.1371/journal.pcbi.1002202</a></span><br>
<span></span><br>
</div>
</blockquote>
</div>
</div>
</div>


<br><br><p style="font-family: Verdana; font-size:10pt; color:#666666;"><b>Disclaimer</b></p><p style="font-family: Verdana; font-size:8pt; color:#666666;">The information contained in this communication from the sender is confidential. It is intended solely for use by the recipient and others authorized to receive it. If you are not the recipient, you are hereby notified that any disclosure, copying, distribution or taking action in relation of the contents of this information is strictly prohibited and may be unlawful.<br><br>This email has been scanned for viruses and malware, and may have been automatically archived by Mimecast, a leader in email security and cyber resilience. Mimecast integrates email defenses with brand protection, security awareness training, web security, compliance and other essential capabilities. Mimecast helps protect large and small organizations from malicious activity, human error and technology failure; and to lead the movement toward building a more resilient world. To find out more, visit our website.</p></body></html>