treder / MVPA-Light

Matlab toolbox for classification and regression of multi-dimensional data
MIT License
70 stars 35 forks source link

Error in mv_statistics/select_metric #40

Closed bekemeier closed 1 year ago

bekemeier commented 1 year ago

Dear Matthias,

I have generated a results matrix using ft_timelockstatistics with mvpa as method for three participants. Here is the code: cfg = [] ;
cfg.method = 'mvpa'; cfg.features = 'chan'; cfg.mvpa.classifier = 'lda'; cfg.mvpa.metric = {'acc' 'auc' 'f1' 'precision' 'recall', 'dval'}; cfg.mvpa.k = 10; cfg.mvpa.repeat = 5; cfg.design = [ones(nAdjM,1); 2*ones(nNounM,1)];

statM = ft_timelockstatistics(cfg, AdjM, NounM);

resultsM{subject} = statM;

It contains multiple matrices (as in your stats tutorial). I have attached the results file. I am now trying to run second level stats on these three classification results using the example from the tutorial:

cfg = []; cfg.metric = 'acc'; cfg.test = 'permutation'; cfg.correctm = 'cluster';
cfg.n_permutations = 1000; cfg.clusterstatistic = 'maxsum'; cfg.alpha = 0.05; cfg.design = 'within'; cfg.statistic = 'wilcoxon'; cfg.null = 0.5; cfg.clustercritval = 1.96; stat_level2 = mv_statistics(cfg, resultsGenC);

My data structure doesn't seem to meet the requirements for mv_statistics. I keep getting an error message 'Unrecognized field name "metric"': Error in mv_statistics/select_metric (line 522) elseif ischar(res.metric) && ~strcmp(res.metric, cfg.metric)

Error in mv_statistics (line 365) result{n} = select_metric(result{n});

Error in untitled (line 93) stat_level2 = mv_statistics(cfg_stat, resultsM);

Can you maybe help me with this issue or point to the possible answer?

Best,

Natalia resultsM.zip

bekemeier commented 1 year ago

Hi Matthias,

I actually solved the problem already. Fieldtrip writes the info about the metric, perf, etc. into the cell "mvpa" within the results structure. So I just adapted your original code to call onto this particular cell.

treder commented 1 year ago

Hi Natalia, glad you managed to solve it yourself. Generally speaking, FieldTrip output is not directly compatible with MVPA-Light. Basically FieldTrip functions should work directly with FieldTrip output (even if it calls MVPA-Light internally), and MVPA-Light functions should work directly with MVPA-Light output, but if you cross things it might not work unfortunately.