R and 3dMVM

Hello, I’m in need of some help!

Want to use 3dMVM - installed R following the build R instructions by Gang Chen (https://afni.nimh.nih.gov/sscc/gangc/Rinstall.html).

When trying to get afni to run R: afni_run_R, terminal outputs that it requires at least 2 args

When attempting to execute afni_run_R in users bin where afni is located, permission denied.

When trying to my run 3dMVM script, error message: The content under -datatable is not rectangular ! 257 4
Not sure if this error is because afni can’t access R or not


Thank you for your time and help!


First, a couple preliminary things.

++ The main installation instructions for AFNI and it’s dependencies (R, Python, etc.) can be found here:
You can pick whatever your Linux flavor or Mac OS version is.

++ Q1: what operating system are you using, and what AFNI version do you have? These can both be answered by providing the output of:
$ afni -ver

++ To check if everything is installed fine-and-dandy on your computer, you can use the helpful system check command to check on system path things and whether necessary dependencies (again, for R, Python, etc.) can be found:
$ afni_system_check.py -check_all

++ Q2: what are you aiming to see by using ‘afni_run_R’? I think that might just be some diagnostic thing, but it’s not really 3dMVM itself.

++ Finally, it could be that your data table itself really isn’t rectangular. Can you post it? If you don’t want to post it, you can also email it, along with your 3dMVM command. There are also some rules of data tabling in the helpfile that I am attaching here, worth double-checking:

-dataTable TABLE: List the data structure with a header as the first line.


         1) This option has to occur last; that is, no other options are
         allowed thereafter. Each line should end with a backslash except for
         the last line.

         2) The first column is fixed and reserved with label 'Subj', and the
         last is reserved for 'InputFile'. Each row should contain only one
         effect estimate in the table of long format (cf. wide format) as
         defined in R. The level labels of a factor should contain at least
         one character. Input files can be in AFNI, NIfTI or surface format.
         AFNI files can be specified with sub-brick selector (square brackets
         [] within quotes) specified with a number or label. Unequal number of
         subjects across groups is allowed, but situations with missing data
         for a within-subject factor are better handled with 3dLME.

         3) It is fine to have variables (or columns) in the table that are
         not modeled in the analysis.

         4) The context of the table can be saved as a separate file, e.g.,
         called table.txt. Do not forget to include a backslash at the end of
         each row. In the script specify the data with '-dataTable @table.txt'.
         This option is useful: (a) when there are many input files so that
         the program complains with an 'Arg list too long' error; (b) when
         you want to try different models with the same dataset (see 3) above).



Thanks for your helpful reply.

++ Using Mac OS 10.7.5 afni version AFNI_2011_12_21_1014

++ Checked the system, all is fine
$ afni_system_check.py -check_all

++Did the following:


However, R is still having warning messages regarding package ‘car’
Error: package or namespace load failed for ‘car’

When running my 3dMVM script, now model test failed for a few possible reasons, one being to make sure that R packages afex and phia have been installed. In R under Package Manager, afex and phia are not loaded and even clicking they wont load.

Using R version for snow leopard 3.2.1 GUI 1.66

Presume I need to get the latest version of R for these packages in order to run 3dMVM, but I assume this means I have to update my Mac OS system as well?

Your AFNI might be too old. Update it first:

@update.afni.binaries -d

and try it again.

++ extracting package macosx_10.7_Intel_64…
tar: Unrecognized archive format
tar: Error exit delayed from previous errors.
** failed to extract package macosx_10.7_Intel_64.tgz

That is probably because your version of AFNI is quite old, and the update script in it is pointing to the old ‘http’ website, as opposed to the new ‘https’ one. Please follow the instructions here:


and see if that works.