A strange error when using MBA

AFNI version info (afni -ver): 23.3.14

Hi AFNI members:

When I use MBA to continue analyzing the results from 3dNetcorr, I encounter this strange error:

Loading required package: Rcpp
Loading 'brms' package (version 2.20.4). Useful instructions
can be found by typing help('brms'). A more detailed introduction
to the package is available through vignette('brms_overview').

Attaching package: ‘brms’

The following object is masked from ‘package:stats’:

    ar

Error in `$<-.data.frame`(`*tmp*`, ROI1, value = integer(0)) : 
  replacement has 0 rows, data has 18648
Calls: $<- -> $<-.data.frame
Execution halted

This is my script:

MBA -prefix ${group_dir}/exp_test -r2z -dataTable ${group_dir}/exp.table \
    -chains 4 -iterations 1000 -WCP 3 \
    -model '1+group' -EOI 'Intercept, group'

and the end of the input table:

image

or a sample table:

Subj,group,ROI1,ROI2,Y
sub-05_ses-before,before,EXA,GPe,0.24
sub-05_ses-before,before,EXA,GPi,0.1331
sub-05_ses-before,before,EXA,HN,-0.053
sub-05_ses-before,before,EXA,HTH,0.1292
sub-05_ses-before,before,EXA,LH_DefaultA_PFCd_1,0.1732
sub-05_ses-before,before,EXA,LH_DefaultA_PFCm_1,0.1122
sub-05_ses-before,before,EXA,LH_DefaultA_pCunPCC_1,0.0362
sub-05_ses-before,before,EXA,LH_DefaultB_IPL_1,0.2402
sub-05_ses-before,before,EXA,LH_DefaultB_PFCd_1,0.2737
sub-05_ses-before,before,EXA,LH_DefaultB_PFCl_1,0.1783
sub-05_ses-before,before,EXA,LH_DefaultB_PFCv_1,0.2059
sub-05_ses-before,before,EXA,LH_DefaultB_PFCv_2,0.2219
sub-05_ses-before,before,EXA,LH_DefaultB_Temp_1,0.1228
sub-05_ses-before,before,EXA,LH_DefaultB_Temp_2,0.1899
sub-05_ses-before,before,EXA,LH_DefaultC_PHC_1,0.1311
sub-05_ses-before,before,EXA,LH_DefaultC_Rsp_1,-0.0423
sub-05_ses-before,before,EXA,MN,0.0359
sub-05_ses-before,before,EXA,NAC,0.1941
sub-05_ses-before,before,EXA,PBP,-0.072
sub-05_ses-before,before,EXA,Pu,0.1985
sub-05_ses-before,before,EXA,RH_DefaultA_IPL_1,0.1556
sub-05_ses-before,before,EXA,RH_DefaultA_PFCd_1,0.2147
sub-05_ses-before,before,EXA,RH_DefaultA_PFCm_1,0.1349
sub-05_ses-before,before,EXA,RH_DefaultA_pCunPCC_1,0.0287
sub-05_ses-before,before,EXA,RH_DefaultB_PFCd_1,0.2306
sub-05_ses-before,before,EXA,RH_DefaultB_PFCv_1,0.0936
sub-05_ses-before,before,EXA,RH_DefaultB_PFCv_2,0.1512
sub-05_ses-before,before,EXA,RH_DefaultC_PHC_1,-0.0335
sub-05_ses-before,before,EXA,RH_DefaultC_Rsp_1,-0.0081
sub-05_ses-before,before,EXA,RN,0.0137
sub-05_ses-before,before,EXA,SNc,-0.0174
sub-05_ses-before,before,EXA,SNr,0.0175
sub-05_ses-before,before,EXA,STN,0.0017
sub-05_ses-before,before,EXA,VTA,-0.0475
sub-05_ses-before,before,EXA,VeP,0.3442
sub-05_ses-after,after,EXA,GPe,0.1789
sub-05_ses-after,after,EXA,GPi,0.0458
sub-05_ses-after,after,EXA,HN,-0.0743
sub-05_ses-after,after,EXA,HTH,0.1431
sub-05_ses-after,after,EXA,LH_DefaultA_PFCd_1,0.0322
sub-05_ses-after,after,EXA,LH_DefaultA_PFCm_1,0.1714
sub-05_ses-after,after,EXA,LH_DefaultA_pCunPCC_1,0.0687
sub-05_ses-after,after,EXA,LH_DefaultB_IPL_1,-0.0076
sub-05_ses-after,after,EXA,LH_DefaultB_PFCd_1,0.0061
sub-05_ses-after,after,EXA,LH_DefaultB_PFCl_1,-0.0363
sub-05_ses-after,after,EXA,LH_DefaultB_PFCv_1,0.033
sub-05_ses-after,after,EXA,LH_DefaultB_PFCv_2,0.0836
sub-05_ses-after,after,EXA,LH_DefaultB_Temp_1,0.0222
sub-05_ses-after,after,EXA,LH_DefaultB_Temp_2,0.0076
sub-05_ses-after,after,EXA,LH_DefaultC_PHC_1,0.0079
sub-05_ses-after,after,EXA,LH_DefaultC_Rsp_1,0.0724
sub-05_ses-after,after,EXA,MN,0.0929
sub-05_ses-after,after,EXA,NAC,0.0059
sub-05_ses-after,after,EXA,PBP,-0.1226
sub-05_ses-after,after,EXA,Pu,0.0105
sub-05_ses-after,after,EXA,RH_DefaultA_IPL_1,0.0829
sub-05_ses-after,after,EXA,RH_DefaultA_PFCd_1,0.0884
sub-05_ses-after,after,EXA,RH_DefaultA_PFCm_1,0.2084
sub-05_ses-after,after,EXA,RH_DefaultA_pCunPCC_1,0.0377
sub-05_ses-after,after,EXA,RH_DefaultB_PFCd_1,0.0746
sub-05_ses-after,after,EXA,RH_DefaultB_PFCv_1,0.1315
sub-05_ses-after,after,EXA,RH_DefaultB_PFCv_2,0.1071
sub-05_ses-after,after,EXA,RH_DefaultC_PHC_1,0.0782
sub-05_ses-after,after,EXA,RH_DefaultC_Rsp_1,0.0874
sub-05_ses-after,after,EXA,RN,-0.0787
sub-05_ses-after,after,EXA,SNc,0.0124
sub-05_ses-after,after,EXA,SNr,-0.0183
sub-05_ses-after,after,EXA,STN,-0.0022
sub-05_ses-after,after,EXA,VTA,0.02
sub-05_ses-after,after,EXA,VeP,0.1731

When I prepared the data for MBA, I didn't find some useful tutorial. So I did it in a hard way. First, I used fat_mvm_prep.py to generate the table. But that table could not be used directly by MBA. I needed to format it using Excel according to the MBA help. The whole process was so torturous. I hope some expert can give us more detailed tutorials about the preparatory stage of group analysis,like after running 3dNetcorr, you can use A to generate the input for B...

The current version of MBA requires the input in long format as a data frame and does not support comma-separated values (CSV) directly. To adapt your file exp.table, consider transforming it into a data frame in R using the following command:

d <- read.csv('exp.table')
write.table(d, file = "new_exp.table", append = FALSE, quote = FALSE, row.names = FALSE)

Afterwards, you can use the newly created new_exp.table as input for MBA.

Gang Chen

@Gang Thanks.
But another error occurred:

Syntax error in '/tmp/Rtmp297KX3/model_af58a03ed990050096d8fb59fd5a4e94.stan', line 22, column 5 to column 6, parsing error:
   -------------------------------------------------
    20:     *   an integer sequence from start to end
    21:     */
    22:    int[] sequence(int start, int end) {
              ^
    23:      array[end - start + 1] int seq;
    24:      for (n in 1:num_elements(seq)) {
   -------------------------------------------------

An identifier is expected as a function name.

Error: Syntax error found! See the message above for more information.
Execution halted

Hi @Gang,
After running 3dNetCorr, can I use part of that results as the input to RBA? Or use the ROI average of seed based whole brain correlation results as the input?

@Gang This discussion may be useful for debugging WCP error in MBA and RBA.
https://discourse.mc-stan.org/t/new-array-syntax-inside-functions/32892

@renyiyuan, it seems there is an issue with the R package brms. Here are two temporary solutions (either would work):

  1. Avoid using the option -WCP in RBA and MBA.

  2. Install older versions of cmdstanr and cmdstan using the following steps:

    a. Install an old version of cmdstanr in R:

    remotes::install_github("stan-dev/cmdstanr", ref = "v0.5.3")
    

    b. Remove the current version of cmdstan from a location like $home/.cmdstan/cmdstan-x.x.x.

    c. Install an old version of cmdstan in R:

    library(cmdstanr)
    install_cmdstan(cores = getOption("mc.cores", 2), version = '2.30.1')
    

I hope this helps resolve the issue.

Gang Chen

@Gang , thanks! I have tried cmdstan-2.31.0. It works.

@Gang ,
I check the RBA running log and see this error message:

Chain 1 Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:
Chain 1 Exception: Exception: student_t_lpdf: Scale parameter is inf, but must be positive finite! (in '/tmp/RtmpJMya6K/model-1ee872a588f2e.stan', line 84, column 4 to column 62) (in '/tmp/RtmpJMya6K/model-1ee872a588f2e.stan', line 162, column 4 to line 164, column 51)
Chain 1 If this warning occurs sporadically, such as for highly constrained variable types like covariance matrices, then the sampler is fine,
Chain 1 but if this warning occurs often then your model may be either severely ill-conditioned or misspecified.

I don't know what it means. Can you explain it?

I'm not entirely certain about the precise meaning of this warning, but I suspect it may not be a critical issue, as discussed here.

Gang Chen

I advise adding a options in the R interface to block this low-level warning. And thanks a lot.

To suppress the warning, install an older version of cmdstanr in R using the following command as suggested earlier:

remotes::install_github("stan-dev/cmdstanr", ref = "v0.5.3")

Gang Chen

Ok. Thanks. Compared to other issues, they are too trivial.

The error and warning appear to have been resolved in the latest development version of brms, which you can install in R using the following commands:

devtools::install_github("stan-dev/cmdstanr")
install_cmdstan(cores = getOption("mc.cores", 4))
if (!requireNamespace("remotes")) {
  install.packages("remotes")
}
remotes::install_github("paul-buerkner/brms")

Gang Chen

OK. I will try it later.