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_split_continuous.m: deal with NaNs in continous variables #52

Closed LucaLaFisca closed 3 years ago

LucaLaFisca commented 3 years ago

line 73: tmp = zscore(CONT(CAT==cat_index(n)));

if CONT contains NaNs, zscore function returns an vector of NaNs. To deal with this case, I propose:

tmp = CONT(CAT==cat_index(n));
if ~any(isnan(tmp)) %if not any NaN in the vector
    tmp = zscore(tmp);
else
    mu = nanmean(tmp);
    sigma = nanstd(tmp);
    tmp = (tmp-mu)./sigma;
end
CPernet commented 3 years ago

ok merge