[FieldTrip] ft_rejectvisual function gives errors in 2020 fieldtrip versions

Helena Pereira hri.pereira at campus.fct.unl.pt
Tue Jun 2 13:55:51 CEST 2020


Dear Jan-Mathijs,

Thank you for your quick response.

The code is now working!

*Please feel free to update the documentation section of the function in
order to avoid similar future problems with other users, and send us a PR
through github.  -> * I will do it!

Thanks!
Best wishes,
Helena Pereira



Schoffelen, J.M. (Jan Mathijs) <jan.schoffelen at donders.ru.nl> escreveu no
dia terça, 2/06/2020 à(s) 11:13:

> Dear Helena,
>
> Thanks for providing some more details. Indeed, the error occurs (as I
> suspected) because you explicitly define the cfg.ylim to have only a single
> element. This is incorrect because the code expects a 2-element vector
> (e.g. [-60 60]) once this parameter is defined as a numeric variable. I
> suspect that things will run through fine for you if you either omit
> cfg.ylim altogether, or specify it as ‘maxmin’, or specify a 2-element
> vector. I saw that this parameter is not documented in the help-section of
> the function, and I suspect there might be more undocumented options.
> Please feel free to update the documentation section of the function in
> order to avoid similar future problems with other users, and send us a PR
> through github.
> Thanks for noticing!
>
> Best wishes,
> Jan-Mathijs
>
>
> On 2 Jun 2020, at 11:16, Helena Pereira <hri.pereira at campus.fct.unl.pt>
> wrote:
>
> Dear Jan-Mathijs,
>
> Thank you for your e-mail.
>
> I am using data from the output of ICA (.mat data). Here is my * cfg for
> visual artifact*:
>
> cgf = [];
> cfg.preproc.demean = 'yes';
> cfg.prepoc.baselinewindow  = [-0.2 0];
> data_process=ft_preprocessing(cfg,data_process );
>
> cgf = [];
> cfg.method   = 'trial';
> cfg.ylim =  60;
> visual_cleaned = ft_rejectvisual(cfg,data_process);
>
> cgf = [];
> cfg.method   = 'channel';
> cfg.alim =  50 ; %why this value?
> %cfg.eogscale = 5e-8;
> vc_data = ft_rejectvisual(cfg,visual_cleaned);
>
> *For ICA: *
> cfg = [];
> %cfg.channel = 1:64;
> cfg.method = 'runica';
> cfg.demean = 'yes';
> ica_cleaned = ft_componentanalysis(cfg, vc_data);
>
> % %Save ICA data
> outfile=strcat(save_dir,'/',infile,'_', sti,'.mat')
> save(outfile, 'ica_cleaned', '-v7.3')
>
> *Before ICA, I did the following processing steps:*
> cfg = [];
> cfg.dataset=infile;   % infile: data.seg
> cfg.trialfun = 'ft_trialfun_general'; % this is the default
> cfg.trialdef.eventtype  = 'Stimulus'; %Event type: e.g. Stimulus,
> response, STATUS
> cfg.trialdef.eventvalue = {stimulus};
>
> cfg.trialdef.prestim    = 2; %latency in seconds
> cfg.trialdef.poststim   = 2; %latency in seconds
> cfg=ft_definetrial(cfg);
>
> % Processing AOC, AMC and MC data
> cfg.channel = [1:69]; %discard channels not used
> cfg.preproc.reref = 'yes';
> cfg.preproc.refchannel = {'M1' 'M2'}; %avg mastoids
> cfg.continuous = 'no';
> cfg.preproc.detrend = 'no';
> %Baseline correction
> cfg.preproc.demean = 'yes';
> cfg.prepoc.baselinewindow  = [-0.2 0];
> %Filtering
> cfg.preproc.lpfilter = 'yes';
> cfg.preproc.hpfilter = 'yes';
> cfg.preproc.lpfreq = 100;
> cfg.preproc.hpfreq = 1;
> data_process=ft_preprocessing(cfg);
>
> Can the error be associated with the fact that I am using
> non-continuous data?
>
> I am using BrainVision Format, that is, .seg, .vmrk and vhdr data.
>
> Thank you,
> Stay safe,
> Helena Pereira
>
>
>
>
> Schoffelen, J.M. (Jan Mathijs) <jan.schoffelen at donders.ru.nl> escreveu no
> dia terça, 2/06/2020 à(s) 09:28:
>
>> Hi Helena,
>>
>> ft_rejectvisual is not deprecated. As a matter of fact, there has been
>> some recent updates to this function, to make its behavior more robust.
>> Since these changes have passed our internal tests, the new version has
>> made it into the release version. Unfortunately, this seems to cause you
>> some problems. As of yet, it is not clear whether this now is a genuine
>> bug, or a feature of an inconsistency in your data, which only surfaces
>> now. In order to be able to confirm your problem, you’d need to give a bit
>> more detail about what you have been doing. Important details to include
>> are some characteristics of the data, and a specification of the cfg that
>> you used as an input to ft_rejectvisual. Also, you couuld try and diagnose
>> the problem a bit more yourself by using the matlab debugger, which you can
>> use to investigate why the variable info.cfg.ylim seems to have an
>> unexpected number of elements (as the error message suggests).
>>
>>
>> Best wishes,
>>
>> Jan-Mathijs
>>
>>
>>
>> On 1 Jun 2020, at 20:51, Helena Pereira <hri.pereira at campus.fct.unl.pt>
>> wrote:
>>
>> Dear all,
>>
>> I am analysing data from EEG subjects. To remove artifacts, I used a code
>> that was computed using the ft_rejectvisual function of 20191019 fieldtrip
>> version. However, when the fieldtrip was uptaded to the 20200521, this
>> error appeared:
>>
>> Index exceeds the number of array elements (1).
>>
>> Error in rejectvisual_trial>redraw (line 274)
>>   ymax = info.cfg.ylim(2);
>>
>> Error in rejectvisual_trial (line 96)
>>   redraw(h);
>>
>> Error in ft_rejectvisual (line 230)
>>     [chansel, trlsel, cfg] = rejectvisual_trial(cfg,
>>     tmpdata);
>>
>> Is ft_rejectvisual function deprecated? How can I solve this error? The
>> version 20191019 is no longer available at the FTP server, but I know it
>> works well because I tested the code with that old version.
>>
>> Thanks in advance,
>> Best regards,
>> Helena Pereira
>>
>> _______________________________________________
>> fieldtrip mailing list
>> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>> https://doi.org/10.1371/journal.pcbi.1002202
>>
>>
>> _______________________________________________
>> fieldtrip mailing list
>> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>> https://doi.org/10.1371/journal.pcbi.1002202
>>
> _______________________________________________
> fieldtrip mailing list
> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
> https://doi.org/10.1371/journal.pcbi.1002202
>
>
> _______________________________________________
> fieldtrip mailing list
> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
> https://doi.org/10.1371/journal.pcbi.1002202
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200602/6fdedea0/attachment.htm>


More information about the fieldtrip mailing list