LIMO-EEG-Toolbox / limo_tools

Hierarchical Linear Modelling for MEEG data
https://limo-eeg-toolbox.github.io/limo_meeg/
Other
59 stars 27 forks source link

limo_random_effect.m: wrong loading of expected_chanlocs #51

Closed LucaLaFisca closed 3 years ago

LucaLaFisca commented 3 years ago

line 304:

test = load([chan_path chan_file]);
if isfield(test,'expected_chanlocs')
    test = test.expected_chanlocs;
end

expected_chanlocs structure is composed of 2 fields: "expected_chanlocs" and "channeighbstructmat". In the current version of the code, the variable "test" is the parent expected_chanlocs structure, but we want it to be the field itself (i.e. "expected_chanlocs.expected_chanlocs").

Solution:

test = load([chan_path chan_file]);
test = struct2cell(test);
test = test{1};
if isfield(test,'expected_chanlocs')
    test = test.expected_chanlocs;
end
CPernet commented 3 years ago

we can use test = test.(cell2mat(fieldnames(test)))