3dMVM syntax for this situation

Hello, I am having some problems trying to figure out how to code up my 3dMVM code for this specific situation. This is my first time coding a 3dMVM command so sorry for this basic stuff.

The situation is, I have a within-subject design with 3 timepoints. Mice undergo a resting state scan after a 1. baseline session, 2. injection with vehicle, and 3. injection with CGRP. There are no between subject variables of interest in this study. We want to control for sex.
In terms of statistical tests, I would like one f-test per condition, and a t-test for each possible contrast between baseline, vehicle, and cgrp (of which there are 3 total).

Because sex is of no interest to us except as something to control for, I was unsure of how to use the -bsVars or how to include the sex variable in my glts and glfs. Basically I think my command is a mess. Can someone give me suggestions or comments about how to optimize my code?

3dMVM -prefix ${OUTPUT} -jobs 24 -mask ${MASK} \
-bsVars “1+sex” \
-wsVars “condition” \
-SS_type 2 \
-num_glt 3 \
-gltLabel 1 BLvsV -gltCode  1 'condition : 1*baseline -1*vehicle' \
          -gltLabel 2 BLvsCGRP -gltCode 2 'condition : 1*baseline -1*cgrp \
          -gltLabel 3 VvsCGRP -gltCode 3 'condition : 1*vehicle -1*cgrp' \
-num_glf 3 \
-glfLabel 1 BL -glfCode 1 'condition : 1*baseline' \
          -glfLabel 2 V -glfCode 2 'condition : 1*vehicle' \
          -glfLabel 3 CGRP -glfCode 3 'condition : 1*cgrp' \
-dataTable                                                                                     \
          Subj  sex    condition InputFile                               \
          LS134 female baseline  ${FILE1}                 \
          LS134 female vehicle   ${FILE2}                 \
          LS134 female cgrp      ${FILE3}                 \
          LS143 male   baseline  ${FILE4}                 \
          LS143 male   vehicle   ${FILE5}                 \
          LS143 male   cgrp      ${FILE6}                 \
          ...
1 Like

You can simply specify the variable sex as

-bsVars "sex" \

I suggest the following two changes for those post hoc inferences. First, there is a missing end quote in your second test:

-gltLabel 2 BLvsCGRP -gltCode 2 'condition : 1*baseline -1*cgrp' \

Second, those three F-tests would be better performed as t-tests:

-num_glt 6 \
-gltLabel 1 BLvsV    -gltCode 1 'condition : 1*baseline -1*vehicle' \
-gltLabel 2 BLvsCGRP -gltCode 2 'condition : 1*baseline -1*cgrp' \
-gltLabel 3 VvsCGRP  -gltCode 3 'condition : 1*vehicle -1*cgrp' \
-gltLabel 4 BL       -gltCode 4 'condition : 1*baseline' \
-gltLabel 5 V        -gltCode 5 'condition : 1*vehicle' \
-glfLabel 6 CGRP     -gltCode 6 'condition : 1*cgrp' \

Gang Chen

2 Likes

Thanks so much for your quick response Gang. You guys are really unmatched by your message board help.

Hi Gang, I've got a follow-up question.
After editing my code, running it gives the following error:

Error in if (len%%wd != 0) errex.AFNI(paste("The content under -dataTable is not rectangular !", :
argument is of length zero
Calls: process.MVM.opts
Execution halted

I've gone through my datatable and checked for extra spaces and other problems but nothing I changed helped. I also resaved the file in excel, and also tried to include the table as part of the original code as in the examples in the help but I keep getting the same error. Am I missing something simple? my code for the script is as follows:

3dMVM -prefix ${RESDIR}/CGRP_MVM_results.nii.gz -jobs 24 -mask ${MASK} \
  -bsVars “sex” \
  -wsVars “condition” \
  -SS_type 2 \
  -num_glt 6 \
  -gltLabel 1 BLvsV -gltCode 1 'condition : 1*baseline -1*vehicle' \
  -gltLabel 2 BLvsCGRP -gltCode 2 'condition : 1*baseline -1*cgrp' \
  -gltLabel 3 VvsCGRP -gltCode 3 'condition : 1*vehicle -1*cgrp' \
  -gltLabel 4 BL -gltCode 4 'condition : 1*baseline' \
  -gltLabel 5 V -gltCode 5 'condition : 1*vehicle' \
  -gltLabel 6 CGRP -gltCode 6 'condition : 1*cgrp' \
  -datatable @/Dedicated/inc_database/scripts/lsowers/migraineMice/CGRP_MVM_datatable_XLtst.txt

And my datatable looks like this:

Subj	sex	condition	InputFile	\
LS131	male	baseline	/Dedicated/inc_database/project/lsowers/migraineMice/derivatives/inc/func/hopkins_offtheshits/seedFC_Thalamus-Sphere/seed2wholebrain/sub-LS131_ses-20230127T121643_dir-fwd_reg-DSURQE_THALsphereR_Z_map.nii.gz	\
LS131	male	vehicle	/Dedicated/inc_database/project/lsowers/migraineMice/derivatives/inc/func/hopkins_offtheshits/seedFC_Thalamus-Sphere/seed2wholebrain/sub-LS131_ses-20230130T113141_dir-fwd_reg-DSURQE_THALsphereR_Z_map.nii.gz	\
LS131	male	cgrp	/Dedicated/inc_database/project/lsowers/migraineMice/derivatives/inc/func/hopkins_offtheshits/seedFC_Thalamus-Sphere/seed2wholebrain/sub-LS131_ses-20230203T113723_dir-fwd_reg-DSURQE_THALsphereR_Z_map.nii.gz	\
LS132	female	baseline	/Dedicated/inc_database/project/lsowers/migraineMice/derivatives/inc/func/hopkins_offtheshits/seedFC_Thalamus-Sphere/seed2wholebrain/sub-LS132_ses-20230127T113358_dir-fwd_reg-DSURQE_THALsphereR_Z_map.nii.gz	\
LS132	female	vehicle	/Dedicated/inc_database/project/lsowers/migraineMice/derivatives/inc/func/hopkins_offtheshits/seedFC_Thalamus-Sphere/seed2wholebrain/sub-LS132_ses-20230130T105028_dir-fwd_reg-DSURQE_THALsphereR_Z_map.nii.gz	\
LS132	female	cgrp	/Dedicated/inc_database/project/lsowers/migraineMice/derivatives/inc/func/hopkins_offtheshits/seedFC_Thalamus-Sphere/seed2wholebrain/sub-LS132_ses-20230203T095503_dir-fwd_reg-DSURQE_THALsphereR_Z_map.nii.gz	\
LS133	male	baseline	/Dedicated/inc_database/project/lsowers/migraineMice/derivatives/inc/func/hopkins_offtheshits/seedFC_Thalamus-Sphere/seed2wholebrain/sub-LS133_ses-20230127T105007_dir-fwd_reg-DSURQE_THALsphereR_Z_map.nii.gz	\
LS133	male	vehicle	/Dedicated/inc_database/project/lsowers/migraineMice/derivatives/inc/func/hopkins_offtheshits/seedFC_Thalamus-Sphere/seed2wholebrain/sub-LS133_ses-20230130T121036_dir-fwd_reg-DSURQE_THALsphereR_Z_map.nii.gz	\
LS133	male	cgrp	/Dedicated/inc_database/project/lsowers/migraineMice/derivatives/inc/func/hopkins_offtheshits/seedFC_Thalamus-Sphere/seed2wholebrain/sub-LS133_ses-20230203T122305_dir-fwd_reg-DSURQE_THALsphereR_Z_map.nii.gz	\
LS134	female	baseline	/Dedicated/inc_database/project/lsowers/migraineMice/derivatives/inc/func/hopkins_offtheshits/seedFC_Thalamus-Sphere/seed2wholebrain/sub-LS134_ses-20230127T100441_dir-fwd_reg-DSURQE_THALsphereR_Z_map.nii.gz	\
LS134	female	vehicle	/Dedicated/inc_database/project/lsowers/migraineMice/derivatives/inc/func/hopkins_offtheshits/seedFC_Thalamus-Sphere/seed2wholebrain/sub-LS134_ses-20230130T095402_dir-fwd_reg-DSURQE_THALsphereR_Z_map.nii.gz	\
LS134	female	cgrp	/Dedicated/inc_database/project/lsowers/migraineMice/derivatives/inc/func/hopkins_offtheshits/seedFC_Thalamus-Sphere/seed2wholebrain/sub-LS134_ses-20230203T105424_dir-fwd_reg-DSURQE_THALsphereR_Z_map.nii.gz	\
LS135	male	baseline	/Dedicated/inc_database/project/lsowers/migraineMice/derivatives/inc/func/hopkins_offtheshits/seedFC_Thalamus-Sphere/seed2wholebrain/sub-LS135_ses-20230127T130242_dir-fwd_reg-DSURQE_THALsphereR_Z_map.nii.gz	\
LS135	male	vehicle	/Dedicated/inc_database/project/lsowers/migraineMice/derivatives/inc/func/hopkins_offtheshits/seedFC_Thalamus-Sphere/seed2wholebrain/sub-LS135_ses-20230130T125500_dir-fwd_reg-DSURQE_THALsphereR_Z_map.nii.gz	\
LS135	male	cgrp	/Dedicated/inc_database/project/lsowers/migraineMice/derivatives/inc/func/hopkins_offtheshits/seedFC_Thalamus-Sphere/seed2wholebrain/sub-LS135_ses-20230203T130418_dir-fwd_reg-DSURQE_THALsphereR_Z_map.nii.gz	\
LS141	male	baseline	/Dedicated/inc_database/project/lsowers/migraineMice/derivatives/inc/func/hopkins_offtheshits/seedFC_Thalamus-Sphere/seed2wholebrain/sub-LS141_ses-20230127T155431_dir-fwd_reg-DSURQE_THALsphereR_Z_map.nii.gz	\
LS141	male	vehicle	/Dedicated/inc_database/project/lsowers/migraineMice/derivatives/inc/func/hopkins_offtheshits/seedFC_Thalamus-Sphere/seed2wholebrain/sub-LS141_ses-20230130T154628_dir-fwd_reg-DSURQE_THALsphereR_Z_map.nii.gz	\
LS141	male	cgrp	/Dedicated/inc_database/project/lsowers/migraineMice/derivatives/inc/func/hopkins_offtheshits/seedFC_Thalamus-Sphere/seed2wholebrain/sub-LS141_ses-20230203T143101_dir-fwd_reg-DSURQE_THALsphereR_Z_map.nii.gz	\
LS143	male	baseline	/Dedicated/inc_database/project/lsowers/migraineMice/derivatives/inc/func/hopkins_offtheshits/seedFC_Thalamus-Sphere/seed2wholebrain/sub-LS143_ses-20230127T151227_dir-fwd_reg-DSURQE_THALsphereR_Z_map.nii.gz	\
LS143	male	vehicle	/Dedicated/inc_database/project/lsowers/migraineMice/derivatives/inc/func/hopkins_offtheshits/seedFC_Thalamus-Sphere/seed2wholebrain/sub-LS143_ses-20230130T134014_dir-fwd_reg-DSURQE_THALsphereR_Z_map.nii.gz	\
LS143	male	cgrp	/Dedicated/inc_database/project/lsowers/migraineMice/derivatives/inc/func/hopkins_offtheshits/seedFC_Thalamus-Sphere/seed2wholebrain/sub-LS143_ses-20230203T134752_dir-fwd_reg-DSURQE_THALsphereR_Z_map.nii.gz	\
LS144	female	baseline	/Dedicated/inc_database/project/lsowers/migraineMice/derivatives/inc/func/hopkins_offtheshits/seedFC_Thalamus-Sphere/seed2wholebrain/sub-LS144_ses-20230127T134926_dir-fwd_reg-DSURQE_THALsphereR_Z_map.nii.gz	\
LS144	female	vehicle	/Dedicated/inc_database/project/lsowers/migraineMice/derivatives/inc/func/hopkins_offtheshits/seedFC_Thalamus-Sphere/seed2wholebrain/sub-LS144_ses-20230130T142202_dir-fwd_reg-DSURQE_THALsphereR_Z_map.nii.gz	\
LS144	female	cgrp	/Dedicated/inc_database/project/lsowers/migraineMice/derivatives/inc/func/hopkins_offtheshits/seedFC_Thalamus-Sphere/seed2wholebrain/sub-LS144_ses-20230203T170433_dir-fwd_reg-DSURQE_THALsphereR_Z_map.nii.gz	\
LS145	male	baseline	/Dedicated/inc_database/project/lsowers/migraineMice/derivatives/inc/func/hopkins_offtheshits/seedFC_Thalamus-Sphere/seed2wholebrain/sub-LS145_ses-20230127T163618_dir-fwd_reg-DSURQE_THALsphereR_Z_map.nii.gz	\
LS145	male	vehicle	/Dedicated/inc_database/project/lsowers/migraineMice/derivatives/inc/func/hopkins_offtheshits/seedFC_Thalamus-Sphere/seed2wholebrain/sub-LS145_ses-20230130T162951_dir-fwd_reg-DSURQE_THALsphereR_Z_map.nii.gz	\
LS145	male	cgrp	/Dedicated/inc_database/project/lsowers/migraineMice/derivatives/inc/func/hopkins_offtheshits/seedFC_Thalamus-Sphere/seed2wholebrain/sub-LS145_ses-20230203T160039_dir-fwd_reg-DSURQE_THALsphereR_Z_map.nii.gz

This is the version from excel but i have also tried the table with just spaces between each column instead of tabs.

thanks for any insight.
lauren

p.s. sorry for the deleted post, i went to make an edit and hit the wrong button

What is your AFNI version?

afni -ver

If you update AFNI to the latest version, 3dMVM might provide more detailed information about the issue with the data table.

Gang Chen

Hi Gang,

I updated my afni binaries right before running this again so I am now running the most up-to-date afni
Precompiled binary macos_13_ARM_clang: Jul 11 2024 (Version AFNI_24.1.22 'Publius Septimius Geta')

I don't believe the error message changed at all. Trying to run this script gives the following:

Error in if (len%%wd != 0) errex.AFNI(paste("The content under -dataTable is not rectangular !", :
argument is of length zero
Calls: process.MVM.opts
Execution halted

OH GOSH, I actually fixed my own problem but have run into some more errors. Let me try to address this and see if I can close this. So sorry to bother you with these posts.

Edit 3:35 CST:

So I got the command to run and am now running into the following error:

Checking dataTable file:
CGRP_MVM_datatable_XLtst.txt

++Good: Table is regular and rectangular.
Read 139 items

Dimensions:
rows: 27 | columns: 4

Data summary:
Variable Detected_Type Details
Subj Subjects Num Subjects=9
sex Categorical Counts: female=9 | male=18
condition Categorical Counts: baseline=9 | cgrp=9 | vehicle=9
InputFile Data Number of InputFiles=27

++ Good: All InputFiles exist.

++ Good: All InputFiles have exactly 1 volume.

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

Loading required package: lme4
Loading required package: Matrix


Welcome to afex. For support visit: http://afex.singmann.science/

  • Functions for ANOVAs: aov_car(), aov_ez(), and aov_4()
  • Methods for calculating p-values with mixed(): 'S', 'KR', 'LRT', and 'PB'
  • 'afex_aov' and 'mixed' objects can be passed to emmeans() for follow-up tests
  • Get and set global package options with: afex_options()
  • Set sum-to-zero contrasts globally: set_sum_contrasts()
  • For example analyses see: browseVignettes("afex")

Attaching package: ‘afex’

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

lmer

Warning messages:
1: package ‘lme4’ was built under R version 4.3.3
2: In check_dep_version() : ABI version mismatch:
lme4 was built with Matrix ABI version 1
Current Matrix ABI version is 0
Please re-install lme4 from source or restore original ‘Matrix’ package
Loading required package: car
Loading required package: carData
Error in str2lang(x) : :1:8: unexpected input
1: Beta ~ “
^
Calls: as.formula -> formula -> formula.character -> str2lang
Execution halted

Is this a problem with my variables? Again, so sorry for all this.

Lauren,

Run the following commands in R:

remove.packages("Matrix")
remove.packages("lme4")
install.packages("lme4", type = "source")

See if this fixes the problem.

Gang Chen

Hey Gang,

Thanks for sticking with me on this. Running those commands in R give me this:

remove.packages("Matrix")

Removing package from ‘/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library’

(as ‘lib’ is unspecified)

remove.packages("lme4")

Removing package from ‘/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library’

(as ‘lib’ is unspecified)

install.packages("lme4", type = "source")

--- Please select a CRAN mirror for use in this session ---

Warning: dependency ‘Matrix’ is not available

trying URL 'https://mirror.las.iastate.edu/CRAN/src/contrib/lme4_1.1-35.5.tar.gz'

Content type 'application/x-gzip' length 3300116 bytes (3.1 MB)

==================================================

downloaded 3.1 MB

ERROR: dependency ‘Matrix’ is not available for package ‘lme4’

  • removing ‘/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/lme4’

The downloaded source packages are in

‘/private/var/folders/8s/0q9mzxpd4wg7sdtzbkkvf7jm0000gn/T/RtmpJy6ED1/downloaded_packages’

Warning message:

In install.packages("lme4", type = "source") :

installation of package ‘lme4’ had non-zero exit status

And running my script again gives this:

Checking dataTable file:
CGRP_MVM_datatable_XLtst.txt

++Good: Table is regular and rectangular.
Read 139 items

Dimensions:
rows: 27 | columns: 4

Data summary:
Variable Detected_Type Details
Subj Subjects Num Subjects=9
sex Categorical Counts: female=9 | male=18
condition Categorical Counts: baseline=9 | cgrp=9 | vehicle=9
InputFile Data Number of InputFiles=27

++ Good: All InputFiles exist.

++ Good: All InputFiles have exactly 1 volume.

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

+* Warning: Log file: /Users/shittyjewel/Desktop/LEVI/MVM_test/groupAnalyses/3dMVM/CGRP_MVM_results_log.txt exists! NOT OVERWRITING!!

Loading required package: lme4
Error: package ‘Matrix’ required by ‘lme4’ could not be found
In addition: Warning message:
package ‘lme4’ was built under R version 4.3.3
Execution halted

It looks like you may need to update R to the latest version and then reinstall those R packages:

rPkgsInstall -pkgs ALL

Gang Chen

Hey gang,

Took care of the R update. At least it's a new error now I guess.

Checking dataTable file:
CGRP_MVM_datatable_XLtst.txt

++Good: Table is regular and rectangular.
Read 139 items

Dimensions:
rows: 27 | columns: 4

Data summary:
Variable Detected_Type Details
Subj Subjects Num Subjects=9
sex Categorical Counts: female=9 | male=18
condition Categorical Counts: baseline=9 | cgrp=9 | vehicle=9
InputFile Data Number of InputFiles=27

++ Good: All InputFiles exist.

++ Good: All InputFiles have exactly 1 volume.

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

+* Warning: Log file: /Users/shittyjewel/Desktop/LEVI/MVM_test/groupAnalyses/3dMVM/CGRP_MVM_results_log.txt exists! NOT OVERWRITING!!

Loading required package: lme4
Loading required package: Matrix


Welcome to afex. For support visit: http://afex.singmann.science/

  • Functions for ANOVAs: aov_car(), aov_ez(), and aov_4()
  • Methods for calculating p-values with mixed(): 'S', 'KR', 'LRT', and 'PB'
  • 'afex_aov' and 'mixed' objects can be passed to emmeans() for follow-up tests
  • Get and set global package options with: afex_options()
  • Set sum-to-zero contrasts globally: set_sum_contrasts()
  • For example analyses see: browseVignettes("afex")

Attaching package: ‘afex’

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

lmer

Loading required package: car
Loading required package: carData
Error in str2lang(x) : :1:8: unexpected invalid token
1: Beta ~ “
^
Calls: as.formula -> formula -> formula.character -> str2lang
Execution halted

I suspect that the quotes in the following two lines

3dMVM ...
  -bsVars “sex” \
  -wsVars “condition” \

might have been causing the trouble. Try replacing them with the following:

3dMVM ...
  -bsVars "sex" \
  -wsVars "condition" \

Gang Chen

1 Like

Hi Gang,

I think you've solved my many problems! Thank you so much for sticking with me on this, I really appreciate your help; especially since I never would have seen that quote issue if I stared at it for hours.

Thanks! this should be closed now, i think.
lauren

Hi-

This is a pretty subtle issue.

To check scripts for bad characters (such as non-ASCII ones, like this fancy quote mascarading as a simple quote), Rick wrote a program called file_tool. It is quite helpful for seeing where these things are occurring:

file_tool -show_bad_all -infiles  SCRIPT

Usually text editors have options to turn off things like "convert quotations". Dashes can also cause subtle woe in the same way.

Copy+pasting from email or PDFs can lead to subtle character issues like this. Some macOS editors try to be particularly "helpful" and prettify text, but these changes tend to be bad for scripting.

I'm glad this was found here, but it is indeed really tricky to find sometimes.

--pt

@ptaylor,

Yeah, that was exactly the issue, I wrote the script in a mac text editor on my break and then c/p'd it over. I'm glad to know about this tool now, to hopefully avoid these issues in the future (thanks mac).

Thanks Paul and Gang!