[FieldTrip] ft_timelockstatistics design matrix
Schoffelen, J.M. (Jan Mathijs)
janmathijs.schoffelen at donders.ru.nl
Sun Jun 26 19:24:47 CEST 2022
Hi Jaewon,
The error that you posted earlier suggests indeed that your data does not match the design matrix.
If HH_timelock.trial (etc.) are not of size nSubjsxNchanxNtime FieldTrip does not have a clue of how to link the data to the design. It seems as if:
1) HH_timelock etc each only have a single observation, while it is expected that there are multiple subjects represented there, i.e. the first dimension in the HH_timelock.trial field should be nSubjs, and not 1
and
2) The nSubjs variable does not match this. You haven’t specified how many subjects you have (and in fact the exact number is irrelevant), but the design matrix in your case should be a 2x (nSubjsx4) matrix.
Good luck
Jan-Mathijs
On 25 Jun 2022, at 11:17, 오재원 via fieldtrip <fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl>> wrote:
Hello,
I have just check the shape of the struct but it does not look like what you sent to me..
It looks like this:
[X]
I think I have to look into how to form the correct data struct first.
Thank you for your help and have a nice day :)
Best,
Jaewon
--------- 원본 메일 ---------
보낸사람 : "Elif Tülay via fieldtrip" <fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl>>
받는사람 : FieldTrip discussion list <fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl>>
참조 : "Elif Tülay" <e.eliftulay at gmail.com<mailto:e.eliftulay at gmail.com>>
받은날짜 : 2022-06-25 (토) 04:13:06
제목 : Re: [FieldTrip] ft_timelockstatistics design matrix
Dear Jaewon,
I just want to ask in order to be sure. For example HH_timelock variable contains all the participants like the attached format. Each struct contains FieldTrip output fields for each participants.Then you can use HH_timelock{:}. If your dataset is not in this format, maybe you can try this way once more.
On Fri, Jun 24, 2022 at 1:27 PM "오재원" via fieldtrip <fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl>> wrote:
Dear Julian,
Thank you for the response. Yes, I have tried adding {:} after each structure but Matlab said {:} cannot be attached to 'structure'.
So I tried altering the structures to cell arrays and then adding {:} to the cell arrays as the following codes:
%% permutation test statistical analysis
HH_timelock = struct2cell(HH_timelock);
HN_timelock = struct2cell(HN_timelock);
LH_timelock = struct2cell(LH_timelock);
LN_timelock = struct2cell(LN_timelock);
[stat] = ft_timelockstatistics(cfg, HH_timelock{:}, HN_timelock{:}, LH_timelock{:}, LN_timelock{:});
But it did not work.
Error: matlab.internal.doc.updateConnectorDocroot (Line 3)
options = weboptions('RequestMethod','post', ...
Warning: Your path is set up incorrectly. You probably used addpath(genpath('path_to_fieldtrip')), this can lead to
unexpected behavior. See
http://www.fieldtriptoolbox.org/faq/should_i_add_fieldtrip_with_all_subdirectories_to_my_matlab_path<https://urldefense.com/v3/__http://www.fieldtriptoolbox.org/faq/should_i_add_fieldtrip_with_all_subdirectories_to_my_matlab_path__;!!HJOPV4FYYWzcc1jazlU!-5oxZvt5bELdM4fGuG08Paw8YCINrdUPywabMYh62UEhuzGtr_HDv9f9cHOCKsi5AJamP-h2BFXvG73kO8Z1VMZcyTEq5l2cshK8iw$>
Error: ft_checkdata (538번 라인)
This function requires timelock data as input, see ft_datatype_timelock.
Error: ft_timelockstatistics (87번 라인)
varargin{i} = ft_checkdata(varargin{i}, 'datatype', 'timelock', 'feedback', 'no');
I am wondering what I can do more at this point.
Best,
Jaewon
--------- 원본 메일 ---------
보낸사람 : Julian Keil via fieldtrip <fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl>>
받는사람 : FieldTrip discussion list <fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl>>
참조 : Julian Keil <julian.keil at gmail.com<mailto:julian.keil at gmail.com>>
받은날짜 : 2022-06-24 (금) 17:27:30
제목 : Re: [FieldTrip] ft_timelockstatistics design matrix
Dear Jaewon,
are "HH_timelock, HN_timelock, LH_timelock, LN_timelock“ your data structures containing the single participants?
Have you tried adding {:} after the structures (e.g., HH_timelock{:}, HN_timelock{:}, LH_timelock{:}, LN_timelock{:})?
Are the same numbers of participants in all structures?
Good luck,
Julian
Am 24.06.2022 um 09:33 schrieb 오재원 via fieldtrip <fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl>>:
Hello,
I was trying cluster-based permutation using ft_timlockstatistics, but I got an error regarding design matrix.
The code I used is as following:
%% Permutation test
[ftver, ftpath] = ft_version;
cd(fullfile(ftpath, 'template', 'electrode'));
elec = ft_read_sens('standard_1020.elc');
% there are some of which the orientation cannot be determined (T3, T4, T5, T6)
ft_plot_sens(elec, 'label', 'yes', 'elecshape', 'disc', 'elecsize', 10, 'facecolor', [0.8 0.8 1.0])
% give it a stronger 3D appearance
camlight headlight
cfg = [];
cfg.elec = elec;
cfg.channel = {'Fp1', 'Fpz', 'Fp2', 'F7', 'F3', 'Fz', 'F4', 'F8', 'T7', 'C3', 'Cz', 'C4', 'T8', 'P7', 'P3', 'Pz', 'P4', 'P8', 'O1', 'Oz', 'O2'};
cfg.method = 'distance';
cfg.feedback = 'yes';
cfg.neighbourdist = 100;
neighbours = ft_prepare_neighbours(cfg);
design = [1:nSubjs 1:nSubjs 1:nSubjs 1:nSubjs; ones(1,nSubjs) ones(1,nSubjs)*2 ones(1,nSubjs)*3 ones(1,nSubjs)*4];
cfg = [];
cfg.channel = {'EEG'};
cfg.latency = [0 0.6];
cfg.method = 'ft_statistics_montecarlo';
cfg.clusterthreshold = 'nonparametric_common';
cfg.neighbours = neighbours;
cfg.statistic = 'ft_statfun_depsamplesFmultivariate';
cfg.correctm = 'cluster';
cfg.clusteralpha = 0.05;
cfg.clusterstatistic = 'maxsum';
cfg.minnbchan = 2;
cfg.tail = 0;
cfg.clustertail = 0;
cfg.alpha = 0.025;
cfg.numrandomization = 500;
cfg.design = design;
cfg.uvar = 1;
cfg.ivar = 2;
%% permutation test statistical analysis
[stat] = ft_timelockstatistics(cfg, HH_timelock, HN_timelock, LH_timelock, LN_timelock);
And the error message :
ft_timelockstatistics (172번 라인)
the length of the design matrix (2) does not match the number of observations in the data (4)
I could not find any problem in my code and I followed the way the fieldtrip tutorial instructed. I have four conditions and I put four repetitions of 1:nSubjs in the unit variable (cfg.uvar) and nSubjs number of ones, twos, threes, and fours each in the independent variable (cfg.ivar). It would be so grateful if you can tell me how to solve this problem. Best, Jaewon
_______________________________________________
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!-5oxZvt5bELdM4fGuG08Paw8YCINrdUPywabMYh62UEhuzGtr_HDv9f9cHOCKsi5AJamP-h2BFXvG73kO8Z1VMZcyTEq5l3Hb4uNYw$>
_______________________________________________
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!-5oxZvt5bELdM4fGuG08Paw8YCINrdUPywabMYh62UEhuzGtr_HDv9f9cHOCKsi5AJamP-h2BFXvG73kO8Z1VMZcyTEq5l3Hb4uNYw$>
_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!-5oxZvt5bELdM4fGuG08Paw8YCINrdUPywabMYh62UEhuzGtr_HDv9f9cHOCKsi5AJamP-h2BFXvG73kO8Z1VMZcyTEq5l3Hb4uNYw$
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20220626/fb0227ec/attachment.htm>
More information about the fieldtrip
mailing list