[FieldTrip] BVA preprocessed data importing

Schoffelen, J.M. (Jan Mathijs) janmathijs.schoffelen at donders.ru.nl
Tue Feb 22 17:02:26 CET 2022


Hi Tuba,

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.

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?
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?

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

endsample(1:end-1) = begsample(2:end) - 1;

endsample(end) = hdr.nSamples*hdr.nTrials;

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.

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.

Best wishes,
Jan-Mathijs


On 22 Feb 2022, at 07:09, tuba aktürk via fieldtrip <fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl>> wrote:

Dear all,

I have a question about brain vision preprocessed EEG data importing to the Filedtrip;

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!

path = 'C:\Vision\Analyzer2\export\';

% Subject Lists
subjs = {'t01' 't02' 't03' 't04' 't05'};

% Condition Lists
cond = {'Segmentation_-1500_1500_aud_post' 'Segmentation_-1500_1500_aud_pre'};

for i=1:length(subjs)
    for k=1:length(cond)
        cfg                 = [];
        cfg.trialfun        = 'ft_trialfun_brainvision_segmented';
        cfg.continuous      = 'no';
        cfg.demean          = 'yes';
        cfg.baselinewindow  = [-200 0];
        cfg.dataset         = [path subjs{i} cond{k} '.eeg'];
        cfg.headerfile      = [path subjs{i} cond{k} '.vhdr'];

        cfg = ft_definetrial(cfg);

        if k == 1
            subj(i).aud_post = ft_preprocessing (cfg);
        elseif k == 2
            subj(i).aud_pre = ft_preprocessing (cfg);

        end
    end
end

Best regards,
Tuba

--
Tuba Aktürk

PhD Student
Cognitive Neuroscience, Psychology and Neuroscience, Maastricht University &
Neuroscience, Graduate School of Health Science, Istanbul Medipol University

_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!4R28OcVF-5I0P1wdfdT-7cXOlDMjv2aKYPlNS0gQp1G5Dx3Tg718c-N_ELKvYe9NRL3hK_JFi0cuyGLwtnYSI6f4cfMueSbQbEZ39A$

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20220222/9f4db18d/attachment.htm>


More information about the fieldtrip mailing list