<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 Tuba,
<div class=""><br class="">
</div>
<div class="">It’s a bit ill-specified what you mean with ’the newest versions of Fieldtrip’ so it is hard to pinpoint from a distance what is going on. My suggestion is first that you try and pinpoint a bit yourself what’s going on.</div>
<div class=""><br class="">
</div>
<div class="">Specifically, have you tested whether it is a problem of the data itself? In other words, do you have similar problems when you run the code on an old dataset that used to work for you?</div>
<div class="">Also, from which version of Fieldtrip are you experiencing problems? With which version did it still work? Has anything changed in the way you are exporting from BVA? Does it happen for all subjects? For all conditions?</div>
<div class=""><br class="">
</div>
<div class=""><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class="">One way to get a bit further would be to debug a bit more: the warning message is thrown in ft_read_data, results from a numerical comparison between the first column (begsample)
 and second column (endsample) of the trl-matrix. Given the warning, some of the endsamples are smaller than the begsamples, which is not allowed. The trl matrix is generated by ft_definetrial, which calls ft_trialfun_brainvision_segmented to do the heavy lifting.
 Lines 97 and 99 in the mentioned function to me seems the only place where it could go wrong, i.e. when </span></div>
<div class=""><span class="pl-en" style="box-sizing: border-box; color: var(--color-prettylights-syntax-entity); font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 12px; white-space: pre;"><br class="">
</span></div>
<div class=""><span class="pl-en" style="box-sizing: border-box; color: var(--color-prettylights-syntax-entity); font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 12px; white-space: pre;"><span class="pl-en" style="box-sizing: border-box; color: var(--color-prettylights-syntax-entity);">endsample</span><span style="caret-color: rgb(49, 59, 69); color: rgb(49, 59, 69); background-color: rgb(255, 255, 255);" class="">(</span><span class="pl-c1" style="box-sizing: border-box; color: var(--color-prettylights-syntax-constant);">1</span><span class="pl-k" style="box-sizing: border-box; color: var(--color-prettylights-syntax-keyword);">:</span><span class="pl-k" style="box-sizing: border-box; color: var(--color-prettylights-syntax-keyword);">end</span><span class="pl-k" style="box-sizing: border-box; color: var(--color-prettylights-syntax-keyword);">-</span><span class="pl-c1" style="box-sizing: border-box; color: var(--color-prettylights-syntax-constant);">1</span><span style="caret-color: rgb(49, 59, 69); color: rgb(49, 59, 69); background-color: rgb(255, 255, 255);" class="">)
</span><span class="pl-k" style="box-sizing: border-box; color: var(--color-prettylights-syntax-keyword);">=</span><span style="caret-color: rgb(49, 59, 69); color: rgb(49, 59, 69); background-color: rgb(255, 255, 255);" class="">
</span><span class="pl-en" style="box-sizing: border-box; color: var(--color-prettylights-syntax-entity);">begsample</span><span style="caret-color: rgb(49, 59, 69); color: rgb(49, 59, 69); background-color: rgb(255, 255, 255);" class="">(</span><span class="pl-c1" style="box-sizing: border-box; color: var(--color-prettylights-syntax-constant);">2</span><span class="pl-k" style="box-sizing: border-box; color: var(--color-prettylights-syntax-keyword);">:</span><span class="pl-k" style="box-sizing: border-box; color: var(--color-prettylights-syntax-keyword);">end</span><span style="caret-color: rgb(49, 59, 69); color: rgb(49, 59, 69); background-color: rgb(255, 255, 255);" class="">)
</span><span class="pl-k" style="box-sizing: border-box; color: var(--color-prettylights-syntax-keyword);">-</span><span style="caret-color: rgb(49, 59, 69); color: rgb(49, 59, 69); background-color: rgb(255, 255, 255);" class="">
</span><span class="pl-c1" style="box-sizing: border-box; color: var(--color-prettylights-syntax-constant);">1</span><span style="caret-color: rgb(49, 59, 69); color: rgb(49, 59, 69); background-color: rgb(255, 255, 255);" class="">;</span></span></div>
<div class=""><span class="pl-en" style="box-sizing: border-box; color: var(--color-prettylights-syntax-entity); font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 12px; white-space: pre;"><span style="caret-color: rgb(49, 59, 69); color: rgb(49, 59, 69); background-color: rgb(255, 255, 255);" class=""><br class="">
</span></span></div>
<div class=""><span class="pl-en" style="box-sizing: border-box; color: var(--color-prettylights-syntax-entity); font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 12px; white-space: pre;">endsample</span><span style="caret-color: rgb(49, 59, 69); color: rgb(49, 59, 69); font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 12px; white-space: pre; background-color: rgb(255, 255, 255);" class="">(</span><span class="pl-k" style="box-sizing: border-box; color: var(--color-prettylights-syntax-keyword); font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 12px; white-space: pre;">end</span><span style="caret-color: rgb(49, 59, 69); color: rgb(49, 59, 69); font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 12px; white-space: pre; background-color: rgb(255, 255, 255);" class="">)
</span><span class="pl-k" style="box-sizing: border-box; color: var(--color-prettylights-syntax-keyword); font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 12px; white-space: pre;">=</span><span style="caret-color: rgb(49, 59, 69); color: rgb(49, 59, 69); font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 12px; white-space: pre; background-color: rgb(255, 255, 255);" class="">
</span><span class="pl-smi" style="box-sizing: border-box; color: rgb(49, 59, 69); caret-color: rgb(49, 59, 69); font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 12px; white-space: pre;">hdr</span><span style="caret-color: rgb(49, 59, 69); color: rgb(49, 59, 69); font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 12px; white-space: pre; background-color: rgb(255, 255, 255);" class="">.</span><span class="pl-smi" style="box-sizing: border-box; color: rgb(49, 59, 69); caret-color: rgb(49, 59, 69); font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 12px; white-space: pre;">nSamples</span><span class="pl-k" style="box-sizing: border-box; color: var(--color-prettylights-syntax-keyword); font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 12px; white-space: pre;">*</span><span class="pl-smi" style="box-sizing: border-box; color: rgb(49, 59, 69); caret-color: rgb(49, 59, 69); font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 12px; white-space: pre;">hdr</span><span style="caret-color: rgb(49, 59, 69); color: rgb(49, 59, 69); font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 12px; white-space: pre; background-color: rgb(255, 255, 255);" class="">.</span><span class="pl-smi" style="box-sizing: border-box; color: rgb(49, 59, 69); caret-color: rgb(49, 59, 69); font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 12px; white-space: pre;">nTrials</span><span style="caret-color: rgb(49, 59, 69); color: rgb(49, 59, 69); font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 12px; white-space: pre; background-color: rgb(255, 255, 255);" class="">;</span></div>
<div class=""><br class="">
</div>
<div class=""><font color="#000000" class=""><span style="caret-color: rgb(0, 0, 0);" class="">Given that you state that only the last trial contains data, my hunch is that there is something wrong in the ordering of the values in begsample, because otherwise
 it cannot happen that all the endsamples(1:end-1) are smaller than their corresponding begsamples.</span></font></div>
<div class=""><br class="">
</div>
<div class="">Looking at the revision history of the file ft_trialfun_brainvision_segmented, it seems that the last functional change dates from somewhere in 2017, but I doubt whether this is the cause of your problem. </div>
<div class=""><br class="">
</div>
<div class="">Best wishes,</div>
<div class="">Jan-Mathijs</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">
<div>
<blockquote type="cite" class="">
<div class="">On 22 Feb 2022, at 07:09, tuba aktürk 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=""><font face="arial, sans-serif" class="">Dear all,</font>
<div class=""><font face="arial, sans-serif" class=""><br class="">
</font>
<div class="">
<div style="box-sizing:border-box" class=""><font face="arial, sans-serif" style="" class="">I have a question about brain vision preprocessed EEG data importing to the Filedtrip; </font></div>
<div style="box-sizing:border-box" class=""><font face="arial, sans-serif" style="" class=""><br class="">
</font></div>
<div style="box-sizing:border-box" class=""><font face="arial, sans-serif" style="" class="">Normally, I was using the below code for it, which worked perfectly so many times. But, with the newest versions of the Fieldtrip I am getting the warning: "Warning:
 endsample is before begsample, returning empty data", and it ends up with the trial structure where only the last trial is read and the previous ones appear blank... I searched blogs and Fieldtrip mailing list, however, didn't find any topic on that problem.
 I am sharing the script I am using below. If you have any suggestions or ideas I would be very grateful. Thanks!</font></div>
<div style="box-sizing:border-box;font-family:"Segoe UI",system-ui,"Apple Color Emoji","Segoe UI Emoji",sans-serif;font-size:14px" class="">
<br class="">
</div>
path = 'C:\Vision\Analyzer2\export\';<br class="">
<br class="">
% Subject Lists<br class="">
subjs = {'t01' 't02' 't03' 't04' 't05'};<br class="">
<br class="">
% Condition Lists<br class="">
cond = {'Segmentation_-1500_1500_aud_post' 'Segmentation_-1500_1500_aud_pre'};<br class="">
<br class="">
for i=1:length(subjs)<br class="">
    for k=1:length(cond)<br class="">
        cfg                 = []; <br class="">
        cfg.trialfun        = 'ft_trialfun_brainvision_segmented'; <br class="">
        cfg.continuous      = 'no';   <br class="">
        cfg.demean          = 'yes';  <br class="">
        cfg.baselinewindow  = [-200 0];  <br class="">
        cfg.dataset         = [path subjs{i} cond{k} '.eeg']; <br class="">
        cfg.headerfile      = [path subjs{i} cond{k} '.vhdr'];<br class="">
<br class="">
        cfg = ft_definetrial(cfg); <br class="">
    <br class="">
        if k == 1<br class="">
            subj(i).aud_post = ft_preprocessing (cfg); <br class="">
        elseif k == 2<br class="">
            subj(i).aud_pre = ft_preprocessing (cfg); <br class="">
            <br class="">
        end<br class="">
    end<br class="">
<div style="box-sizing:border-box;font-family:"Segoe UI",system-ui,"Apple Color Emoji","Segoe UI Emoji",sans-serif;font-size:14px" class="">
<span style="font-family:Arial,Helvetica,sans-serif;font-size:small" class="">end</span> </div>
<div class=""><br class="">
</div>
<div class="">Best regards,</div>
<div class="">Tuba </div>
<div class=""><br class="">
</div>
-- <br class="">
<div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">
<div dir="ltr" class="">
<div class=""><b class="">Tuba Aktürk</b></div>
<div class=""><b class=""><br class="">
</b></div>
<div class=""><i style="" class="">PhD Student<br class="">
Cognitive Neuroscience, Psychology and Neuroscience, Maastricht University </i><i style="" class="">&</i></div>
<div class=""><i style="" class="">Neuroscience, Graduate School of Health Science, Istanbul Medipol University</i><i style="" class=""><br class="">
</i></div>
<div 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!4R28OcVF-5I0P1wdfdT-7cXOlDMjv2aKYPlNS0gQp1G5Dx3Tg718c-N_ELKvYe9NRL3hK_JFi0cuyGLwtnYSI6f4cfMueSbQbEZ39A$
<br class="">
</div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>