Contrast of one condition versus average of rest - with afni_proc.py gltsym in regress block

Hi there,

I am running a regression using afni_proc.py.

I want to contrast one condition against the average of the others. I have put this in as I think it should go using the general linear tests in the regression block (gltsym), but wondered if anyone could confirm I have entered this correctly. I had a read of various other posts on the forum, but could not find a similar question.

Thank you for your help,

H


AFNI version info (afni -ver):
Precompiled binary linux_ubuntu_24_64: Oct 1 2024 (Version AFNI_24.3.00 'Elagabalus')

#!/bin/tcsh

# Set up participant details
set sub = sub-TS
set ses = ses-01

# Set up directories
set base_dir = $pwd
set script_dir = $base_dir/scripts
set data_base_dir = $base_dir/data/$sub/$ses

# Set up files
set extension = .nii.gz
set anat_raw_dir = $data_base_dir/anat
set anat_raw = ${sub}_acq-MP2RAGE_T1w

set anat_ss_dir = $base_dir/derivatives/hdbet/$sub/$ses
set anat_ss = ${anat_raw}_SS

set data_dir = $data_base_dir/func
set data_base = ${sub}_acq-BodyLoc_HIRF

set blip_rev_base = ${sub}_acq-BodyLoc_PA_HIRF

set surf_dir = $base_dir/derivatives/FastSurfer/output/${sub}_${ses}/SUMA
set surf_anat = ${sub}_${ses}_SurfVol.nii
set surf_spec = ${sub}_${ses}_lh.spec

# Get stimulus timing file names
set stimuli_loc = $base_dir/stimuli/$sub/$ses
cd $stimuli_loc

set stim1_la = BodyLoc_${sub}_${ses}_*_ONSETSFIX_leftarm.txt
set stim2_lf = BodyLoc_${sub}_${ses}_*_ONSETSFIX_leftfoot.txt
set stim3_lh = BodyLoc_${sub}_${ses}_*_ONSETSFIX_lefthand.txt
set stim4_l = BodyLoc_${sub}_${ses}_*_ONSETSFIX_lips.txt
set stim5_ra = BodyLoc_${sub}_${ses}_*_ONSETSFIX_rightarm.txt
set stim6_rf = BodyLoc_${sub}_${ses}_*_ONSETSFIX_rightfoot.txt
set stim7_rh = BodyLoc_${sub}_${ses}_*_ONSETSFIX_righthand.txt

cd $script_dir

# Set blur
set blur_size = 3


# Script
afni_proc.py \
	-subj_id					${sub}_${ses}														\
	-dsets						$data_dir/${data_base}${extension}									\
	-blip_forward_dset 			$data_dir/${data_base}${extension}'[194..204]'						\
	-blip_reverse_dset			$data_dir/${blip_rev_base}${extension}								\
	-blocks						tcat despike align volreg surf blur scale regress					\
	-copy_anat					$anat_ss_dir/${anat_ss}${extension}									\
	-anat_has_skull				no																	\
	-anat_follower				orig_anat_w_skull anat $anat_raw_dir/${anat_raw}${extension}		\
	-surf_anat					$surf_dir/$surf_anat												\
	-surf_spec					$surf_dir/$surf_spec												\
	-tcat_remove_first_trs		0																	\
	-align_opts_aea				-giant_move															\
								-partial_coverage													\
								-cost lpc															\
	-align_unifize_epi			local																\
	-volreg_align_e2a																				\
	-volreg_align_to			MIN_OUTLIER															\
	-volreg_post_vr_allin 		yes																	\
	-volreg_pvra_base_index 	MIN_OUTLIER															\
	-volreg_interp 				-Fourier															\
	-volreg_warp_final_interp 	wsinc5																\
	-volreg_compute_tsnr		yes																	\
	-blur_size					$blur_size															\
	-regress_stim_times 																			\
								$stimuli_loc/$stim1_la												\
								$stimuli_loc/$stim2_lf												\
								$stimuli_loc/$stim3_lh												\
								$stimuli_loc/$stim4_l												\
								$stimuli_loc/$stim5_ra												\
								$stimuli_loc/$stim6_rf												\
								$stimuli_loc/$stim7_rh												\
	-regress_stim_labels		leftarm																\
								leftfoot															\
								lefthand															\
								lips																\
								rightarm															\
								rightfoot															\
								righthand															\
	-regress_basis				'BLOCK(9.9,1)'														\
	-regress_opts_3dD			-gltsym 'SYM: leftarm-((leftfoot+lefthand+lips+rightarm+rightfoot+righthand)/6)'	\
								-glt_label 1 leftarm-others															\
								-gltsym 'SYM: leftfoot-((leftarm+lefthand+lips+rightarm+rightfoot+righthand)/6)'	\
								-glt_label 2 leftfoot-others														\
								-gltsym 'SYM: lefthand-((leftarm+leftfoot+lips+rightarm+rightfoot+righthand)/6)'	\
								-glt_label 3 lefthand-others														\
								-gltsym 'SYM: lips-((leftarm+leftfoot+lefthand+rightarm+rightfoot+righthand)/6)'	\
								-glt_label 4 lips-others															\
								-gltsym 'SYM: rightarm-((leftarm+leftfoot+lefthand+lips+rightfoot+righthand)/6)'	\
								-glt_label 5 rightarm-others														\
								-gltsym 'SYM: rightfoot-((leftarm+leftfoot+lefthand+lips+rightarm+righthand)/6)'	\
								-glt_label 6 rightfoot-others														\
								-gltsym 'SYM: righthand-((leftarm+leftfoot+lefthand+lips+rightarm+rightfoot)/6)'	\
								-glt_label 7 righthand-others														\
	-regress_censor_motion		0.3																	\
	-regress_censor_outliers	0.05																\
	-regress_make_ideal_sum		sum_ideal.1D														\
	-html_review_style			basic

Hi H,
The -gltsym parsing is not quite as intelligent as 3dcalc, say. You would need to expand it, writing something like:

-gltsym 'SYM: leftarm -0.16667*leftfoot -0.16667*lefthand -0.16667*lips -0.16667*rightarm -0.16667*rightfoot -0.16667*righthand'

See DeconSummer2004.html for details.

-rick

Hi Rick,

Thanks for getting back, and for the solution!

Follow up question: Before you wrote back, I had managed to get something I thought might be the solution
-gltsym 'SYM: 6*leftarm -leftfoot -lefthand -tongue -rightelbow -rightfoot -righthand'

I believe my solution and yours provide orthogonal contrasts (weights summing to 0). Is there a mathematical difference between your version and mine? I read somewhere that doing it my way might scale or weight the variable with the 6 higher? Which I would not want to do, but I am not sure if this is the case.

Thanks again!

They are just scaled versions of each other, where yours results would be 6 times mine, since the GLTs are just weighted sums of betas. In your case the contrast is 6 times leftarm vs the sum of other betas, while mine is leftarm vs the mean of other betas. The t- and F-stats would be the same for each, though the results would be scaled.

Either way is really okay. We tend to balance any diff mean at zero, and also balance the signed weights at 1. That keeps the magnitudes of the GLT results consistent.

  • rick

Thank you!