Error in gltRes[[n]] : subscript out of bounds

Hello! I'm receiving the following error when running 3dLME:

Error in gltRes[[n]] : subscript out of bounds

The data seems to load ok and the matrices look correct. Another post on the message board about a similar error said to update AFNI, but the version I'm running is more recent than that post, so I'm not sure that's the problem. Any advice? Thank you!

AFNI version info (afni -ver): AFNI_24.2.07 'Macrinus'

It would be helpful if you could share the following details:

  • The version of R
  • The nature of the variables involved (e.g., between-individual factors, within-individual factors, or between-individual or within-individual quantitative variables)
  • The 3dLME script you’re running

Gang Chen

Thanks, Gang! Info below:

R version 3.6.3 (2020-02-29) -- "Holding the Windsock"

The variables are between-individual, and the model includes both categorical and quantitative variables. Here's the output from 3dLME about the variables, followed by the script (I truncated the data table, if you want it all let me know):

Dimensions:
rows: 588 | columns: 5

Data summary:
Variable Detected_Type Details
Subj Subjects Num Subjects=49
condition Categorical Unique levels=12
age Quantitative Min=18 | Max=37 | Num outliers=48
gender Categorical Counts: F=360 | M=228
InputFile Data Number of InputFiles=588

++ Good: All InputFiles exist.

++ Good: All InputFiles have exactly 1 volume.

++ Good: All InputFiles are on the same grid.

#!/bin/bash

file="lepetitprince_convolved_stats"

3dLME \
-prefix lme_lepetitprince_convolved.nii.gz \
-mask MNI_N27_dilate3_fillholes_2mm.nii.gz \
-model "condition+age+gender" \
-qVars "age" \
-qVarsCenters "21.31" \
-ranEff '~1' \
-SS_type 3 \
-num_glt 104 \
-gltLabel 1 'seed' -gltCode 1 'condition : 1*word 1*lan1 1*lan2 1*lan3 1*lan4 1*lan5 1*lan6 1*lan7 1*lan8 1*lan9 1*lan10 1*lan11' \
-gltLabel 2 'lan1_seed' -gltCode 2 'condition : 1*lan1' \
-gltLabel 3 'lan2_seed' -gltCode 3 'condition : 1*lan2' \
-gltLabel 4 'lan3_seed' -gltCode 4 'condition : 1*lan3' \
-gltLabel 5 'lan4_seed' -gltCode 5 'condition : 1*lan4' \
-gltLabel 6 'lan5_seed' -gltCode 6 'condition : 1*lan5' \
-gltLabel 7 'lan6_seed' -gltCode 7 'condition : 1*lan6' \
-gltLabel 8 'lan7_seed' -gltCode 8 'condition : 1*lan7' \
-gltLabel 9 'lan8_seed' -gltCode 9 'condition : 1*lan8' \
-gltLabel 10 'lan9_seed' -gltCode 10 'condition : 1*lan9' \
-gltLabel 11 'lan10_seed' -gltCode 11 'condition : 1*lan10' \
-gltLabel 12 'lan11_seed' -gltCode 12 'condition : 1*lan11' \
-gltLabel 13 'word_seed' -gltCode 13 'condition : 1*word' \
-gltLabel 14 'lan1_vs_lan2' -gltCode 14 'condition : 1*lan1 -1*lan2' \
-gltLabel 15 'lan1_vs_lan3' -gltCode 15 'condition : 1*lan1 -1*lan3' \
-gltLabel 16 'lan1_vs_lan4' -gltCode 16 'condition : 1*lan1 -1*lan4' \
-gltLabel 17 'lan1_vs_lan5' -gltCode 17 'condition : 1*lan1 -1*lan5' \
-gltLabel 18 'lan1_vs_lan6' -gltCode 18 'condition : 1*lan1 -1*lan6' \
-gltLabel 19 'lan1_vs_lan7' -gltCode 19 'condition : 1*lan1 -1*lan7' \
-gltLabel 20 'lan1_vs_lan8' -gltCode 20 'condition : 1*lan1 -1*lan8' \
-gltLabel 21 'lan1_vs_lan9' -gltCode 21 'condition : 1*lan1 -1*lan9' \
-gltLabel 22 'lan1_vs_lan10' -gltCode 22 'condition : 1*lan1 -1*lan10' \
-gltLabel 23 'lan1_vs_lan11' -gltCode 23 'condition : 1*lan1 -1*lan11' \
-gltLabel 24 'lan1_vs_word' -gltCode 24 'condition : 1*lan1 -1*word' \
-gltLabel 25 'lan2_vs_lan3' -gltCode 25 'condition : 1*lan2 -1*lan3' \
-gltLabel 26 'lan2_vs_lan4' -gltCode 26 'condition : 1*lan2 -1*lan4' \
-gltLabel 27 'lan2_vs_lan5' -gltCode 27 'condition : 1*lan2 -1*lan5' \
-gltLabel 28 'lan2_vs_lan6' -gltCode 28 'condition : 1*lan2 -1*lan6' \
-gltLabel 29 'lan2_vs_lan7' -gltCode 29 'condition : 1*lan2 -1*lan7' \
-gltLabel 30 'lan2_vs_lan8' -gltCode 30 'condition : 1*lan2 -1*lan8' \
-gltLabel 31 'lan2_vs_lan9' -gltCode 31 'condition : 1*lan2 -1*lan9' \
-gltLabel 32 'lan2_vs_lan10' -gltCode 32 'condition : 1*lan2 -1*lan10' \
-gltLabel 33 'lan2_vs_lan11' -gltCode 33 'condition : 1*lan2 -1*lan11' \
-gltLabel 34 'lan2_vs_word' -gltCode 34 'condition : 1*lan2 -1*word' \
-gltLabel 35 'lan3_vs_lan4' -gltCode 35 'condition : 1*lan3 -1*lan4' \
-gltLabel 36 'lan3_vs_lan5' -gltCode 36 'condition : 1*lan3 -1*lan5' \
-gltLabel 37 'lan3_vs_lan6' -gltCode 37 'condition : 1*lan3 -1*lan6' \
-gltLabel 38 'lan3_vs_lan7' -gltCode 38 'condition : 1*lan3 -1*lan7' \
-gltLabel 39 'lan3_vs_lan8' -gltCode 39 'condition : 1*lan3 -1*lan8' \
-gltLabel 40 'lan3_vs_lan9' -gltCode 40 'condition : 1*lan3 -1*lan9' \
-gltLabel 41 'lan3_vs_lan10' -gltCode 41 'condition : 1*lan3 -1*lan10' \
-gltLabel 42 'lan3_vs_lan11' -gltCode 42 'condition : 1*lan3 -1*lan11' \
-gltLabel 43 'lan3_vs_word' -gltCode 43 'condition : 1*lan3 -1*word' \
-gltLabel 44 'lan4_vs_lan5' -gltCode 44 'condition : 1*lan4 -1*lan5' \
-gltLabel 45 'lan4_vs_lan6' -gltCode 45 'condition : 1*lan4 -1*lan6' \
-gltLabel 46 'lan4_vs_lan7' -gltCode 46 'condition : 1*lan4 -1*lan7' \
-gltLabel 47 'lan4_vs_lan8' -gltCode 47 'condition : 1*lan4 -1*lan8' \
-gltLabel 48 'lan4_vs_lan9' -gltCode 48 'condition : 1*lan4 -1*lan9' \
-gltLabel 49 'lan4_vs_lan10' -gltCode 49 'condition : 1*lan4 -1*lan10' \
-gltLabel 50 'lan4_vs_lan11' -gltCode 50 'condition : 1*lan4 -1*lan11' \
-gltLabel 51 'lan4_vs_word' -gltCode 51 'condition : 1*lan4 -1*word' \
-gltLabel 52 'lan5_vs_lan6' -gltCode 52 'condition : 1*lan5 -1*lan6' \
-gltLabel 53 'lan5_vs_lan7' -gltCode 53 'condition : 1*lan5 -1*lan7' \
-gltLabel 54 'lan5_vs_lan8' -gltCode 54 'condition : 1*lan5 -1*lan8' \
-gltLabel 55 'lan5_vs_lan9' -gltCode 55 'condition : 1*lan5 -1*lan9' \
-gltLabel 56 'lan5_vs_lan10' -gltCode 56 'condition : 1*lan5 -1*lan10' \
-gltLabel 57 'lan5_vs_lan11' -gltCode 57 'condition : 1*lan5 -1*lan11' \
-gltLabel 58 'lan5_vs_word' -gltCode 58 'condition : 1*lan5 -1*word' \
-gltLabel 59 'lan6_vs_lan7' -gltCode 59 'condition : 1*lan6 -1*lan7' \
-gltLabel 60 'lan6_vs_lan8' -gltCode 60 'condition : 1*lan6 -1*lan8' \
-gltLabel 61 'lan6_vs_lan9' -gltCode 61 'condition : 1*lan6 -1*lan9' \
-gltLabel 62 'lan6_vs_lan10' -gltCode 62 'condition : 1*lan6 -1*lan10' \
-gltLabel 63 'lan6_vs_lan11' -gltCode 63 'condition : 1*lan6 -1*lan11' \
-gltLabel 64 'lan6_vs_word' -gltCode 64 'condition : 1*lan6 -1*word' \
-gltLabel 65 'lan7_vs_lan8' -gltCode 65 'condition : 1*lan7 -1*lan8' \
-gltLabel 66 'lan7_vs_lan9' -gltCode 66 'condition : 1*lan7 -1*lan9' \
-gltLabel 67 'lan7_vs_lan10' -gltCode 67 'condition : 1*lan7 -1*lan10' \
-gltLabel 68 'lan7_vs_lan11' -gltCode 68 'condition : 1*lan7 -1*lan11' \
-gltLabel 69 'lan7_vs_word' -gltCode 69 'condition : 1*lan7 -1*word' \
-gltLabel 70 'lan8_vs_lan9' -gltCode 70 'condition : 1*lan8 -1*lan9' \
-gltLabel 71 'lan8_vs_lan10' -gltCode 71 'condition : 1*lan8 -1*lan10' \
-gltLabel 72 'lan8_vs_lan11' -gltCode 72 'condition : 1*lan8 -1*lan11' \
-gltLabel 73 'lan8_vs_word' -gltCode 73 'condition : 1*lan8 -1*word' \
-gltLabel 74 'lan9_vs_lan10' -gltCode 74 'condition : 1*lan9 -1*lan10' \
-gltLabel 75 'lan9_vs_lan11' -gltCode 75 'condition : 1*lan9 -1*lan11' \
-gltLabel 76 'lan9_vs_word' -gltCode 76 'condition : 1*lan9 -1*word' \
-gltLabel 77 'lan10_vs_lan11' -gltCode 77 'condition : 1*lan10 -1*lan11' \
-gltLabel 78 'lan10_vs_word' -gltCode 78 'condition : 1*lan10 -1*word' \
-gltLabel 79 'lan11_vs_word' -gltCode 79 'condition : 1*lan11 -1*word' \
-gltLabel 80 'lan1_vs_all' -gltCode 80 'condition : 1*lan1 -1*lan2 -1*lan3 -1*lan4 -1*lan5 -1*lan6 -1*lan7 -1*lan8 -1*lan9 -1*lan10 -1*lan11 -1*word' \
-gltLabel 81 'lan2_vs_all' -gltCode 81 'condition : 1*lan2 -1*lan1 -1*lan3 -1*lan4 -1*lan5 -1*lan6 -1*lan7 -1*lan8 -1*lan9 -1*lan10 -1*lan11 -1*word' \
-gltLabel 82 'lan3_vs_all' -gltCode 82 'condition : 1*lan3 -1*lan2 -1*lan1 -1*lan4 -1*lan5 -1*lan6 -1*lan7 -1*lan8 -1*lan9 -1*lan10 -1*lan11 -1*word' \
-gltLabel 83 'lan4_vs_all' -gltCode 83 'condition : 1*lan4 -1*lan2 -1*lan3 -1*lan1 -1*lan5 -1*lan6 -1*lan7 -1*lan8 -1*lan9 -1*lan10 -1*lan11 -1*word' \
-gltLabel 84 'lan5_vs_all' -gltCode 84 'condition : 1*lan5 -1*lan2 -1*lan3 -1*lan4 -1*lan1 -1*lan6 -1*lan7 -1*lan8 -1*lan9 -1*lan10 -1*lan11 -1*word' \
-gltLabel 85 'lan6_vs_all' -gltCode 85 'condition : 1*lan6 -1*lan2 -1*lan3 -1*lan4 -1*lan5 -1*lan1 -1*lan7 -1*lan8 -1*lan9 -1*lan10 -1*lan11 -1*word' \
-gltLabel 86 'lan7_vs_all' -gltCode 86 'condition : 1*lan7 -1*lan2 -1*lan3 -1*lan4 -1*lan5 -1*lan6 -1*lan1 -1*lan8 -1*lan9 -1*lan10 -1*lan11 -1*word' \
-gltLabel 87 'lan8_vs_all' -gltCode 87 'condition : 1*lan8 -1*lan2 -1*lan3 -1*lan4 -1*lan5 -1*lan6 -1*lan7 -1*lan1 -1*lan9 -1*lan10 -1*lan11 -1*word' \
-gltLabel 88 'lan9_vs_all' -gltCode 88 'condition : 1*lan9 -1*lan2 -1*lan3 -1*lan4 -1*lan5 -1*lan6 -1*lan7 -1*lan8 -1*lan1 -1*lan10 -1*lan11 -1*word' \
-gltLabel 89 'lan10_vs_all' -gltCode 89 'condition : 1*lan10 -1*lan2 -1*lan3 -1*lan4 -1*lan5 -1*lan6 -1*lan7 -1*lan8 -1*lan9 -1*lan1 -1*lan11 -1*word' \
-gltLabel 90 'lan11_vs_all' -gltCode 90 'condition : 1*lan11 -1*lan2 -1*lan3 -1*lan4 -1*lan5 -1*lan6 -1*lan7 -1*lan8 -1*lan9 -1*lan10 -1*lan1 -1*word' \
-gltLabel 91 'word_vs_all' -gltCode 91 'condition : 1*word -1*lan2 -1*lan3 -1*lan4 -1*lan5 -1*lan6 -1*lan7 -1*lan8 -1*lan9 -1*lan10 -1*lan11 -1*lan1' \
-gltLabel 92 'SM_vs_sensory' -gltCode 92 'condition : 1*lan3 +1*lan4 +1*lan7 +1*lan8 +1*lan9 +1*lan10 +1*lan11 -1*lan1 -1*lan5 -1*lan6 -1*lan2' \
-gltLabel 93 'lan1_vs_lan' -gltCode 93 'condition : 1*lan1 -1*lan2 -1*lan3 -1*lan4 -1*lan5 -1*lan6 -1*lan7 -1*lan8 -1*lan9 -1*lan10 -1*lan11' \
-gltLabel 94 'lan2_vs_lan' -gltCode 94 'condition : 1*lan2 -1*lan1 -1*lan3 -1*lan4 -1*lan5 -1*lan6 -1*lan7 -1*lan8 -1*lan9 -1*lan10 -1*lan11' \
-gltLabel 95 'lan3_vs_lan' -gltCode 95 'condition : 1*lan3 -1*lan2 -1*lan1 -1*lan4 -1*lan5 -1*lan6 -1*lan7 -1*lan8 -1*lan9 -1*lan10 -1*lan11' \
-gltLabel 96 'lan4_vs_lan' -gltCode 96 'condition : 1*lan4 -1*lan2 -1*lan3 -1*lan1 -1*lan5 -1*lan6 -1*lan7 -1*lan8 -1*lan9 -1*lan10 -1*lan11' \
-gltLabel 97 'lan5_vs_lan' -gltCode 97 'condition : 1*lan5 -1*lan2 -1*lan3 -1*lan4 -1*lan1 -1*lan6 -1*lan7 -1*lan8 -1*lan9 -1*lan10 -1*lan11' \
-gltLabel 98 'lan6_vs_lan' -gltCode 98 'condition : 1*lan6 -1*lan2 -1*lan3 -1*lan4 -1*lan5 -1*lan1 -1*lan7 -1*lan8 -1*lan9 -1*lan10 -1*lan11' \
-gltLabel 99 'lan7_vs_lan' -gltCode 99 'condition : 1*lan7 -1*lan2 -1*lan3 -1*lan4 -1*lan5 -1*lan6 -1*lan1 -1*lan8 -1*lan9 -1*lan10 -1*lan11' \
-gltLabel 100 'lan8_vs_lan' -gltCode 100 'condition : 1*lan8 -1*lan2 -1*lan3 -1*lan4 -1*lan5 -1*lan6 -1*lan7 -1*lan1 -1*lan9 -1*lan10 -1*lan11' \
-gltLabel 101 'lan9_vs_lan' -gltCode 101 'condition : 1*lan9 -1*lan2 -1*lan3 -1*lan4 -1*lan5 -1*lan6 -1*lan7 -1*lan8 -1*lan1 -1*lan10 -1*lan11' \
-gltLabel 102 'lan10_vs_lan' -gltCode 102 'condition : 1*lan10 -1*lan2 -1*lan3 -1*lan4 -1*lan5 -1*lan6 -1*lan7 -1*lan8 -1*lan9 -1*lan1 -1*lan11' \
-gltLabel 103 'lan11_vs_lan' -gltCode 103 'condition : 1*lan11 -1*lan2 -1*lan3 -1*lan4 -1*lan5 -1*lan6 -1*lan7 -1*lan8 -1*lan9 -1*lan10 -1*lan1' \
-gltLabel 104 'sensory_vs_motor' -gltCode 104 'condition : 1*lan1 +1*lan2 +1*lan3 +1*lan4 +1*lan5 +1*lan6 -1*lan7 -1*lan8 -1*lan9 -1*lan10 -1*lan11' \
-dataTable \
Subj condition age gender InputFile \
sub-EN057 word 20 F sub-EN057_"$file".nii.gz['lancaster_words#0_Coef'] \
sub-EN057 lan1 20 F sub-EN057_"$file".nii.gz['lancaster_words#3_Coef'] \
sub-EN057 lan2 20 F sub-EN057_"$file".nii.gz['lancaster_words#4_Coef'] \
sub-EN057 lan3 20 F sub-EN057_"$file".nii.gz['lancaster_words#5_Coef'] \
sub-EN057 lan4 20 F sub-EN057_"$file".nii.gz['lancaster_words#6_Coef'] \
sub-EN057 lan5 20 F sub-EN057_"$file".nii.gz['lancaster_words#7_Coef'] \
sub-EN057 lan6 20 F sub-EN057_"$file".nii.gz['lancaster_words#8_Coef'] \
sub-EN057 lan7 20 F sub-EN057_"$file".nii.gz['lancaster_words#9_Coef'] \
sub-EN057 lan8 20 F sub-EN057_"$file".nii.gz['lancaster_words#10_Coef'] \
sub-EN057 lan9 20 F sub-EN057_"$file".nii.gz['lancaster_words#11_Coef'] \
sub-EN057 lan10 20 F sub-EN057_"$file".nii.gz['lancaster_words#12_Coef'] \
sub-EN057 lan11 20 F sub-EN057_"$file".nii.gz['lancaster_words#13_Coef'] \
sub-EN058 word 22 M sub-EN058_"$file".nii.gz['lancaster_words#0_Coef'] \
...
sub-EN115 lan11 23 F sub-EN115_"$file".nii.gz['lancaster_words#13_Coef']

I could not find anything obviously wrong. As a sanity check, try updating your R to the latest version. Additionally, reinstall the following packages in R:

install.packages("nlme")  
install.packages("lme4")  
install.packages("phia")  
install.packages("snow")  

Once updated, rerun your 3dLME script to see if the issue is resolved.

Gang Chen

Hi Gang. Thank you for this suggestion; it changed the error message at least!

Error in if (!is.na(lop$qVars)) lop$QV <- strsplit(lop$qVars, "\,")[[1]] :
the condition has length > 1
Calls: process.LME.opts
Execution halted

I found another thread on the message board about this error that sounds like it's an R compatibility issue? I updated to R version 4.4.2 (2024-10-31) -- "Pile of Leaves". Any other suggestions?

After a bit of hunting, I finally spotted the issue. The line:

-qVarsCenters "21.31" \

should actually be:

-qVarCenters "21.31" \

Hope this fix will keep your computer busy for a while.

As a side note, the model can also be specified using 3dLMEr or 3dMVM.

Gang Chen

That worked, thank you very much!!!