3DLME suddenly wouldn't recognize variable in model, problem with R library ? (3dLMEr never worked)

AFNI version info (afni -ver):

Precompiled binary linux_ubuntu_16_64: Jan 6 2023 (Version AFNI_23.0.00 'Commodus')
ubuntu : Ubuntu 22.04.4 LTS
R versions : R version 4.4.0 (2024-04-24) in use in Rstudio
I added a line in my tcsh script with the LME functions and got the same version output
R -e 'R.version' -----> R version 4.4.0 (2024-04-24)
I have 5 different R libraries though (do you know if AFNI installs its own ?)

Dear folks,

I have had some great difficulties to regress my data with 3dLME and 3dLMEr.

I have a data set of 26 subjects, each having three measures (from 3dDeconvolve) linked to the task.

Very simple data set indeed. I want the unique effect to be random, so I tried to use 3dLMEr, but never managed to make it work.
The weirdest part is that I managed to make 3dLME work with the same dataset and model, but never with 3dLMEr....
Other strange thing, how come when I put 'condition' as variable, my results from the model only has 2 sub-bricks (intercept) ? What do we need to put as option to output the coefficients and p-values (t-stats or whatever) of my condition ? I want more results !! :slight_smile:

Code I used

3dLMEr -overwrite -prefix BOLD_regression                              \
    -mask $mask                                             \
    -resid errts_BOLD_regression  \
    -model "1+entropy+(1|Subj)"                        \
    -qVars "condition"                                        \
    -dataTable @$Home/GLM_model.1D

3dLME -overwrite -prefix BOLD_regression                              \
    -mask $mask                                             \
    -resid errts_BOLD_regression  \
    -model "1+condition"                        \
    -ranEff "1+condition"                              \
    -qVars "condition"                                        \
    -dataTable @$Home/GLM_model.1D

The data table looks like this :
Subj condition InputFile
1 0 stats.subj1+tlrc.BRIK[6]"
1 1 stats.subj1+tlrc.BRIK[10]"
1 2 stats.subj1+tlrc.BRIK[14]"
[...]
N 0 stats.subjN+tlrc.BRIK[6]"
N 1 stats.subjN+tlrc.BRIK[10]"
N 2 stats.subjN+tlrc.BRIK[14]"

Nothing too fancy.
I made 3dLME work on Friday, but on Monday it gives me this error :

++++++++++++++++++++++++++++++++++++++++++++++++++++
***** Summary information of data structure *****
26 subjects :  1 10 11 12 13 14 15 16 17 18 19 2 20 21 22 23 24 25 26 3 4 5 6 7 8 9 
78 response values
78 centered values for numeric variable entropy : -1 0 1 -1 0 1 -1 0 1 -1 0 1 -1 0 1 -1 0 1 -1 0 1 -1 0 1 -1 0 1 -1 0 1 -1 0 1 -1 0 1 -1 0 1 -1 0 1 -1 0 1 -1 0 1 -1 0 1 -1 0 1 -1 0 1 -1 0 1 -1 0 1 -1 0 1 -1 0 1 -1 0 1 -1 0 1 -1 0 1 
0 post hoc tests

Contingency tables of subject distributions among the categorical variables:


Tabulation of subjects against all categorical variables***** End of data structure information *****
++++++++++++++++++++++++++++++++++++++++++++++++++++
[...]
Erreur dans eval(parse(text = lop$ranEff[[n]])) : 
  objet 'condition' introuvable
Appels : eval -> eval
ExĂ©cution arrĂȘtĂ©e

which translates into : cannot find object 'condition', execution halted.
My guess is that I have different version of the same function installed. I'll try to change the default library in use in R to see if one of them work.

The other error is the classical one from 3dLMEr :

++++++++++++++++++++++++++++++++++++++++++++++++++++
***** Summary information of data structure *****
78 response values

Contingency tables of subject distributions among the categorical variables:

***** End of data structure information *****
++++++++++++++++++++++++++++++++++++++++++++++++++++

~~~~~~~~~~~~~~~~~~~ Model test failed  ~~~~~~~~~~~~~~~~~~~
Possible reasons:

0) Make sure that R package lmerTest has been installed. See the 3dLME
help documentation for more details.

1) Inappropriate model specification with options -model, or -qVars.

2) In correct specifications for random effect with -ranEff.

3) Mistakes in data table. Check the data structure shown above, and verify
whether there are any inconsistencies.

4) Inconsistent variable names which are case sensitive. For example, factor
named Scanner in model specification and then listed as scanner in the table hader
would cause grief for 3dLMEr.

** Error: 
   Quitting due to model test failure...

I never managed to go further that point with 3dLMEr
Any clue why this occurs ? I tested what is proposed, added ranEff line, installed libraries (they load anyway)

I don't mind which way to do it, but I want my condition to be regressed with one coefficient (continuous variable and clustered through any way possible (preferably 3dClusterize as I have bits of code doing stuff after this step). If you know any other way to do the regression, I would love it

Update.

After ranting a while and a nice cup of coffee, I ran "@afni_R_package_install -afni" which unintentionally updated all the R programs in the AFNI library (there is indeed a specific library, but I thought the command line would first output the path to this library rather than update everything, but hey, never mind). Now 3dLMEr is working, a lot of "boundary (singular) fit: see help ('issingular')", but I guess we'll see about that later.

I guess it was indeed a R library problem, It would be nice to have a handy description of AFNI hierarchy of libraries to be make sure we can fiddle with our own libraries and modify whatever without destroying AFNI's work (I couldn't find it on the web).

3dLMEr -overwrite -prefix BOLD_regression                              \
    -mask $mask                                             \
    -resid errts_BOLD_regression  \
    -model "1+entropy+(1|Subj)"                        \
    -qVars "condition"                                        \
    -dataTable @$Home/GLM_model.1D

There are two issues with this script:

  1. Should the variable be named entropy or condition?
  2. It should not be treated as a quantitative variable (remove -qVars "condition").

If you want pair-wise comparisons across the three conditions, use option -gltCode.


3dLME -overwrite -prefix BOLD_regression                              \
    -mask $mask                                             \
    -resid errts_BOLD_regression  \
    -model "1+condition"                        \
    -ranEff "1+condition"                              \
    -qVars "condition"                                        \
    -dataTable @$Home/GLM_model.1D

There are two issues with this script:

  1. The variable condition should not be treated as a quantitative variable (remove -qVars "condition").
  2. The variable condition should not be treated as a random variable (change -ranEff "1+condition" to -ranEff "~1" ).

Gang Chen

Thank you Gang,

I might be a bit confused there.
I would like to have one beta and stat for 'condition', so one coefficient for the three levels (we expect a linear relation).
Should I drop 'condition' as random effect but keep it as qVars ?

It might be challenging to assess linearity among only three data points. See if the following works:

3dLMEr -overwrite -prefix BOLD_regression \
    -mask $mask                           \
    -resid errts_BOLD_regression          \
    -model "condition+(condition|Subj)"   \
    -qVars "condition"                    \
    -gltCode "condition :"                \
    -dataTable @$Home/GLM_model.1D
1 Like

Hello Gang,

The previous command you proposed works fine, thank you.
I now need to check the same relation, but with the condition (3 levels) being not continuous, but with three levels.

I tried this command :

3dLMEr -overwrite -prefix BOLD_regression \
      -mask $mask                           \
      -resid errts_BOLD_regression          \
      -model "1+condition+(1+condition|Subj)"   \
      -gltCode H0 "condition : 1*0"                \
      -gltCode H1 "condition : 1*1"                \
      -gltCode H2 "condition : 1*2"                \
      -gltCode H2-H1 "condition : 1*2 -1*1"                \
      -gltCode H2-H0 "condition : 1*2 -1*0"                \
      -gltCode H1-H0 "condition : 1*1 -1*0"                \
      -dataTable @$Home/GLM_model_BOLD.1D

But I get error from *3dLMEr :

~~~~~~~~~~~~~~~~~~~ Model test failed  ~~~~~~~~~~~~~~~~~~~
Possible reasons:

0) Make sure that R package lmerTest has been installed. See the 3dLME
help documentation for more details.

1) Inappropriate model specification with options -model, or -qVars.

2) In correct specifications for random effect with -ranEff.

3) Mistakes in data table. Check the data structure shown above, and verify
whether there are any inconsistencies.

4) Inconsistent variable names which are case sensitive. For example, factor
named Scanner in model specification and then listed as scanner in the table hader
would cause grief for 3dLMEr.

** Error: 
   Quitting due to model test failure...

As I mentioned, packages have been loaded successfully, and I can run the model you proposed before.

Any advice ?
Thanks

So, after different tries, it seems that it is the random prat of the model that is the problem.

1+condition+(1+condition|Subj)

gives error, while ```
1+condition+(1|Subj)

works well. 
Can we not do a factor variable as random ?

When condition is a categorical variable (factor), the following is the correct setup:

1+condition+(1|Subj)

For model specification, refer to this blog post for more details.

Gang Chen

Okay, thank you very much for the link,

I am fully analyzing now.

Thank you for your time