LIMO-EEG-Toolbox / limo_tools

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

limo_batch - Invalid file identifier error #66

Closed amisepa closed 3 years ago

amisepa commented 3 years ago

Hi,

I have 2 groups, 3 conditions, and have done the following steps: 1) 1st level OLS ERP to get the LIMO.txt file 2) limo_batch > contrast only > selected LIMO.txt file > selected contrast.mat file It run successfully for ~1h and then I got this error: image

I have these files in the directory: image

Thanks in advance! Cedric

amisepa commented 3 years ago

@CPernet I think the problem might come from line 448 where the filename has a number for each subject with a space between them, probably preventing fopen from working in cell2csv line 71 (fopen returns -1).

[LIMO_files.LIMO filesep 'con' num2str(con_num) 'files' glm_name '.txt'] ans = 'my_path\derivatives3\LIMO_derivatives3\con1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81_files_design1_GLM_Channels_Time_OLS.txt'

CPernet commented 3 years ago

looks like cell2csv did not recognize he con number 1 - note this means all your con files have been generated, but no txt file (so you can make one by hand if you don;t want to recompute) 2 - this should be solved in https://github.com/LIMO-EEG-Toolbox/limo_tools/blob/HotFixes/limo_batch.m (the contrast number to use could on occasion not be indexed properly)

amisepa commented 3 years ago

Thanks!

I think I got it to work but I end up with only 1 only con file and all subjects have con_1.mat. image image Shouldn't I have one con text file for each group? e.g. 'con1_files_design1_GLM_Channels_Time_OLS.txt' and 'con2_files_design1_GLM_Channels_Time_OLS.txt'

Just to check, I have 2 groups and 3 conditions and my contrast is a simple .mat file with [1 -1 0]. Is this ok or does it need a row for each subject (i.e. 81 rows with [1 -1 0])? Or should it have rows with [1 -1 0] for subjects from group 1 and rows with [-1 1 0] for subjects from group 2?

And for 2nd level analysis I do: Repeated measures ANOVA > full scalp > 2 independent grps > 3 repeated factor level > select the con file --> here it needs 2 con files but I have just one

Cedric

CPernet commented 3 years ago

yes and no -- if groups are defined in STUDY , you should get 'Gp1_con1_files_design1_GLM_Channels_Time_OLS.txt' and 'Gp2_con1_files_design1_GLM_Channels_Time_OLS.txt' -- now these are all con1 because you entered only 1 contrast [1 -1 0]

a contrast is a linear combination of the columns of the design matrix with 3 conditions you can for instance do [1 -1 0 0] A>B [0 1 -1 0] B>C [0.5 0.5 -1 0] ((A+B)/2 > C)

you can run several contrasts by writing them as a matrix [1 -1 0 0 ; 0 1 -1 0 ; 0.5 0.5 -1 0] ; note I add the 0 for the constant term here (3 conditions but 4 columns)

amisepa commented 3 years ago

Ok thank you.

I was doing these contrasts with your contrast manager in Results, but only after running ANOVA with one group as I don't have the 2 gp_con1_files...txt for some reason. Is it a different type of analysis to run limo_batch with these contrasts instead of later in Results?

So I still need to figure out why I don't have both groups. In the Study design, I have the conditions and groups separately as categorical variables (for the same design). Do they need to be all combined into 1 variable?

amisepa commented 3 years ago

I have tried using the contrast [1 -1 0 0 ; 0 1 -1 0 ; 1 0 -1 0 ; 0.5 -1 0.5 0] following your method and have now 4 con files, but still no independent groups.

Study design variables: image

Limo 1st level variables: image

Am I missing something?

CPernet commented 3 years ago

mmh it should split see https://github.com/LIMO-EEG-Toolbox/limo_tools/blob/HotFixes/limo_batch.m#L489 split of LIMO files, Betas files? what is length(STUDY.group)? = 2 right

amisepa commented 3 years ago

Mmmh weird when I open limo_batch in Matlab it only has 470 lines... I recloned it and it's still the same.

No... length(STUDY.group) = 0... it's empty :( I used bids_export to convert my data to BIDS to then import in STUDY, and the group is defined in both the pInfo variable (participants.tsv) and in the data variable.

I have tried to redefine it with different formats but I keep getting this error: image

CPernet commented 3 years ago

well maybe @arnodelorme can check why your groups aren't there automatically - obviously if STUDY doesn't have groups LIMO won't make them -- you can still check using the GUI STUDY-->edit

as for limo_batch make sure you use the HotFixes branch https://github.com/LIMO-EEG-Toolbox/limo_tools/tree/HotFixes (for instance if you use git command or github desktop after cloning you need to checkout the HotFixes - otherwise you are in master)

amisepa commented 3 years ago

@arnodelorme it is in STUDY variables for the design from the .tsv file but not recognized in STUDY for each participant: image

I have tried different formats but I can;t find what it is supposed to be to work. It;s not in your bids_export_examples: https://github.com/sccn/bids-matlab-tools/blob/master/bids_export_example.m

Ok @CPernet thanks I will get on the branch!

amisepa commented 3 years ago

Ok @CPernet I edited in STUDY>edit manually for all subjects and am on HotFixes branch, it works now. :)

The problem comes from bids export/import.

@arnodelorme the group info is correct in STUDY>design variables from the .tsv file but not recognized in STUDY>edit for each participant: image

I have tried different formats when converting to bids format with bids_export but I can't find what it needs to work. You don't have groups in your bids_export_examples.

CPernet commented 3 years ago

yep i knew it :-)