[FieldTrip] Invisible data after ft_resampledata

Schoffelen, J.M. (Jan Mathijs) janmathijs.schoffelen at donders.ru.nl
Fri Oct 29 14:51:06 CEST 2021


hi Emilie,

Given the lack of responses so far, I think that nobody has encountered this before. I hope that you inspected your data for NaNs? This is the most likely cause of your problem. Also, your use case seems to be quite an exceptional one, since you seem to be reading the channels one at the time (and resample), and then concatenate afterwards, using ft_appenddata. ft_appenddata performs some checks on the sanity of the sampled time axis in order to determine how (and whether) the data can be appended. I suspect that in your case, the channels’ sampling might be slightly different from one channel to the next, which becomes numerically not tolerated once the effective sampling rate is reduced too much.

Possible solutions:
1)  only downsample after concatenation
2) impose a numerically identical time axis across channels, e.g. by including a statement datr{i}.time = datr{1}.time; within the for loop.

Best wishes,
Jan-Mathijs


On 29 Oct 2021, at 12:52, Emilie Caspar via fieldtrip <fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl>> wrote:

Dear Fieldtrippers,

Just a follow-up email to know if someone already got this problem of « Invisible trials » after downsampling and has an idea about how to solve the problem.

Kind regards,

Emilie

<Downsampling.001.jpeg>
---------------------------------------------
Emilie CASPAR
Associate Professor
Department of Experimental Psychology, Ghent University
office: Henri Dunantlaan, 2 - Floor 2, Room 94
lab’s website: https://moralsocialbrain.com/<https://urldefense.com/v3/__https://moralsocialbrain.com/__;!!HJOPV4FYYWzcc1jazlU!vIs6cDO9UI_eSxJ-ejSlr1oqs47g4UtnsVqQOLcRSfvkRYPZQz1BrYgADkAqrz-vRfTJ2oqAQY_tczI$>
personal website: https://emiliecaspar.home.blog/<https://urldefense.com/v3/__https://emiliecaspar.home.blog/__;!!HJOPV4FYYWzcc1jazlU!vIs6cDO9UI_eSxJ-ejSlr1oqs47g4UtnsVqQOLcRSfvkRYPZQz1BrYgADkAqrz-vRfTJ2oqAkCkgYUk$>

Université libre de Bruxelles (office & contact): DB10.138 / +32 2 650 32 95

Le 21 oct. 2021 à 14:40, Emilie Caspar via fieldtrip <fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl>> a écrit :

Dear fieldtrippers,

I am trying to downsample my EEG data, originally recorded at 2048 Hz.

I run the following code:

    cfg = [];
    %cfg.channel = {'A1', 'B2', 'A5', 'B5', 'B6', 'B8', 'A15', 'B20', 'B15', 'B16', 'A13', 'B18', 'A27', 'A28', 'A31', 'A29', 'A30', 'A32', 'B32', 'A21', 'A31', 'B26', 'EXG1', 'EXG2', 'EXG3', 'EXG4'}%'B15';
    cfg.dataset    = [ file.name];
    cfg.bpfilter    = 'yes';
    cfg.bpfreq      = bpfilterRange;
    cfg.bpfiltord   = bpfilterOrder;
    cfg.reref       = 'yes';
    cfg.refchannel  = chansRef;
    allData_preprosses = ft_preprocessing(cfg);

    cfg = [];
    cfg.resamplefs = 512;
    data_DS = ft_resampledata(cfg, allData_preprosses);


When I look at individual trials for artefact rejection, something very weird happens. Basically some trials become ‘invisible’ (sorry, I don’t find any other way to describe it), see figure attached. It seems that the data do exit though because when I average my visible trials to the invisible ones, it results in an invisible ERPs graph. But when I remove the trials containing the invisible data, an ERP graph does appear (please don’t pay attention to the quality of the data, this is just an example without any cleaning).

It seems there is a logic to the phenomenon, because if I downsample to 1024Hz (so half of my initial 2048 Hz), only half of my data becomes invisible and if I downsample to 512Hz, a 3/4 of the data becomes invisible.

I have tried the same with a different coding, with this time downsampling before filtering as follows, but the output is exactly the same.

display('downsample each channel')
         cfgp         = [];
                cfgp.dataset = [file.name];
                cfgr            = [];
                cfgr.resamplefs = 512;
                display('Resampling')
                for i= chansAll
                    cfgp.channel = i;
                    datp         = ft_preprocessing(cfgp);
                    datr{i}      = ft_resampledata(cfgr, datp);
                    clear datp
                end
                cfg = [];
                datall = ft_appenddata(cfg, datr{:});

    display('Filters')

    cfg = [];
    cfg.dataset    = [ file.name];
    cfg.bpfilter    = 'yes';
    cfg.bpfreq      = bpfilterRange;
    cfg.bpfiltord   = bpfilterOrder;
    cfg.reref       = 'yes';
    cfg.refchannel  = chansRef;
    data_DS = ft_preprocessing(cfg, datall);


Does anyone have any idea regarding this phenomenon?

Thank you in advance!

Best regards,

Emilie

<Downsampling.001.jpeg>
---------------------------------------------
Emilie CASPAR
Associate Professor
Department of Experimental Psychology, Ghent University
office: Henri Dunantlaan, 2 - Floor 2, Room 94
lab’s website: https://moralsocialbrain.com/<https://urldefense.com/v3/__https://eur01.safelinks.protection.outlook.com/?url=https*3A*2F*2Fmoralsocialbrain.com*2F&data=04*7C01*7Cemilie.caspar*40ulb.be*7C9eaa583fc9f2496f3d9708d99494a638*7C30a5145e75bd4212bb028ff9c0ea4ae9*7C0*7C0*7C637704188432821811*7CUnknown*7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0*3D*7C1000&sdata=X9emmQ51jam6Zr*2FzU1ntTu4F*2FAWsPVUwbwMPtsxLOhw*3D&reserved=0__;JSUlJSUlJSUlJSUlJSUlJSUlJQ!!HJOPV4FYYWzcc1jazlU!vIs6cDO9UI_eSxJ-ejSlr1oqs47g4UtnsVqQOLcRSfvkRYPZQz1BrYgADkAqrz-vRfTJ2oqAxN_xjhw$>
personal website: https://emiliecaspar.home.blog/<https://urldefense.com/v3/__https://eur01.safelinks.protection.outlook.com/?url=https*3A*2F*2Femiliecaspar.home.blog*2F&data=04*7C01*7Cemilie.caspar*40ulb.be*7C9eaa583fc9f2496f3d9708d99494a638*7C30a5145e75bd4212bb028ff9c0ea4ae9*7C0*7C0*7C637704188432831766*7CUnknown*7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0*3D*7C1000&sdata=RSBTcOxejkzdWKA9QOyJZKXBD*2F5bGyFC12*2FKCpKl8GY*3D&reserved=0__;JSUlJSUlJSUlJSUlJSUlJSUlJQ!!HJOPV4FYYWzcc1jazlU!vIs6cDO9UI_eSxJ-ejSlr1oqs47g4UtnsVqQOLcRSfvkRYPZQz1BrYgADkAqrz-vRfTJ2oqAk0r1eNs$>

Université libre de Bruxelles (office & contact): DB10.138 / +32 2 650 32 95

_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://doi.org/10.1371/journal.pcbi.1002202<https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!vIs6cDO9UI_eSxJ-ejSlr1oqs47g4UtnsVqQOLcRSfvkRYPZQz1BrYgADkAqrz-vRfTJ2oqA3PXLTtU$>

_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!vIs6cDO9UI_eSxJ-ejSlr1oqs47g4UtnsVqQOLcRSfvkRYPZQz1BrYgADkAqrz-vRfTJ2oqA3PXLTtU$

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20211029/114906a3/attachment.htm>


More information about the fieldtrip mailing list