[FieldTrip] af2d

Dr. Stephan Frisch stephan.frisch at uni-ulm.de
Sun Feb 12 08:31:56 CET 2023


Guten Tag, 
Hi, 

Ich bin vom 05.02.2023 bis 10.02.2023 nicht im Büro und kann die Emails nur sehr unregelmäßig lesen und beantworten. Die Emails werden auch nicht weitergeleitet.  

I am out of the office from 05.02.2023 to 10.02.2023 and can only read and answer emails very sporadically. The emails are also not being forwarded.  

Viele Grüße / Best regards
Stephan Frisch


Am 07.02.2023 um 00:32 schrieb Ruoyi Cao via fieldtrip <fieldtrip at science.ru.nl>:

> Hi Jan-Mathijs: 
> Thank you so much for your fast response ! This is exactly the problem. There is one empty event in the bdf file. 
> 
> Best wishes,
> Ruoyi
> 
> 
> On Mon, Feb 6, 2023 at 10:35 PM Schoffelen, J.M. (Jan Mathijs) via fieldtrip <fieldtrip at science.ru.nl> wrote:
> Hi Ruoyi,
> 
> I don’t know about the specific file format you are working with, but - occasionally in some file formats - some events may have an empty value. As a consequence, the code that you used in your selfmade function may not have been absolutely robust. Specifically, the three lines:
> 
> value2 = {event.value}.';
> value=cell2mat(value2)
> sample = [event.sample].’
> 
> lead to two vectors (value and sample) that are assumed to relate to each other one-by-one, meaning that element -i- in one of the vectors corresponds to element -i- in the other vector.
> I would first check if this is really the case in your data. If not, I think that this explains the discrepancy you report, and would be indicative that you may need to change your own code a bit, in order to obtain the expected behavior. You could quickly check this: a = {1 2 [] 3}; b = cell2mat(a); As you will see, ‘a’ has 4 elements, ‘b’ only 3...
> 
> Best wishes,
> Jan-Mathijs
> 
> 
> 
> On 6 Feb 2023, at 20:33, Ruoyi Cao via fieldtrip <fieldtrip at science.ru.nl> wrote:
> 
> Hello FieldTrip community,
> I segmented data by triggers after artifact correction on continuous data , where all deleted parts were replaced with NaN. Then this data mat was segmented with ft_trialfun_general and with a self made function as follows. The NaN value was later deleted after the output was time locked to the trigger.
> 
> I am very confused as the outcome from my self-made function was surprisingly not the same. Could anyone kindly give me some ideas for why this is the case and how to fix the problem? 
> 
> 
> Thank you so much 
> Ruoyi.
> 
> The two methods are as follows: 
> Standard code: 
> 
> 1: 
> cfg = [];
> cfg.dataset             = M
> % cfg.trialdef.pre    =  2.5;
> % cfg.trialdef.post   =  1.5;
> cfg.trialdef.eventtype      = 'STATUS';
> cfg.trialdef.prestim        = 2.5; % in seconds
> cfg.trialdef.poststim       = 1.5; % in seconds
> cfg.trialdef.eventvalue = 101;
> cfg_B1 = ft_definetrial(cfg);
> segbinding1= ft_redefinetrial(cfg_B1,data); 
> Reference: 
> Preprocessing - Reading continuous EEG and MEG data - FieldTrip toolbox
> 
> 2:  Self made function according to following instruction : 
> 
> function [trl, event] =location1(cfg);
> hdr   = ft_read_header(cfg.dataset);
> event = ft_read_event(cfg.dataset);
> % search for "trigger" events
> % value  = [event(find(strcmp('trigger', {event.type}))).value]';
> value2 = {event.value}.';
> value=cell2mat(value2)
> % sample = [event(find(strcmp('trigger', {event.type}))).sample]';
> sample = [event.sample].'
> % determine the number of samples before and after the trigger
> pretrig  = -round(cfg.trialdef.pre  * hdr.Fs);
> posttrig =  round(cfg.trialdef.post * hdr.Fs);
> % for each trigger except the last one
> trl = [];
> for j = 1:(length(value)-3)
>            trg1 = value(j); 
> if (trg1==101);
> trlbegin = sample(j) + pretrig;
> trlend   = sample(j) + posttrig;
> offset   = pretrig;
> newtrl   = [trlbegin trlend  offset ];;
>  trl      = [trl; newtrl]   
> end
> end
> 
> This function was run with : 
> cfg = [];
> cfg.dataset             = M
> cfg.trialdef.pre    =  2.5;
> cfg.trialdef.post   =  1.5;
> cfg.trialfun = 'location1';
> cfg_B1 = ft_definetrial(cfg);
> segbinding1= ft_redefinetrial(cfg_B1,data);
> References 
> Making your own trialfun for conditional trial definition - FieldTrip toolbox
> 
> The following excels shows two different trial definitions given by these two methods. The highlighted value is the differences between the beginning of each segment for each detected trial between two methods. 
> 
> <image.png>
> _______________________________________________
> fieldtrip mailing list
> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
> https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!_MVGSW6yRgkWvGt4xy4cmB_vlZyD-pBdlbVepuQMeFvwrOtYJgIGHAAo0UbHZSnMQFmpY44JpbC233m34wdGVGr04n82eQoxcxg4aA$ 
> 
> _______________________________________________
> fieldtrip mailing list
> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
> https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!8SCcS8FlnYiPu9lRawM9p2yQzQ3ZfW9p7RXL6-iVu0Mc7zMEq-o81moGryXuLenJyFYachVb-8-LYfmIlDM1uncJ1JkLlf5deA$ 
> _______________________________________________
> fieldtrip mailing list
> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
> https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!8SCcS8FlnYiPu9lRawM9p2yQzQ3ZfW9p7RXL6-iVu0Mc7zMEq-o81moGryXuLenJyFYachVb-8-LYfmIlDM1uncJ1JkLlf5deA$ 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/enriched
Size: 9060 bytes
Desc: not available
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20230212/25b2a246/attachment.bin>


More information about the fieldtrip mailing list