3dMEMA correction

Dear all,

I used 3dMEMA but I would like to correct the output.
Can I use ETAC? I am not sure if its only recommended for 3dttest++

If not, which other method should I use?

Many thanks!


Myriam, ETAC is only available in 3dttest++. You can use 3dClustSim with ACF estimated through individual level or 3dMEMA -residual_Z

Thanks your answer, Gang!

However, when I run it with -residual_Z. The following error pop up
:** option -subs_tstats has illegal dashed parameter: -residual_Z
→ maybe parameter is a mis-typed option?

This is my script:
gen_group_command.py -command 3dMEMA
-write_script cmd.mema.6
-prefix mema++.6_E-S
-dsets path/stats.bil_REML+tlrc.HEAD
-dset_index1_list ‘1,3,4,5,6,7,8,9,10,11,12,13,16,19,20,21,23,27’
-dsets path/stats.bil_REML+tlrc.HEAD
-dset_index1_list ‘1,2,3,4,5,10,11,13,15,16,20,23,30,35,36,37,44,52’
-set_labels SP EN
-subs_betas ‘TASK#0_Coef’
-subs_tstats ‘TASK#0_Tstat’

Any thoughts what should I do?

This is my afni version:Precompiled binary linux_openmp_64: Feb 10 2017 (Version AFNI_17.0.09)

Try first creating a 3dMEMA script using gen_group_command.py without -residual_Z, and then add -residual_Z to the script.

Thanks Gang! It worked!

However, I don’t understand the output. Now, I have three output files:

The first one (mema+tlrc) is still the one uncorrected. But ICC & resZ shows sub-bricks of each participant individually.

How can get the comparison between groups (b & t values) but corrected by multiple comparisons?


Half of the content in resZ is the residuals (the other half is the Z-stats for the residuals). Use 3dFWHM to estimate ACF on the residuals, and then run 3dClustSim with the ACF values to obtain the cluster threshold.

Thank you Gang!
One more question,

-Just to double-check, I run 3dFWHM. are the acf values the ones written by: vary, vary and varzz? so, in the example below will be:
varxx=0.537552 varyy=0.504485 varzz=0.308338

3dFWHM -dset mema++.6_E-S_resZ+tlrc -out E-S_FWHM

++ 3dFWHM: AFNI version=AFNI_17.0.09 (Feb 10 2017) [64-bit]
++ Authored by: B. Douglas Ward
*+ WARNING: This program is obsolete! Use 3dFWHMx instead!!
var =0.774703
varxx=0.537552 varyy=0.504485 varzz=0.308338
sx=1.531972 sy=1.593274 sz=2.122862

3dClustSim -acf 0.537552 0.504485 0.308338 -LOTS -prefix 3dClustsim_E_S

-Also, as it says the ‘This program is obsolete. Use 3dFWHMx’
I did try it too by:
3dFWHMx -dset mema++.6_E-S_resZ+tlrc -out E-S_FWHMx

However, I don’t know how which ones are the -acf values, as I thought they have to be values between 0 and 1, and the 3dFWHMx output values are between 3 and 5.

thank you for your time!

You should use 3dFWHMx with option -acf. In addition, I believe that the residual file mema++.6_E-S_resZ+tlrc contrains both the residuals and the Z-stat in an alternating order. So, you need to use only the residuals without the Z-stat part. Try something like the following:

3dFWHMx -dset mema++.6_E-S_resZ+tlrc’[0:X:(2)]’ -out E-S_FWHMx

and replace the letter ‘X’ in the above command with the last sub-brick index in the file. Let me know if it works.


So, I tried what you suggested plus adding the -acf command . But did not work (see below)
I have a total of 35 sub-bricks (see image attached)

3dFWHMx -dset mema++.6_E-S_resZ+tlrc’[0:34:(2)]’ -acf -out E-S_FWHMx
++ 3dFWHMx: AFNI version=AFNI_17.0.09 (Feb 10 2017) [64-bit]
++ Authored by: The Bob
** ERROR: selector syntax error 5 ‘:(2)]’
** ERROR: bad sub-brick selector [0:34:(2)]
** FATAL ERROR: Can’t open dataset ‘mema++.6_E-S_resZ+tlrc[0:34:(2)]’
** Program compile date = Feb 10 2017

However, I try this (see below) and it worked:

3dFWHMx -dset mema++.6_E-S_resZ+tlrc’[0…$(2)]’ -acf -out E-S_FWHMx
++ 3dFWHMx: AFNI version=AFNI_17.0.09 (Feb 10 2017) [64-bit]
++ Authored by: The Bob
*+ WARNING: removed 131033 voxels from mask because they are constant in time
++ start FWHM calculations

  • FWHM done (0.00 CPU s thus far)
    ++ start ACF calculations out to radius = 12.25 mm
  • ACF done (0.00 CPU s thus far)
    3.88083 3.95934 4.43569 4.08479
    0.747622 2.32492 9.72146 6.10881
    ++ ACF 1D file [radius ACF mixed_model gaussian_NEWmodel] written to 3dFWHMx.1D
    ++ 1dplot: AFNI version=AFNI_17.0.09 (Feb 10 2017) [64-bit]
    ++ Authored by: RWC et al.
    pnmtopng: 42 colors found
  • and 1dplot-ed to file 3dFWHMx.1D.png

So, my questions are:
-Why is not working when I write: 3dFWHMx -dset mema++.6_E-S_resZ+tlrc’[0:34:(2)]’ -acf -out E-S_FWHMx
Am I choosing the wrong sub-bricks number? (see image below)

-is this command ok? 3dFWHMx -dset mema++.6_E-S_resZ+tlrc’[0…(2)]' -acf -out E-S_FWHMx I mean, writing [0..(2)] instead of '[0:34:(2)]

-If the command above is ok, the output is a file called: 3dFWHMx.1D
I assume the values in this file are the acf values. Which ones do I need to use for 3dClustSim?
The table looks like:
0 1 1 1
2 0.721748 0.721851 0.742904
2.82843 0.541156 0.545359 0.551906
3.4641 0.417775 0.423102 0.410013
4 0.34554 0.337426 0.3046
4.47214 0.279764 0.276865 0.226289
4.89898 0.233509 0.233667 0.168111
5.65685 0.178671 0.179776 0.0927813
6 0.162576 0.162904 0.0689275
6.32456 0.15554 0.150159 0.0512065
6.63325 0.14018 0.140327 0.0380415
6.9282 0.12457 0.132567 0.0282612
7.2111 0.129147 0.126291 0.0209953
7.48331 0.118861 0.121088 0.0155975
8 0.11475 0.112838 0.00860836
8.24621 0.109159 0.109446 0.00639519
8.48528 0.111247 0.106392 0.00475101
8.7178 0.0983605 0.103604 0.00352954
8.94427 0.101126 0.101029 0.00262211
9.16515 0.0982441 0.0986284 0.00194797
9.38083 0.0904522 0.0963737 0.00144716
9.79796 0.091374 0.0922211 0.000798694
10 0.0875434 0.0902942 0.000593353
10.198 0.0892459 0.0884527 0.000440804
10.3923 0.0866942 0.0866883 0.000327475
10.7703 0.082545 0.0833654 0.000180736
10.9545 0.0827532 0.0817966 0.000134269
11.3137 0.0766195 0.0788235 7.41039e-05
11.4891 0.0783004 0.0774124 5.50521e-05
11.6619 0.0762587 0.0760476 4.08984e-05
11.8322 0.0766266 0.0747266 3.03835e-05
12 0.0749448 0.073447 2.25721e-05
12.1655 0.0792722 0.0722067 1.67688e-05

many many thanks!

Screen Shot 2017-10-23 at 9.34.32 AM.png

My bad! My memory cheated me… Sorry about this!

3dMEMA currently does not provide any output for the residuals, but the Z-stat for the residuals. So, I recommend that you estimate the ACF by using the residuals from the individual level.

Hi Chang,

What do you mean by ‘estimate the ACF by using the residuals from the individual level’?
How should I do that?


Hi Gang,

Do you mean I should not specify the residuals on the file. So instead of, 3dFWHMx -dset mema++.6_E-S_resZ+tlrc’[0:X:(2)]’ -out E-S_FWHMx

Should be:

3dFWHMx -dset mema++.6_E-S_resZ+tlrc -acf -out E-S_FWHMx



Since the residuals at the group level currently cannot be obtained through from 3dMEMA (the option -residual_Z only provides the Z-stat for the residuals), I was suggesting that you estimate the ACF using the residuals from the individual subject analysis from 3dDeconvolve or 3dREMLfit. Specifically, when you perform individual subject analysis, there is an option -errts in 3dDeconvolve that provides the residuals for each subject. Then you run 3dFWHMx with the output from the option -errts in 3dDeconvolve, and the ACF estimates should not vary too much across subjects. You can use the average ACF values to get the cluster thresholds with 3dClustSim. Does this make sense?

Great, Gang! My very last question…

Actually, double checking and correct me if I am wrong, the afni_proc.py provides the ACF values on the blur.errts.1D file, right?
Something like:
3.88582 4.19455 5.32402 4.42727 # epits FWHM blur estimates
0.831582 2.56576 7.90266 6.34748 # epits ACF blur estimates
3.84754 4.1605 5.35565 4.40941 # errts FWHM blur estimates
0.82605 2.54857 7.59102 6.30045 # errts ACF blur estimates
3.83204 4.14254 5.32463 4.38863 # err_reml FWHM blur estimates
0.824958 2.54073 7.48632 6.27801 # err_reml ACF blur estimates

So, I will have to copy the “errts ACF blur estimates” row (0.82605 2.54857 7.59102) onto the 3dClustSim, is this correct?

Can I use the ACF values for 1 participant only, or should I do the average of all participants?
If needs the average, is there any ‘quickly’ way to get the average?

Thank you for your patience!!

I will have to copy the “errts ACF blur estimates” row (0.82605 2.54857 7.59102) onto the 3dClustSim, is this correct?


Can I use the ACF values for 1 participant only, or should I do the average of all participants?
If needs the average, is there any ‘quickly’ way to get the average?

Use the average across the subjects since it is a little more reliable.

thank you soooo much!


Thanks for the command.(tu) I will go through the document of the 3dMEMA and test it on my data first.