[BUG] LIMO design matrix messup at lines 156-166 function limo_glm_handling.m
Closed this issue · 13 comments
Describe the bug
A clear and concise description of what the bug is.
Limo crashes with vague message : "issue with GLM design" upon estimating 1st level parameters. Upon checking the logs I came across the limo_glm_handling.m at line 164 where concatenation fails. I then reran it and tried to figure out what was going in.
There are some dark magicks happening in lines 156-166. A tmp variable is made, and then 1:2:end is used and 2:2:end (L 157 and 158). This assumes that LIMO.model.model_df is a cell array of cell arrays of dimenions 2X1. This works well.
Then at lines 162-163 the same is attempted, but now for LIMO.model.conditions_df, which is also assumed to be the same shape. In my case, they are not the same shape as model_df, but they are 1X2. The 'tmp' variable then becomes a matrix instead of a vector, and the concatenation on L164 fails, because it only can find 32 channels instead of my original 63.
I can fix this issue by forcing it to be a Nx1 vector with: tmp=tmp(:) , adding that at the end of lines 156 and 162, of function limi_glm_handling.m. Not sure if that is intended, but I don't see how it could otherwise work.
I have a feeling that this code could be made more robust by using a reshape function with the number of channels, rather than using 1:2:end, 1 and 2:2:end,: on a temporary variable that is then deleted?
I'm sorry this is not a full bug report as expected, but hopefully it illustrates the issue.
Many thanks for making the toolbox
Johan
I get this when I estimate 1st level Betas, with having 2 factors in my STUDY.design, and have clicked the 'interaction model for categorical Indep. var.', to make that factorial GLM into an interaction model at first level (so I can estimate the interactions at 2nd level). If I don't click the 'interaction model' checkbox, LIMO estimates beta's with no error (but I have the wrong model at 1st level).
Hi Johan,
-
the quick and happy answer to your trouble is that to estimate the interactions at 2nd level, you must NOT compute it subject wise ; just think when you average reaction times to 4 conditions A1 A2 B1 B2 and you enter that into your ANOVA, same here you want Betas1,2,3,4 per subject that you put into an ANOVA at the group level (alternatively you can think, you split the variance into different buckets per subject, factor 1, factor 2, interaction -- so at the group level you can't look at this anymore, but if you say conditions 1,2,3,4 than at the group level you can say pull 12 vs 34, or 13 vs 24)
-
the actual bug I see why LIMO.model.conditions_df is now a matrix ; to be fair we have been testing interaction models lately since it is very rarely used (see the quick and happy above) ; let me fix and push this -- will retag here for the sake of having record of it
ok not as straightforward as I thought - I just computed a full factorial on 1 subject and no bug
I did push a small patch into master to record all df, but I don't think it will solve your problem - try and if still bugs, maybe you can share 1 subject with me (with the imported data and LIMO.mat that failed) I should be able to get on from there - thx
What happened for me was that I have a STUDY in which I specify 1 factor (nback), using EEG.event.nback=1 (or 2), and then specify below that (in the STUDY create design GUI) another factor (RF), which is ON or OFF, and this I coded into EEG.event.rf being (also) 1 or 2. When I estimated in the standard way, the first lvl GLMs were factorial designs, so: [1 0 1 0; 1 0 0 1; 0 1 1 0; 0 1 0 1]; But, I wanted not to have the factorial design, but interaction design; so as to estimate interactions properly at 2nd level. So I want the design at 1st level to be: [1 0 0 0; 0 1 0 0; 0 0 1 0; 0 0 0 1]. I could click the first checkmark in the LIMO GUI to convert the factorial into the interaction design, but then the error occurred.
I tried it again with the recent eeglab version and the most recent limo_tools, and now the popup error message changes. "All of the input arguments must be of the same size and shape. Previous Inputs had size 10 in dimension 2. Input #3 has size 1. This is not a bug (Error occurred in function limo_check_ppool() at line 11."
The bug might be related to how EEGlab.event is converted into STUDY design and how LIMO pick up from that? I can share a subject (55M). How should I send it over?
'I could click the first checkmark in the LIMO GUI to convert the factorial into the interaction design, but then the error occurred.' this tick box does not exist --- what it says is to make a full factorial, ie not what you want
I see, EEG.event.nback=1 or 2, EEG.event.rf = 1 or 2, and you want to combine them.
The STUDY interface allows to combine events within EEG.event types but not across -- maybe @arnodelorme as a quick fix to do that?
I can still look at why LIMO bugs, as indicated above I don't want the .set --> 'share 1 subject with me (with the imported data and LIMO.mat that failed)' that is just the LIMO folder (Yr.mat and LIMO.mat)
Hi Cyril, the fix you did worked, it doesn't hang anymore, so the issue is resolved. Many thanks!
To deal with the events I just rerun the preprocessing event-labeling part so I have 4 different EEG.event.type (s): A1, A2, B1 and B2. Estimating the LIMO parameters on the type then gives a good 1st level LIMO.design.X (i.e. looking diagonally across the reshuffled trials).
Am I right into believing that the full factorial design at 1st level - with the 9 columns in my case, is pretty much only used if you are looking/trying to infer from ERP/spectra of one single subject (for example across many sessions /factors), and not try to average across subjects?
yes, the idea with full factorial is to add bootstrap and test, per subject, when this happens. Then you can have a group statistics on the percentage of subjects showing an effect (binomial test) and maybe try to get more out of neural dynamics (mean and var of onsets, although onsets are noticeably hard to determine). For the 'standard' analysis, you are good to go with a repeated measure ANOVA 2*2
to do a full factorial design with Bootstrap use the LIMO import - not STUDY
- each column of the categorical variable file to import code your factor (for instance 1st column with values 1,2,3 means 3 levels, 2nd column, values 1,2 means 2 levels)
- obviously, raws are trials
LIMO creates the factor and the interaction term -- you can choose to bootstrap.
Alternatively -- you can use STUDY to create all conditions and use contrasts to estimate factors' effects ; the variance partition of the model is not correct and the stat test should still be ok. Then use some dark magic :-) set LIMO.design.bootstrap to say 800, LIMO.design.status to 'to do' save and call limo_glm(4, path to LIMO file)