[FieldTrip] Permutation test with cluster based correction on a single sensor with time frequency data

Anne Guérin anne.guerin at gipsa-lab.grenoble-inp.fr
Sat Dec 21 06:43:22 CET 2024


Hi Jan-Mathijs,

Yes, indeed, data have been generated with Brainstorm and additional 
“in-house” programs. I use fieldtrip directly for permutation statistics.

  Best regards.

Anne

Le 20/12/2024 à 19:46, Schoffelen, J.M. (Jan Mathijs) via fieldtrip a 
écrit :
> Hi Anne,
>
> It seems as if you have solved it yourself indeed. I did not notice 
> that the data structure that you pasted in an earlier e-mail indeed 
> was fieldtrip-incompatible, with an incorrect ‘dimord’. I don’t know 
> where this data structure came from, but if it was created using 
> ‘purely’ fieldtrip functions, please do point us to where in the code 
> this happened. Otherwise, I will file this as a ‘user error’, thanks 
> for letting us know, and glad that it now works for you.
>
> Best wishes,
> Jan-Mathijs
>
>> On 19 Dec 2024, at 16:53, Anne Guérin via fieldtrip 
>> <fieldtrip at science.ru.nl> wrote:
>>
>>
>> Le 19/12/2024 à 14:57, Schoffelen, J.M. (Jan Mathijs) via fieldtrip a 
>> écrit :
>>> Hi Anne,
>>>
>>> I don’t know what’s going on.
>>>
>>> Have you tried cfg.neighbours = {} (i.e. curly rather than square 
>>> brackets), and/or explicitly defined cfg.connectivity = []; ?
>>>
>>> Best wishes,
>>> Jan-Mathijs
>>>
>>> Hi Jan-Mathijs,
>>
>> When I try cfg.neighbours = {}, instead of [], a bug appears earlier at
>>
>> Unrecognized field name "label".
>>
>> Error in channelconnectivity (line 91)
>>       [seld] = match_str(chans, neighbours(chan).label);
>>
>> I solved it with cfg.chanel = {ROI}  in order to overlap the field 
>> .label of the data structure, and with cfg.neighbours = [];
>>
>> after this function (channelconnectivity) and go back to
>>
>> I have for the cfg structure and these 3 fields :
>>
>>               channel: {'V5_R'}
>>            neighbours: []
>>          connectivity: 0
>>
>> With cfg.neighbours={}; , in the function channelconnectivity, the 
>> bug appears at line 91
>>
>> line 90 for chan=1:length(neighbours)
>> line 91            [seld] = match_str(chans, neighbours(chan).label);
>>
>> in fact with cfg.neighbours={} , the variable 'neighbours' is a 
>> struct with no field, so length(neighbours)=1 , and the loop begins 
>> and it's bug.
>>
>> So I go back  cfg.chanel = {'V5_R'} and cfg.neighbours=[] 
>> (cfg.connectivity = [] hasno impact), I find the same bug again, at 
>> the function 'findcluster'.
>>
>> But, I think that the problem comes from the expected input data 
>> onoff of the function findcluster :
>>
>> onoff                  =  is a 3D boolean matrix with size N1xN2xN3
>>
>> three dimensions are expected for chan freq and time, but in my case 
>> there are only two dimensions freq and time. So I changed the indut 
>> data like this (for example for the first subject) :
>>
>> ftAllFiles{1}
>>
>> ans =
>>
>>   struct with fields:
>>
>>     dimord: 'chan_freq_time'
>>        avg: [1×29×401 double]
>>       time: [-0.2000 -0.1990 -0.1980 -0.1970 -0.1960 -0.1950 -0.1940 
>> -0.1930 -0.1920 -0.1910 -0.1900 -0.1890 -0.1880 -0.1870 -0.1860 … ]
>>       freq: [6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 
>> 26 27 28 29 30 31 32 33 34]
>>      label: {'V5_R'}
>>
>> with a first dimension as a scalar (only one chanel).
>>
>> It now seems to be working properly. but I must verify the results to 
>> be sure.
>>
>> The moral of the story is that you always have to define a “chan” 
>> dimension, even if there's only one chanel, and that it's not 
>> theoretically necessary to encode the data in this case.
>>
>> Thank you.
>>
>> Best regards.
>>
>> Anne
>>
>>>> On 19 Dec 2024, at 12:18, Anne Guérin via 
>>>> fieldtrip<fieldtrip at science.ru.nl>wrote:
>>>>
>>>> Hi,
>>>>
>>>> I would like to use the FT permutations test with cluster based 
>>>> correction on 2D data freq x time with a within subject design. 
>>>> Data are obtained after sources reconstruction and are for example 
>>>> related to a particular ROI (e.g. V5_R). The first dimension is a 
>>>> frequency dimension but not the oscillatory brain frequency. This 
>>>> dimension is linked to a temporal frequency of the input visual 
>>>> stimulus. the second dimension is time (sRate = 1kHz) and data are 
>>>> timelocked ERP for different values of this temporale frequency (by 
>>>> step of 1Hz). The data therefore has the same structure as if it 
>>>> had been obtained by time-frequency analysis on a particular electrode.
>>>>
>>>> For example, here's the data for one participant:
>>>> ftAllFiles{1}
>>>>
>>>> ans =
>>>>
>>>>   struct with fields:
>>>>
>>>>     dimord: 'freq_time'
>>>>        avg: [29×401 double]
>>>>       time: [-0.2000 -0.1990 -0.1980 -0.1970 -0.1960 -0.1950 
>>>> -0.1940 -0.1930 -0.1920 -0.1910 -0.1900 -0.1890 -0.1880 -0.1870 
>>>> -0.1860 … ]
>>>>       freq: [6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 
>>>> 25 26 27 28 29 30 31 32 33 34]
>>>>      label: {'V5_R'}
>>>> There are 29 participants for each conditions. ftAllFiles have 2x29 
>>>> cells, the first 29 correspond to the first condition and the last 
>>>> 29 to the second condition.
>>>>
>>>> Here is the configuration :
>>>>
>>>> >> statcfg
>>>>
>>>> statcfg =
>>>>
>>>>   struct with fields:
>>>>
>>>>            frequency: 'all'
>>>>            parameter: 'avg'
>>>>          avgoverfreq: 'no'
>>>>          avgoverchan: 'no'
>>>>              latency: 'all'
>>>>               method: 'montecarlo'
>>>>            statistic: 'ft_statfun_depsamplesT'
>>>>             correctm: 'cluster'
>>>>         clusteralpha: 0.0500
>>>>     clusterstatistic: 'maxsum'
>>>>            minnbchan: 0
>>>>                 tail: 1
>>>>          clustertail: 1
>>>>                alpha: 0.0500
>>>>     numrandomization: 100000
>>>>                 ivar: 1
>>>>                 uvar: 2
>>>>               design: [2×58 double]
>>>>              channel: 'all'
>>>>           neighbours: []
>>>>          avgovertime: 'no'
>>>>
>>>> When I run   ftStat = ft_freqstatistics(statcfg, ftAllFiles{:}); , 
>>>> the program stops at the step 'findcluster':
>>>>
>>>> posclusobs = findcluster(tmp, connmat, cfg.minnbchan);
>>>>
>>>> In fact tmp is 2D boolean table (29 frequency samples x 401 time 
>>>> samples), connmat is 4x4 matrix with 0 and cfg.minnbchan=0.  So bug 
>>>> withfindcluster. See below.
>>>>
>>>> When I plot tmp (image(tmp)), the result doesn't look ridiculous.
>>>>
>>>> How to have a good configuration of neighborhood for this 
>>>> single-sensor time-frequency permutation test ?
>>>>
>>>> Thank you for your help.
>>>>
>>>> Best regards.
>>>>
>>>> Anne
>>>>
>>>> ps :
>>>>
>>>>
>>>> >>     ftStat = ft_freqstatistics(statcfg, ftAllFiles{:});
>>>> the call to "ft_selectdata" took 0 seconds
>>>> using "ft_statistics_montecarlo" for the statistical testing
>>>> using "ft_statfun_depsamplesT" for the single-sample statistics
>>>> constructing randomized design
>>>> total number of measurements     = 58
>>>> total number of variables        = 2
>>>> number of independent variables  = 1
>>>> number of unit variables         = 1
>>>> number of within-cell variables  = 0
>>>> number of control variables      = 0
>>>> using a permutation resampling approach
>>>> repeated measurement in variable 2 over 29 levels
>>>> number of repeated measurements in each level is 2 2 2 2 2 2 2 2 2 
>>>> 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
>>>> the maximum number of unique permutations is 536870912
>>>> generated 100000 random permutations
>>>> computing a parametric threshold for clustering
>>>> computing statistic
>>>> estimated time per randomization is 0.00 seconds
>>>> computing statistic 100000 from 100000
>>>>
>>>> Error using findcluster
>>>> invalid dimension of spatdimneighbstructmat
>>>>
>>>> Error in clusterstat (line 214)
>>>>   posclusobs = findcluster(tmp, connmat, cfg.minnbchan);
>>>>
>>>> Error in ft_statistics_montecarlo (line 364)
>>>>   [stat, cfg] = clusterstat(cfg, statrand, statobs);
>>>>
>>>> Error in ft_freqstatistics (line 194)
>>>>   [stat, cfg] = statmethod(cfg, dat, design);
>>>>
>>>>
>>>>
>>>> -- 
>>>> Anne Guérin-Dugué
>>>> PR Emérite Université Grenoble Alpes (UGA)
>>>> GIPSA-lab / PSD / Equipe ViBS
>>>> Bureau B146
>>>> Site Ampère
>>>> 11 rue des Mathématiques
>>>> BP 46
>>>> F - 38042 GRENOBLE
>>>> tel : +33 (0)4 76 57 43 73
>>>> mel :anne.guerin at gipsa-lab.grenoble-inp.fr
>>>> _______________________________________________
>>>> fieldtrip mailing list
>>>> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmailman.science.ru.nl%2Fmailman%2Flistinfo%2Ffieldtrip&data=05%7C02%7Cfieldtrip%40science.ru.nl%7C893fd3880b204f0cb81008dd21826952%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638703566883055287%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C40000%7C%7C%7C&sdata=2aT0aGEPkll2lvw5AP8zi3g%2BLQTMfAZnwO86lmKOCCQ%3D&reserved=0 
>>>> <https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmailman.science.ru.nl%2Fmailman%2Flistinfo%2Ffieldtrip&data=05%7C02%7Cfieldtrip%40science.ru.nl%7C893fd3880b204f0cb81008dd21826952%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638703566883074482%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C40000%7C%7C%7C&sdata=QBsJfu5Pl4IWdV7ntm%2FaqDBD%2B8yvxnT8RfaMulE1ADc%3D&reserved=0>
>>>> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdoi.org%2F10.1371%2Fjournal.pcbi.1002202&data=05%7C02%7Cfieldtrip%40science.ru.nl%7C893fd3880b204f0cb81008dd21826952%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638703566883089661%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C40000%7C%7C%7C&sdata=IEMGAaaIqolI2BkygJHv2RrIBwhuG4rBO30yJvN3%2BdI%3D&reserved=0 
>>>> <https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdoi.org%2F10.1371%2Fjournal.pcbi.1002202&data=05%7C02%7Cfieldtrip%40science.ru.nl%7C893fd3880b204f0cb81008dd21826952%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638703566883102418%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C40000%7C%7C%7C&sdata=fI8IB2Fq6bTHWc60cJm6uoURWhM64rmPzJBmtyoghAA%3D&reserved=0>
>>>
>>>
>>> _______________________________________________
>>> fieldtrip mailing list
>>> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmailman.science.ru.nl%2Fmailman%2Flistinfo%2Ffieldtrip&data=05%7C02%7Cfieldtrip%40science.ru.nl%7C893fd3880b204f0cb81008dd21826952%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638703566883114560%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C40000%7C%7C%7C&sdata=VzNM4ubNkKyEo86S9EfHBMnExuzIzsBI6K7kkSkGPnI%3D&reserved=0
>>> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdoi.org%2F10.1371%2Fjournal.pcbi.1002202&data=05%7C02%7Cfieldtrip%40science.ru.nl%7C893fd3880b204f0cb81008dd21826952%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638703566883126589%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C40000%7C%7C%7C&sdata=1wvOg%2F43wWdrJttud88QhPBa9mkdHH0L9mIV4Upj6fw%3D&reserved=0
>> -- 
>> Anne Guérin-Dugué
>> PR Emérite Université Grenoble Alpes (UGA)
>> GIPSA-lab / PSD / Equipe ViBS
>> Bureau B146
>> Site Ampère
>> 11 rue des Mathématiques
>> BP 46
>> F - 38042 GRENOBLE
>> tel : +33 (0)4 76 57 43 73
>> mel :anne.guerin at gipsa-lab.grenoble-inp.fr
>> _______________________________________________
>> fieldtrip mailing list
>> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmailman.science.ru.nl%2Fmailman%2Flistinfo%2Ffieldtrip&data=05%7C02%7Cfieldtrip%40science.ru.nl%7C893fd3880b204f0cb81008dd21826952%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638703566883138292%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C40000%7C%7C%7C&sdata=SgTL30fEBKg8GGFnHrVdagzldoO72atswIdugE6vUtk%3D&reserved=0 
>> <https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmailman.science.ru.nl%2Fmailman%2Flistinfo%2Ffieldtrip&data=05%7C02%7Cfieldtrip%40science.ru.nl%7C893fd3880b204f0cb81008dd21826952%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638703566883149949%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C40000%7C%7C%7C&sdata=cKTKu9Wd%2FVvO3%2BrQ6juE67DKLW2GDoq%2BDGTmjQreAKA%3D&reserved=0>
>> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdoi.org%2F10.1371%2Fjournal.pcbi.1002202&data=05%7C02%7Cfieldtrip%40science.ru.nl%7C893fd3880b204f0cb81008dd21826952%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638703566883161817%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C40000%7C%7C%7C&sdata=shLdMikiDVu7jMAiZLw%2BH96FWU7r4iOMxkzOBz3FB98%3D&reserved=0 
>> <https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdoi.org%2F10.1371%2Fjournal.pcbi.1002202&data=05%7C02%7Cfieldtrip%40science.ru.nl%7C893fd3880b204f0cb81008dd21826952%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638703566883173491%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C40000%7C%7C%7C&sdata=m3iU5TsyTRCYEZOfpwiL6rHDvCvC7swzJxyXrn5gTuA%3D&reserved=0>
>
>
> _______________________________________________
> fieldtrip mailing list
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmailman.science.ru.nl%2Fmailman%2Flistinfo%2Ffieldtrip&data=05%7C02%7Cfieldtrip%40science.ru.nl%7C893fd3880b204f0cb81008dd21826952%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638703566883185316%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C40000%7C%7C%7C&sdata=TN%2F%2BaASwWaFw2hWrMy3zi5QyOxtnu9vTp8PcI9QdN7g%3D&reserved=0
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdoi.org%2F10.1371%2Fjournal.pcbi.1002202&data=05%7C02%7Cfieldtrip%40science.ru.nl%7C893fd3880b204f0cb81008dd21826952%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638703566883197074%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C40000%7C%7C%7C&sdata=NXVGYrcMWCHFcCCCeDDENfZ7zMll3YjpuS%2B5xKPQNsg%3D&reserved=0

-- 
Anne Guérin-Dugué
PR Emérite Université Grenoble Alpes (UGA)
GIPSA-lab / PSD / Equipe ViBS
Bureau B146
Site Ampère
11 rue des Mathématiques
BP 46
F - 38042 GRENOBLE
tel : +33 (0)4 76 57 43 73
mel :anne.guerin at gipsa-lab.grenoble-inp.fr
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20241221/5d704833/attachment.htm>


More information about the fieldtrip mailing list