Error while estimating ACF using 3dFWHMx

AFNI version info (20.2.16):

Dear AFNI team,

I encountered a challenge while attempting to run 3dClustSim to estimate the probability of false positive clusters. During the calculation of the ACF using 3dFWHMx, I encountered an issue with one participant. Specifically, 3dFWHMx was unable to estimate the 2nd and 3rd ACF values, displaying the error message “Calfun[1]=nan; Calfun[2]=nan” [Attached is a screenshot for your reference].

I am puzzled as to why this error occurred only for one participant. In investigating further, I performed a 3dinfo on the errts.nii file and noticed values in the thousands, despite having done intensity scaling by a factor of 100. Could this indicate an issue with my preprocessing or functional normalization?

If needed, I am more than willing to upload the errts and bucket file for your review and assistance.

Thank you for your time and support.

Best regards,

Hello Sahithyan,

Sure, if you could make a link to this data, I would be happy to take a look. Does this have anything to do with overzealous censoring, perhaps? Does this analysis include censoring? And if so, how many time points are in the dataset, and how many were censored?

Having values in the thousands is a bit surprising, assuming you have run this through, did you?


  • rick

Hi Rick,

I appreciate your willingness to address this matter, and I apologize for the delayed response.

Yes, the analysis includes censoring but only 27 volumes out of 1116 is censored, so I don’t think it’s a censoring issue.

I did not employ afni_proc specifically for this, but the preprocessing was akin to the steps taken for all other participant data. Strangely, it's only this participant's data that is causing a discrepancy during the 3dFWHMx phase.

Here is the code snippet used:

-input PCR514_M_TR_MNI_3mm_SI_censor_CueDeconvTaskMR_errts.nii.gz
-mask MNI152_T1_3mm_brain_GM_02182017.nii.gz
> PCR514_M_TR_MNI_3mm_SI_censor_CueDeconvTaskMR_errts_FWHM_ACF.1D

I've shared the 3dDeconvolve bucket file along with the errts file . Additionally, I've provided the output file after both anatomical and functional preprocessing (for feedback on potential preprocessing issues) and the GM mask used. Files

Thank you for your assistance.

Best regards,

Hi Sahithyan,

Thanks for the data. Even the input to 3dDeconvolve has values in the millions, and it is not clear what processing went into computing it. See coord -15 -48 57 , and compare time point 0 with time point 963 (or open a graph window there). Also, it looks like runs 3 and 5 are scaled above the others. This seems to have run-specific issues.

It might be good to consider running this through for comparison. Maybe something went wrong with your scaling, I can only guess.

  • rick

Hi Rick,

I ran the same participant data through, and I have uploaded the files ( AFNI_proc ) for your consideration. I still see scaling and normalization issue (can be seen in the QC_anat fig).

Do you have any idea how to correct this?


Hi, Sahithyan-

This might be side issue in the processing to consider. Are you asking about the image QC_anatSS.514.jpg specifically? I think the oddness of the mask being truncated relates to the dataset not be centered around the coordinate origin (0,0,0). Given the displayed angle of the brain, I wonder if the input to SSwarper has obliquity in it?

We generally recommend deobliquing the anatomical before processing, to fit better into the alignment stream. Also, different software will deal with obliquity in different ways, so this removes some uncertainty and potential issues.

What is the output of the following, where DSET_ANAT is your anatomical volume input to SSwarper:

3dinfo -obliquity DSET_ANAT


If the output is not zero, then it would be preferable to get rid of the obliquity in a way not to interpolate the data, while also preserving the coordinate origin (we assume that that is actually reasonably well placed, when obliquity is considered). In very recent versions of AFNI, we have a new program called adjunct_deob_around_origin. In an older version of AFNI, you can just run:

3dcopy DSET_ANAT __tmp
3drefit  oblique_recenter  __tmp+orig
3drefit  -deoblique  __tmp+orig
3dcopy __tmp+orig DSET_ANAT_NEW

... where DSET_ANAT_NEW can be whatever output name you want. If you open that new dataset up in the AFNI GUI and jump to (x,y,z,)=(0,0,0), then hopefully you will see that coordinate origin location well-centered in the brain.

Also, we have recently added an updated version of @SSwarper called sswarper2 to the distribution, and you could also try using that instead of @SSwarper on the anatomical alignment, if you want. The options and output should be the same (just more QC images output) for integrating with But this is just if you want to try that.


Hello Rick,

Upon closer examination of the data, it appears that the scaling issue arose because the participant moved out of the field of view (beyond the bounding box) during run3 and run5, resulting in values in the thousands.

Thanks for your input; they were instrumental in identifying and understanding the issue.

And to Paul Taylor,

Yes, the input to SSwarper had obliquity. Deoblique the Anat image solved the issue with QC_anatSS.514.

I'm curious if there's a method to generate these quality check images without relying on @SSwaper. If such an approach exists, could you please direct me to it?

Thank you.

Hi, Sahithyan-

Re. this question:

... which QC images are you wanting, specifically, the mask over the an anatomical dataset, and/or edge lines of one dataset over another, or something else? The QC images made during @SSwarper's run are generated by AFNI programs (notably @chauffeur_afni, @djunct_edgy_align_check and older ones by @snapshot_volreg), but I am happy to provide more detailed pointers to help tune parameters/usage.


Hi Paul,

Looking for a script to generate specifically quality check images similar to QC_anatSS and QC_anatQQ.

Those images are really helpful to quickly check if there are any issues with skullstripping and normalization.


OK, sure. You can change the ulay/olay0 names as you wish, of course, to fit your data application.

To generate QC_anatSS:

set odir = .                              # output dir
set pref = __tmp_                         # prefix of mask of anatSS
set ulay  = "${odir}/anatU.${SubID}.nii"  # underlay dataset: non-SS anat
set olay0 = "${odir}/anatSS.${SubID}.nii" # overlay dataset: SS'ed anat
set olay  = "${pref}mask.nii"             # mask created from SS'ed anat
set opref_exqc1 = "${odir}/QC_anatSS.${SubID}.jpg"   # output name of img

3dcalc                                          \
    -overwrite                                  \
    -a          ${olay0}                        \
    -expr       'bool(a)'                       \
    -prefix     ${olay}                         \
@chauffeur_afni                                 \
    -ulay                ${ulay}                \
    -ulay_range          "2%" "98%"             \
    -olay                ${olay}                \
    -func_range_perc_nz  1                      \
    -set_subbricks       0 0 0                  \
    -box_focus_slices    ${olay}                \
    -cbar                "Reds_and_Blues_Inv"   \
    -opacity             4                      \
    -prefix              "${pref}MONT1"         \
    -save_ftype          JPEG                   \
    -montx               9                      \
    -monty               1                      \
    -montgap             3                      \
    -set_xhairs          OFF                    \
    -label_mode          1                      \
    -label_size          4

2dcat                                           \
    -gap      5                                 \
    -gap_col  66 184 254                        \
    -nx       1                                 \
    -ny       3                                 \
    -prefix   "${opref_exqc1}"                  \

To generate QC_anatQQ:


set odir = .                                # output dir
set SubID = something                       # subject ID
set ulay  = "${odir}/anatQQ.${SubID}.nii"   # underlay dset, in same space as olay/Basedset
set olay  = "${Basedset}"                   # overlay dset, to be edgified
set opref_exqc2 = "${odir}/QC_anatQQ.${SubID}.jpg"  # img output name

@djunct_edgy_align_check                      \
    -montx             8                      \
    -monty             1                      \
    -ulay              "${ulay}"              \
    -olay              "${olay}"              \
    -box_focus_slices  "${olay}"              \
    -prefix            "${pref}MONT2"

2dcat                                         \
    -gap      5                               \
    -gap_col  66 184 254                      \
    -nx       1                               \
    -ny       3                               \
    -prefix   "${opref_exqc2}"                \

Please let me know if you ahve any questions.


1 Like

Thank you so much. This is very helpful !

Cool, glad that seems useful.

I have just edited the above post to have nicer vertical spacing, simply to be more readable/clear.