QC recommendations after running fMRIPrep + partial afni_proc.py (mask/scale/regress only)

Hi AFNI Gurus,

I’m hoping to get some guidance on best practices for QC at a slightly nonstandard point in my pipeline.

Pipeline overview

I ran fMRIPrep for initial preprocessing and QC, using it for what I understand to be the functional equivalents of the following afni_proc.py blocks:

  • tcat
  • tshift
  • volreg
  • blur
  • align
  • despike
  • tlrc

After that, I ran afni_proc.py only for the final stages, specifically using just the following blocks:

  • mask
  • scale
  • regress

Because I only ran these later blocks in afni_proc.py, the usual QC HTML and driver scripts were not generated automatically.

I’d now like to do appropriate QC on the outputs from afni_proc.py at this stage and wanted to check whether the steps I’m planning are sufficient, or whether there are additional QC checks you’d recommend.


My current QC plan

Since I don’t have the auto-generated QC HTML, I’m planning to manually review the following:

1. General warnings / failures

  • output.proc.s##
    Read through the main script output log and search for any WARNING or FAILURE flags.

2. Alignment

  • out.mask_ae_overlap.txt
    Review EPI–anat alignment via overlap between EPI and anat brain masks.
    Check the %(A \ B) value and confirm it is not excessively large.

3. Regression and correlation warnings

  • out.df_info.txt
    Check degrees of freedom (flag unusually low df).
  • 3dREMLfit.err
    Note any warnings or errors.
  • out.cormat_warn.txt
    Look for warnings about high correlations between any pair of regressors in the main regression matrix, including baseline terms.

4. Non-baseline regression matrix

  • Plot X.stim.xmat.1D and check that it matches my design.

5. Statistical results

  • In AFNI GUI, inspect bricks for:
    • Each condition vs baseline
    • Each contrast
  • Check that:
    • Nothing looks obviously wrong
    • Results are broadly similar to other subjects
    • There are clear activations in task-relevant sensory modalities (e.g., visual) and response-related regions (e.g., motor cortex)

Question

At this stage—after fMRIPrep preprocessing and a limited afni_proc.py run focused on mask/scale/regress—are there additional QC steps you would recommend?

Thanks very much for any guidance.

Best,
Lauren

Hi, Lauren-

Well, the QC items in afni_proc.py's HTML have all been developed and tested over time, so our recommendation would be check all of those things.

A couple of points:

  • The APQC HTML framework has also been setup to allow for opening up multiple subjects' results in separate tabs, and making each page jump to the same spot, so you can use Ctrl+Tab and Ctrl+Shift+Tab to check the same image montages quickly across all subjects---that kind of systematic data visualization is really, really helpful to see important patterns, differences and similarities.
  • The QC HTML is also made to be able to save comments/notes/ratings directly, which are instantly saved in the page and can be shared. That is very convenient for remembering what you noticed over time, sharing it with your lab, and even other folks.

To the items you listed:

The things you have listed are definitely useful parts of these. For reference, QC examples are also noted here and here.

Re alignment: Looking at alignment will really be best done by looking at the overlay/underlay directly, not just on a derived quantitity of overlap; that image also tells you about signal strength/dropout, EPI distortion and FOV coverage (in the EPI-anatomical case). Checking left-right flipping has also been surprisingly useful.

TSNR is also something we check (in the "regr" APQC block), to make sure you have adequate signal strength in regions you care about. The APQC HTML will estimate an automatic table of regions, reporting on signal strength in a small set of regions around the brain, to help you have a sense of where signals might be too weak to trust. Importantly, when you run afni_proc.py, you can load in your own atlases/region maps, and select your own ROIs of importance, and get that table for your study's important regions. This is helpful even if doing a voxelwise study, because again you get a sense of where data might exist but not be reliable.

There is the corr_brain dataset and the local radial correlation map datasets, and these provide checks for where artifacts might be, whether due to motion or scanner weirdness.

Running InstaCorr is something that I consider to be perhaps the most important QC check on data, personally. In the APQC HTML, there is a button above several images to fire it up; perhaps the output APQC HTML from the limited-block run still has that?

Looking at the raw data itself (the "vorig" APQC block) is helpful, to get a sense of distortion, ghosting, FOV, dropout or other odd things that might be happening.

In the "mot" block of the APQC, we check for whether censoring might have preferentially/problematically removed time points during a particular stimulus class. That is useful to know, esp. if one might be more prone to inspiring subject motion, say.

Re. the stats modeling, I thought those images would be created still? Is that not the case? What version of AFNI are you running?

Separate from the APQC HTML, it would probably be quite good to run gen_ss_review_table.py, to automatically check through various quantities that afni_proc.py saves up in out.ss_review*txt as useful to know. See Sec. 2.4 here. You can compare quantities for consistency, being above/below a threshold, being outliers compared to other subjects, etc.

--pt

Thanks so much, Paul! To clarify - I have done significant QC already based on the HTML report generated by fMRIprep, and only used afni for the mask, scale, regress block. Because of this the APQC HTML, QC HTML reports and gen_ss_review scripts were not generated (that I can tell) in the subject folders.

Hi, Lauren-

OK. What version of AFNI are you using? I thought at least some features, esp. from regression would be automatically generated in an HTML still.

--pt

The APQC report should be generated with just a few key options (aside from everything else that you ask for). Consider this portion:

 afni_proc.py                                                        \
     -subj_id                  sub-000                              \
     -blocks                   mask scale regress                   \
     -radial_correlate_blocks  tcat regress                         \
     -copy_anat                data/anat_final.sub-000.affine+tlrc  \
     -dsets                    data/pb02.sub-000.affine.r0*D        \
     -regress_motion_file      data/dfile_rall.1D                   \
    ... \
     -regress_censor_motion    0.3                                  \
     -regress_censor_outliers  0.05                                 \

My guess is that you might be missing either -copy_anat or -regress_motion_file.

Might that be the case?

-rick

Thank you both! I'm running off a institutional cluster that has AFNI version=AFNI_24.0.01 (Jan 11 2024). Here is my afniproc.py script:

    afni_proc.py -subj_id s{$subj}                                    					    \
         -script proc.s{$subj}						  										\
	  	 -scr_overwrite                                     								\
#	 -execute							     												\
	 -out_dir $top_dir/{$subj}_afni_proc_fmriprep_wm_csf_3cond								\
     -blocks mask scale regress           														\
     -copy_anat "$anat_dir/sub-${subj}_ses-2_space-MNI152NLin6Asym_res-2_desc-preproc_T1w_brain.nii.gz" \
	 -anat_has_skull no																		\
     -dsets $epi_dir/notme1/denoised_func_data_nonaggr.nii.gz            	                \
    	   $epi_dir/notme2/denoised_func_data_nonaggr.nii.gz         	                    \
    	   $epi_dir/notme3/denoised_func_data_nonaggr.nii.gz         	                    \
     -tcat_remove_first_trs 0                                         						\
	 -mask_epi_anat yes						    											\
	 -regress_stim_times_offset $stim_offset												\
     -regress_stim_times $stim_dir/s{$subj}_*Female_times.1D           					    \
     -regress_stim_labels Famous_Female_times Other_Female_times Self_Female_times   		\
     -regress_basis 'BLOCK(23.6,1)'                   					                    \
	 -regress_make_cbucket yes					    										\
	 -regress_extra_ortvec /data/ddtrp/TP2/Nuisance_Reg_WM_CSF/{$subj}_csf_notme_all.1D		\
	 					   /data/ddtrp/TP2/Nuisance_Reg_WM_CSF/{$subj}_wm_notme_all.1D		\
	 -regress_extra_ortvec_labels CSF WM													\
	 -regress_3dD_stop						      											\
     -regress_reml_exec                                                    					\
     -regress_opts_3dD						      											\
	    -jobs 2							      												\
	    -bout                                                	      						\
	    -num_glt 3							      											\
            -gltsym 'SYM: Self_Female_times -Other_Female_times'	      					\
		-glt_label 1 Self_F-Other_F            			      								\
            -gltsym 'SYM: Self_Female_times -Famous_Female_times'             				\
		-glt_label 2 Self_F-Famous_F           			      								\
            -gltsym 'SYM: Famous_Female_times -Other_Female_times'	      					\
		-glt_label 3 Famous_F-Other_F			              								\
    -regress_compute_fitts                                                					\
    -regress_est_blur_errts						      										\
	-regress_local_times
end

This is a list of the files generated for one subject:

-rw-rw-r-- 1 llebois ddtrp        848 Aug 13 17:08 3dClustSim.ACF.cmd
-rw-rw-r-- 1 llebois ddtrp        618 Aug 13 16:12 3dREMLfit.err
-rw-rw-r-- 1 llebois ddtrp   50547224 Aug 13 16:11 all_betas.sNTD170_REML+tlrc.BRIK
-rw-rw-r-- 1 llebois ddtrp       4105 Aug 13 16:11 all_betas.sNTD170_REML+tlrc.HEAD
-rw-rw-r-- 1 llebois ddtrp 1072323252 Aug 13 16:13 all_runs.sNTD170+tlrc.BRIK
-rw-rw-r-- 1 llebois ddtrp      22767 Aug 13 16:12 all_runs.sNTD170+tlrc.HEAD
-rw-rw-r-- 1 llebois ddtrp        488 Aug 13 16:18 blur.err_reml.1D
-rw-rw-r-- 1 llebois ddtrp        106 Aug 13 16:18 blur_est.sNTD170.1D
-rw-rw-r-- 1 llebois ddtrp    3610516 Aug 13 16:15 corr_brain+tlrc.BRIK
-rw-rw-r-- 1 llebois ddtrp       2303 Aug 13 16:15 corr_brain+tlrc.HEAD
-rwxr-xr-x 1 llebois ddtrp       2403 Aug 13 17:11 @epi_review.sNTD170
-rw-rw-r-- 1 llebois ddtrp 1072323252 Aug 13 16:12 errts.sNTD170_REML+tlrc.BRIK
-rw-rw-r-- 1 llebois ddtrp      23936 Aug 13 16:11 errts.sNTD170_REML+tlrc.HEAD
drwxrwsr-x 2 llebois ddtrp          8 Aug 13 16:18 files_ACF
drwxrwsr-x 2 llebois ddtrp         21 Aug 13 17:08 files_ClustSim
-rw-rw-r-- 1 llebois ddtrp 1072323252 Aug 13 16:15 fitts.sNTD170_REML+tlrc.BRIK
-rw-rw-r-- 1 llebois ddtrp      25165 Aug 13 16:15 fitts.sNTD170_REML+tlrc.HEAD
-rw-rw-r-- 1 llebois ddtrp     902629 Aug 13 16:08 full_mask.sNTD170+tlrc.BRIK
-rw-rw-r-- 1 llebois ddtrp       2625 Aug 13 16:08 full_mask.sNTD170+tlrc.HEAD
-rw-rw-r-- 1 llebois ddtrp       1278 Aug 13 16:15 ideal_Famous_Female_times.1D
-rw-rw-r-- 1 llebois ddtrp       1268 Aug 13 16:15 ideal_Other_Female_times.1D
-rw-rw-r-- 1 llebois ddtrp       1292 Aug 13 16:15 ideal_Self_Female_times.1D
-rw-rw-r-- 1 llebois ddtrp     902629 Aug 13 16:08 mask_anat.sNTD170+tlrc.BRIK
-rw-rw-r-- 1 llebois ddtrp       3035 Aug 13 16:08 mask_anat.sNTD170+tlrc.HEAD
-rw-rw-r-- 1 llebois ddtrp     902629 Aug 13 16:08 mask_epi_anat.sNTD170+tlrc.BRIK
-rw-rw-r-- 1 llebois ddtrp       2808 Aug 13 16:08 mask_epi_anat.sNTD170+tlrc.HEAD
-rw-rw-r-- 1 llebois ddtrp       2986 Aug 13 16:15 mean.errts.1D
-rw-rw-r-- 1 llebois ddtrp       3252 Aug 13 16:15 mean.errts.unit.1D
-rw-rw-r-- 1 llebois ddtrp        295 Aug 13 17:11 out.ap_uvars.json
-rw-rw-r-- 1 llebois ddtrp        233 Aug 13 17:11 out.ap_uvars.txt
-rw-rw-r-- 1 llebois ddtrp         55 Aug 13 16:09 out.cormat_warn.txt
-rw-rw-r-- 1 llebois ddtrp        792 Aug 13 16:08 outcount.r01.1D
-rw-rw-r-- 1 llebois ddtrp        792 Aug 13 16:08 outcount.r02.1D
-rw-rw-r-- 1 llebois ddtrp        792 Aug 13 16:08 outcount.r03.1D
-rw-rw-r-- 1 llebois ddtrp       2376 Aug 13 16:08 outcount_rall.1D
-rw-rw-r-- 1 llebois ddtrp        356 Aug 13 16:09 out.df_info.txt
-rw-rw-r-- 1 llebois ddtrp         11 Aug 13 16:15 out.gcor.1D
-rw-rw-r-- 1 llebois ddtrp         10 Aug 13 16:08 out.mask_ae_dice.txt
-rw-rw-r-- 1 llebois ddtrp        394 Aug 13 16:08 out.mask_ae_overlap.txt
-rw-rw-r-- 1 llebois ddtrp          0 Aug 13 16:07 out.pre_ss_warn.txt
-rw-rw-r-- 1 llebois ddtrp      40902 Aug 13 16:07 out.vlines.pb00.tcat.txt
-rw-rw-r-- 1 llebois ddtrp  357441084 Aug 13 16:05 pb00.sNTD170.r01.tcat+tlrc.BRIK
-rw-rw-r-- 1 llebois ddtrp       9253 Aug 13 16:04 pb00.sNTD170.r01.tcat+tlrc.HEAD
-rw-rw-r-- 1 llebois ddtrp  357441084 Aug 13 16:05 pb00.sNTD170.r02.tcat+tlrc.BRIK
-rw-rw-r-- 1 llebois ddtrp       9253 Aug 13 16:05 pb00.sNTD170.r02.tcat+tlrc.HEAD
-rw-rw-r-- 1 llebois ddtrp  357441084 Aug 13 16:06 pb00.sNTD170.r03.tcat+tlrc.BRIK
-rw-rw-r-- 1 llebois ddtrp       9253 Aug 13 16:05 pb00.sNTD170.r03.tcat+tlrc.HEAD
-rw-rw-r-- 1 llebois ddtrp  357441084 Aug 13 16:08 pb01.sNTD170.r01.scale+tlrc.BRIK
-rw-rw-r-- 1 llebois ddtrp      10547 Aug 13 16:08 pb01.sNTD170.r01.scale+tlrc.HEAD
-rw-rw-r-- 1 llebois ddtrp  357441084 Aug 13 16:08 pb01.sNTD170.r02.scale+tlrc.BRIK
-rw-rw-r-- 1 llebois ddtrp      10547 Aug 13 16:08 pb01.sNTD170.r02.scale+tlrc.HEAD
-rw-rw-r-- 1 llebois ddtrp  357441084 Aug 13 16:09 pb01.sNTD170.r03.scale+tlrc.BRIK
-rw-rw-r-- 1 llebois ddtrp      10547 Aug 13 16:09 pb01.sNTD170.r03.scale+tlrc.HEAD
drwxrwsr-x 2 llebois ddtrp         10 Aug 13 17:11 radcor.pb02.regress
-rw-rw-r-- 1 llebois ddtrp   10831548 Sep  8 10:09 sNTD170_3dD_fem_cond_betas+tlrc.BRIK
-rw-rw-r-- 1 llebois ddtrp       3627 Sep  8 10:09 sNTD170_3dD_fem_cond_betas+tlrc.HEAD
-rw-rw-r-- 1 llebois ddtrp       1250 Aug 13 16:09 stats.REML_cmd
-rw-rw-r-- 1 llebois ddtrp   68599804 Aug 13 16:12 stats.sNTD170_REML+tlrc.BRIK
-rw-rw-r-- 1 llebois ddtrp      73932 Aug 13 17:08 stats.sNTD170_REML+tlrc.HEAD
-rw-rw-r-- 1 llebois ddtrp   21663096 Aug 13 16:11 stats.sNTD170_REMLvar+tlrc.BRIK
-rw-rw-r-- 1 llebois ddtrp       3887 Aug 13 16:11 stats.sNTD170_REMLvar+tlrc.HEAD
drwxrwsr-x 2 llebois ddtrp          7 Aug 13 16:04 stimuli
-rw-rw-r-- 1 llebois ddtrp    1805258 Aug 13 16:04 sub-NTD170_ses-2_space-MNI152NLin6Asym_res-2_desc-preproc_T1w_brain+tlrc.BRIK
-rw-rw-r-- 1 llebois ddtrp       2515 Aug 13 16:04 sub-NTD170_ses-2_space-MNI152NLin6Asym_res-2_desc-preproc_T1w_brain+tlrc.HEAD
-rw-rw-r-- 1 llebois ddtrp       2764 Aug 13 16:15 sum_ideal.1D
-rw-rw-r-- 1 llebois ddtrp    3610516 Aug 13 16:14 TSNR.sNTD170+tlrc.BRIK
-rw-rw-r-- 1 llebois ddtrp       4501 Aug 13 16:14 TSNR.sNTD170+tlrc.HEAD
drwxrwsr-x 2 llebois ddtrp         25 Aug 13 16:07 vlines.pb00.tcat
-rw-rw-r-- 1 llebois ddtrp     325392 Aug 13 16:09 X.jpg
-rw-rw-r-- 1 llebois ddtrp       4059 Aug 13 16:15 X.stim.xmat.1D
-rw-rw-r-- 1 llebois ddtrp      32930 Aug 13 16:09 X.xmat.1D

Best,
Lauren

Hi, Lauren-

OK. We did put in updates for generating the APQC HTML if someone uses fMRIprep and then afni_proc.py, from AFNI ver 25.0.04.

What was happening in earlier versions is that several fields weren't known in the JSON dictionary that stores important files and information from processing (which is the seed of the APQC HTML), and so the generating program crashed early on. We added more backups and escapes to allow for those cases with more missing items. It still won't be as complete as if the full processing were done in AP, but more items are there---what might be most useful to use is the stats ones, which I think should be present.

One option that people use on clusters to be able to control/update their AFNI version is to put a local copy of AFNI binaries in their home directory branch somewhere, and then put that location at the start of their shell path. It doesn't require admin/sudo passwords, and you can always undo it and/or update your local AFNI copy. And the dependencies needed to run AFNI should already be present.

If that sounds useful (for this, or for other processing), what kind of operating system is that?

--pt

Thank you - I was able to access a newer version of afni on the cluster - all set there.

OK, great. So then I think you should be able to generate an APQC HTML for the current results directory, as a test. If you go to the AP results directory and run the following (where the argument for the second command is the name of what should be the single QC directory, assuming there aren't any other backup ones; more generally, it is just QC_${subj}, containing the subject ID):

apqc_make_tcsh.py -run
apqc_make_html.py -qc_dir QC_*

Then, you should be able to run:

open_apqc.py -infiles QC_*/index.html

... and open the QC HTML.

I suspect it might still be better to rerun AP with the more recent version of AFNI, because probably a few QC items have been added since then that require earlier processing steps.

It would be great to know how it goes, though, generating a QC HTML at this point.

thanks,
pt

Hi Paul,

I reran afni_proc.py with this version of afni:

afni -ver

Precompiled binary linux_ubuntu_16_64_glw_local_shared: Nov 19 2025 (Version AFNI_25.3.00 'Gordian II')

My subject directory now contains this:

-rw-rw---- 1 llebois ddtrp        848 Jan 11 18:12 3dClustSim.ACF.cmd
-rw-rw---- 1 llebois ddtrp        826 Jan 11 17:17 3dREMLfit.err
-rw-rw---- 1 llebois ddtrp   61378772 Jan 11 17:17 all_betas.sNTD009_REML+tlrc.BRIK
-rw-rw---- 1 llebois ddtrp       4638 Jan 11 17:17 all_betas.sNTD009_REML+tlrc.HEAD
-rw-rw---- 1 llebois ddtrp 1072323252 Jan 11 17:17 all_runs.sNTD009+tlrc.BRIK
-rw-rw---- 1 llebois ddtrp      22787 Jan 11 17:17 all_runs.sNTD009+tlrc.HEAD
-rw-rw---- 1 llebois ddtrp        490 Jan 11 17:21 blur.err_reml.1D
-rw-rw---- 1 llebois ddtrp        106 Jan 11 17:21 blur_est.sNTD009.1D
-rw-rw---- 1 llebois ddtrp    3610516 Jan 11 17:17 corr_brain+tlrc.BRIK
-rw-rw---- 1 llebois ddtrp       2323 Jan 11 17:17 corr_brain+tlrc.HEAD
-rwxr-xr-x 1 llebois ddtrp       2403 Jan 11 18:14 @epi_review.sNTD009
-rw-rw---- 1 llebois ddtrp 1072323252 Jan 11 17:17 errts.sNTD009_REML+tlrc.BRIK
-rw-rw---- 1 llebois ddtrp      24268 Jan 11 17:17 errts.sNTD009_REML+tlrc.HEAD
drwxrws--- 2 llebois ddtrp          8 Jan 11 17:21 files_ACF
drwxrws--- 2 llebois ddtrp         21 Jan 11 18:12 files_ClustSim
-rw-rw---- 1 llebois ddtrp 1072323252 Jan 11 17:17 fitts.sNTD009_REML+tlrc.BRIK
-rw-rw---- 1 llebois ddtrp      25537 Jan 11 17:17 fitts.sNTD009_REML+tlrc.HEAD
-rw-rw---- 1 llebois ddtrp     902629 Jan 11 17:14 full_mask.sNTD009+tlrc.BRIK
-rw-rw---- 1 llebois ddtrp       2684 Jan 11 17:14 full_mask.sNTD009+tlrc.HEAD
drwxrws--- 2 llebois ddtrp         33 Jan 11 17:12 gtkyd
-rw-rw---- 1 llebois ddtrp        675 Jan 11 17:12 gtkyd.xls
-rw-rw---- 1 llebois ddtrp        925 Jan 11 17:17 ideal_Famous_Female_times.1D
-rw-rw---- 1 llebois ddtrp        957 Jan 11 17:17 ideal_Famous_Male_times.1D
-rw-rw---- 1 llebois ddtrp        955 Jan 11 17:17 ideal_Other_Female_times.1D
-rw-rw---- 1 llebois ddtrp        934 Jan 11 17:17 ideal_Other_Male_times.1D
-rw-rw---- 1 llebois ddtrp        929 Jan 11 17:17 ideal_Self_Female_times.1D
-rw-rw---- 1 llebois ddtrp        929 Jan 11 17:17 ideal_Self_Male_times.1D
-rw-rw---- 1 llebois ddtrp     902629 Jan 11 17:14 mask_anat.sNTD009+tlrc.BRIK
-rw-rw---- 1 llebois ddtrp       3094 Jan 11 17:14 mask_anat.sNTD009+tlrc.HEAD
-rw-rw---- 1 llebois ddtrp     902629 Jan 11 17:14 mask_epi_anat.sNTD009+tlrc.BRIK
-rw-rw---- 1 llebois ddtrp       2887 Jan 11 17:14 mask_epi_anat.sNTD009+tlrc.HEAD
-rw-rw---- 1 llebois ddtrp       3016 Jan 11 17:17 mean.errts.1D
-rw-rw---- 1 llebois ddtrp       3314 Jan 11 17:17 mean.errts.unit.1D
-rw-rw---- 1 llebois ddtrp        483 Jan 11 17:14 out.4095_all.txt
-rw-rw---- 1 llebois ddtrp          0 Jan 11 17:14 out.4095_warn.txt
-rw-rw---- 1 llebois ddtrp        354 Jan 11 18:14 out.ap_uvars.json
-rw-rw---- 1 llebois ddtrp        286 Jan 11 18:14 out.ap_uvars.txt
-rw-rw---- 1 llebois ddtrp         55 Jan 11 17:14 out.cormat_warn.txt
-rw-rw---- 1 llebois ddtrp        792 Jan 11 17:14 outcount.r01.1D
-rw-rw---- 1 llebois ddtrp        792 Jan 11 17:14 outcount.r02.1D
-rw-rw---- 1 llebois ddtrp        792 Jan 11 17:14 outcount.r03.1D
-rw-rw---- 1 llebois ddtrp       2376 Jan 11 17:14 outcount_rall.1D
-rw-rw---- 1 llebois ddtrp        356 Jan 11 17:14 out.df_info.txt
-rw-rw---- 1 llebois ddtrp         11 Jan 11 17:17 out.gcor.1D
-rw-rw---- 1 llebois ddtrp         31 Jan 11 17:12 out.gtkyd.outliers.txt
-rw-rw---- 1 llebois ddtrp         10 Jan 11 17:14 out.mask_ae_dice.txt
-rw-rw---- 1 llebois ddtrp        394 Jan 11 17:14 out.mask_ae_overlap.txt
-rw-rw---- 1 llebois ddtrp          0 Jan 11 17:14 out.pre_ss_warn.txt
-rw-rw---- 1 llebois ddtrp      44473 Jan 11 17:14 out.vlines.pb00.tcat.txt
-rw-rw---- 1 llebois ddtrp  357441084 Jan 11 17:12 pb00.sNTD009.r01.tcat+tlrc.BRIK
-rw-rw---- 1 llebois ddtrp       9272 Jan 11 17:12 pb00.sNTD009.r01.tcat+tlrc.HEAD
-rw-rw---- 1 llebois ddtrp  357441084 Jan 11 17:12 pb00.sNTD009.r02.tcat+tlrc.BRIK
-rw-rw---- 1 llebois ddtrp       9272 Jan 11 17:12 pb00.sNTD009.r02.tcat+tlrc.HEAD
-rw-rw---- 1 llebois ddtrp  357441084 Jan 11 17:12 pb00.sNTD009.r03.tcat+tlrc.BRIK
-rw-rw---- 1 llebois ddtrp       9272 Jan 11 17:12 pb00.sNTD009.r03.tcat+tlrc.HEAD
-rw-rw---- 1 llebois ddtrp  357441084 Jan 11 17:14 pb01.sNTD009.r01.scale+tlrc.BRIK
-rw-rw---- 1 llebois ddtrp      10625 Jan 11 17:14 pb01.sNTD009.r01.scale+tlrc.HEAD
-rw-rw---- 1 llebois ddtrp  357441084 Jan 11 17:14 pb01.sNTD009.r02.scale+tlrc.BRIK
-rw-rw---- 1 llebois ddtrp      10625 Jan 11 17:14 pb01.sNTD009.r02.scale+tlrc.HEAD
-rw-rw---- 1 llebois ddtrp  357441084 Jan 11 17:14 pb01.sNTD009.r03.scale+tlrc.BRIK
-rw-rw---- 1 llebois ddtrp      10625 Jan 11 17:14 pb01.sNTD009.r03.scale+tlrc.HEAD
drwxrws--- 2 llebois ddtrp         10 Jan 11 18:14 radcor.pb02.regress
-rw-rw---- 1 llebois ddtrp       1562 Jan 11 17:14 stats.REML_cmd
-rw-rw---- 1 llebois ddtrp  101094448 Jan 11 17:17 stats.sNTD009_REML+tlrc.BRIK
-rw-rw---- 1 llebois ddtrp      84885 Jan 11 18:12 stats.sNTD009_REML+tlrc.HEAD
-rw-rw---- 1 llebois ddtrp   21663096 Jan 11 17:17 stats.sNTD009_REMLvar+tlrc.BRIK
-rw-rw---- 1 llebois ddtrp       4219 Jan 11 17:17 stats.sNTD009_REMLvar+tlrc.HEAD
drwxrws--- 2 llebois ddtrp         10 Jan 11 17:12 stimuli
-rw-rw---- 1 llebois ddtrp    1805258 Jan 11 17:12 sub-NTD009_ses-2_space-MNI152NLin6Asym_res-2_desc-preproc_T1w_brain+tlrc.BRIK
-rw-rw---- 1 llebois ddtrp       2534 Jan 11 17:12 sub-NTD009_ses-2_space-MNI152NLin6Asym_res-2_desc-preproc_T1w_brain+tlrc.HEAD
-rw-rw---- 1 llebois ddtrp       2762 Jan 11 17:17 sum_ideal.1D
-rw-rw---- 1 llebois ddtrp    3610516 Jan 11 17:17 TSNR.sNTD009+tlrc.BRIK
-rw-rw---- 1 llebois ddtrp       4913 Jan 11 17:17 TSNR.sNTD009+tlrc.HEAD
drwxrws--- 2 llebois ddtrp          4 Jan 11 17:17 tsnr_stats_regress
drwxrws--- 2 llebois ddtrp         46 Jan 11 17:14 vlines.pb00.tcat
-rw-rw---- 1 llebois ddtrp     312319 Jan 11 17:14 X.jpg
-rw-rw---- 1 llebois ddtrp       5919 Jan 11 17:17 X.stim.xmat.1D
-rw-rw---- 1 llebois ddtrp      35389 Jan 11 17:14 X.xmat.1D

I went ahead and ran

apqc_make_tcsh.py -run
apqc_make_html.py -qc_dir QC_NTD009

But I get this error:

afnirun apqc_make_html.py -qc_dir QC_NTD009
Traceback (most recent call last):
  File "/opt/afni/install/apqc_make_html.py", line 89, in <module>
    os.chdir(iopts.qcdir)
FileNotFoundError: [Errno 2] No such file or directory: 'QC_NTD009'

I think because the QC directory was still not created even when using the newer version of afni?

Best,
LL

Hi, Lauren-

Hmm, that's odd. Of those two commands, the first (apqc_make_tcsh.py) should generate the QC directory and most of its components, and the second should create the HTML out of the contents there. So, if there is no QC directory, that means the first one failed.

The error message refers to this program: /opt/afni/install/apqc_make_html.py. Just to doublecheck, that is the correct path for your current, ver=25.3.00 AFNI?

Assuming that is the case, could you please run this:

apqc_make_tcsh.py -run -do_log

... which has an extra argument to create a text file log of everything run, "log_apqc_tcsh.txt". Then, could please email me that script and I'll take a look at what is happening?

thanks,
pt

Thanks for your command.

You can try making that directory and running again (mkdir QC_NTD009), but I believe a motion file is required for the QC generation, at least on the afni_proc.py side (perhaps running apqc_make* would still work). It seems likely that you would want to evaluate subject motion in the report, even if you are not censoring.

Now that you have a current version of AFNI, extract the 6 motion time series from the fMRIprep nuisance file and pass them via -regress_motion_file. That should make for a better QC report.

You might also want to pass some ROIs for getting TSNR stats, as mentioned by Paul. That would mean passing an ROI dataset in the final space with -ROI_import and specifying regions of particular interest using -regress_compute_tsnr_stats.

-rick

Hi Paul & Rick - I went ahead and re-ran afniproc with motion regressors. This is the afniproc script I used:

afni_proc.py -subj_id s{$subj}                                    				   \
         -script proc.s{$subj}						  										\
	  	 -scr_overwrite                                     								\
#	 -execute							     												\
	 -out_dir $top_dir/{$subj}_afni_proc_fmriprep_wm_csf_6cond								\
     -blocks mask scale regress           													\
     -copy_anat "$anat_dir/sub-${subj}_ses-2_space-MNI152NLin6Asym_res-2_desc-preproc_T1w_brain.nii.gz" \
	 -anat_has_skull no																		\
     -dsets $epi_dir/notme1/denoised_func_data_nonaggr.nii.gz            	                \
    	   $epi_dir/notme2/denoised_func_data_nonaggr.nii.gz         	                    \
    	   $epi_dir/notme3/denoised_func_data_nonaggr.nii.gz         	                    \
     -tcat_remove_first_trs 0                                         						\
	 -mask_epi_anat yes						    											\
	 -regress_stim_times_offset $stim_offset												\
     -regress_stim_times $stim_dir/s{$subj}_*_times.1D           					    \
     -regress_stim_labels Famous_Female_times Famous_Male_times Other_Female_times Other_Male_times Self_Female_times Self_Male_times  		\
     -regress_basis 'BLOCK(23.6,1)'                   					                    \
	 -regress_make_cbucket yes					    										\
	 -regress_motion_file /data/ddtrp/TP2/AFNI_motion/{$subj}_motion6_notme_all.1D			\
	 -regress_extra_ortvec /data/ddtrp/TP2/Nuisance_Reg_WM_CSF/{$subj}_csf_notme_all.1D		\
	 					   /data/ddtrp/TP2/Nuisance_Reg_WM_CSF/{$subj}_wm_notme_all.1D		\
	 -regress_extra_ortvec_labels CSF WM													\
	 -regress_3dD_stop						      											\
    -regress_reml_exec                                                    					\
     -regress_opts_3dD						      											\
	    -jobs 2							      												\
	    -bout                                                	      						\
	    -num_glt 3							      											\
            -gltsym 'SYM: Self_Female_times -Other_Female_times'	      					\
		-glt_label 1 Self_F-Other_F            			      								\
            -gltsym 'SYM: Self_Female_times -Famous_Female_times'             				\
		-glt_label 2 Self_F-Famous_F           			      								\
            -gltsym 'SYM: Famous_Female_times -Other_Female_times'	      					\
		-glt_label 3 Famous_F-Other_F			              								\
    -regress_compute_fitts                                                					\
    -regress_est_blur_errts						      										\
	-regress_local_times
end

This is the directory contents:

3dClustSim.ACF.cmd
3dREMLfit.err
all_betas.sNTD009_REML+tlrc.BRIK
all_betas.sNTD009_REML+tlrc.HEAD
all_runs.sNTD009+tlrc.BRIK
all_runs.sNTD009+tlrc.HEAD
blur.err_reml.1D
blur_est.sNTD009.1D
corr_brain+tlrc.BRIK
corr_brain+tlrc.HEAD
@epi_review.sNTD009
errts.sNTD009_REML+tlrc.BRIK
errts.sNTD009_REML+tlrc.HEAD
files_ACF
files_ClustSim
fitts.sNTD009_REML+tlrc.BRIK
fitts.sNTD009_REML+tlrc.HEAD
full_mask.sNTD009+tlrc.BRIK
full_mask.sNTD009+tlrc.HEAD
gtkyd
gtkyd.xls
ideal_Famous_Female_times.1D
ideal_Famous_Male_times.1D
ideal_Other_Female_times.1D
ideal_Other_Male_times.1D
ideal_Self_Female_times.1D
ideal_Self_Male_times.1D
mask_anat.sNTD009+tlrc.BRIK
mask_anat.sNTD009+tlrc.HEAD
mask_epi_anat.sNTD009+tlrc.BRIK
mask_epi_anat.sNTD009+tlrc.HEAD
mean.errts.1D
mean.errts.unit.1D
motion_demean.1D
motion_deriv.1D
NTD009_motion6_notme_all.1D
out.4095_all.txt
out.4095_warn.txt
out.ap_uvars.json
out.ap_uvars.txt
out.cormat_warn.txt
outcount.r01.1D
outcount.r02.1D
outcount.r03.1D
outcount_rall.1D
out.df_info.txt
out.gcor.1D
out.gtkyd.outliers.txt
out.mask_ae_dice.txt
out.mask_ae_overlap.txt
out.pre_ss_warn.txt
out.vlines.pb00.tcat.txt
pb00.sNTD009.r01.tcat+tlrc.BRIK
pb00.sNTD009.r01.tcat+tlrc.HEAD
pb00.sNTD009.r02.tcat+tlrc.BRIK
pb00.sNTD009.r02.tcat+tlrc.HEAD
pb00.sNTD009.r03.tcat+tlrc.BRIK
pb00.sNTD009.r03.tcat+tlrc.HEAD
pb01.sNTD009.r01.scale+tlrc.BRIK
pb01.sNTD009.r01.scale+tlrc.HEAD
pb01.sNTD009.r02.scale+tlrc.BRIK
pb01.sNTD009.r02.scale+tlrc.HEAD
pb01.sNTD009.r03.scale+tlrc.BRIK
pb01.sNTD009.r03.scale+tlrc.HEAD
radcor.pb02.regress
stats.REML_cmd
stats.sNTD009_REML+tlrc.BRIK
stats.sNTD009_REML+tlrc.HEAD
stats.sNTD009_REMLvar+tlrc.BRIK
stats.sNTD009_REMLvar+tlrc.HEAD
stimuli
sub-NTD009_ses-2_space-MNI152NLin6Asym_res-2_desc-preproc_T1w_brain+tlrc.BRIK
sub-NTD009_ses-2_space-MNI152NLin6Asym_res-2_desc-preproc_T1w_brain+tlrc.HEAD
sum_ideal.1D
TSNR.sNTD009+tlrc.BRIK
TSNR.sNTD009+tlrc.HEAD
tsnr_stats_regress
vlines.pb00.tcat
X.jpg
X.stim.xmat.1D
X.xmat.1D

I tried running the first command and get this error:

afnirun apqc_make_tcsh.py -run -do_log
Traceback (most recent call last):
  File "/opt/afni/install/apqc_make_tcsh.py", line 349, in <module>
    with open(iopts.json, 'r') as fff:
FileNotFoundError: [Errno 2] No such file or directory: 'out.ss_review_uvars.json'

It seems like even with motion regressors it's not generating the necessary files for APQC?

Thank you so much for your time and guidance.
Best,
Lauren

Hi Lauren,
I just sent you a message about this.
Thanks,
-rick

Hi Lauren,
Thanks for the information yesterday. Indeed, the enorm file is still not generated without either a volreg block or censoring. A note to myself to deal with this case is actually on line 231 of my "todo" file, but that suggests it would not have happened anytime soon... :)

Anyway, I made an update for it and will fire off a build today.

How do you get new binaries? What is the output of:

afni_system_check.py -disp_ver_afni

Thanks again,
-rick

Thank you so much, Rick! I really appreciate your time on this on such a quick turnaround. I use a cluster at our imaging center to conduct fMRI analyses - so I spoke with the director of IT there, and he said the best option for him would be if you could "generate a new Docker image. Then he can build a new Apptainer/Singularity image from that." Admittedly I don't really know what this means - so I don't know if this is a bigger ask.

Re afni_system_check.py -disp_ver_afni output:

AFNI_25.3.00, linux_ubuntu_16_64_glw_local_shared, Nov 19 2025, local

Best,
Lauren

Maybe we should have an independent discussion about that.
There is actually an afni/afni_make_build container that gets created with our github build packages (under /opt/afni/install), though I have not really evaluated using it for anything. And we are plotting to make a more complete docker package, but have not finished it yet. I would still expect that it might be straightforward to try a more simple binary solution, as you did on your own.

Hi Rick - thank you! I haven't yet tried a binary solution on the cluster (the newer version of afni I accessed earlier in this thread was already installed on the cluster). How would I go about the binary solution on the cluster?
Best,
Lauren

Hi, Lauren-

I think the binary solution refers to what I mentioned above: downloading one of our precompiled binaries for Linux, putting the folder somewhere in your local directory structure, and putting that location at the start of your shell path.

What kind of operating system does the cluster use? If you run afni_system_check.py -check_all and put the outputs here, then we should be able to tell.

-pt

Hi Paul, Thank you! Here is the output requested:

afnirun afni_system_check.py -check_all
-------------------------------- general ---------------------------------
architecture:         64bit ELF
cpu type:             x86_64
system:               Linux
release:              4.18.0-553.53.1.el8_10.x86_64
version:              #1 SMP Fri May 9 17:36:31 EDT 2025
distribution:         Ubuntu 18.04 bionic
number of CPUs:       64
user:                 llebois
apparent login shell: tcsh
shell RC file:        .cshrc (exists)

--------------------- AFNI and related program tests ---------------------
which afni           : /opt/afni/src/../install/afni
afni version         : Precompiled binary linux_ubuntu_16_64_glw_local_shared: Nov 19 2025 
                     : AFNI_25.3.00 'Gordian II'
AFNI_version.txt     : AFNI_25.3.00, linux_ubuntu_16_64_glw_local_shared, Nov 19 2025, local
afnipy version       : AFNI_25.3.00
which python         : /usr/bin/python
python version       : 3.6.9
which R              : /usr/bin/R
R version            : R version 3.4.4 (x86_64-pc-linux-gnu)

instances of various programs found in PATH:
    afni    : 1   (/opt/afni/install/afni)
                  (not owned by user)
    R       : 1   (/usr/bin/R)
    python  : 1   (/usr/bin/python3.6)
    python2 : 0 
    python3 : 1   (/usr/bin/python3.6)

testing ability to start various programs...
    afni                 : success
    suma                 : success
    3dSkullStrip         : success
    3dAllineate          : success
    3dRSFC               : success
    SurfMesh             : success
    3dClustSim           : success
    build_afni.py        : success
    uber_subject.py      : success
    3dMVM                : FAILURE
        Unknown user: proto.
        Error in library(data.table) : there is no package called ‘data.table’
        Calls: source ... suppressPackageStartupMessages -> withCallingHandlers -> library
        Execution halted
    rPkgsInstall         : success

have failures, testing programs under implied /opt/afni/install...
    afni                 : success
    suma                 : success
    3dSkullStrip         : success
    3dAllineate          : success
    3dRSFC               : success
    SurfMesh             : success
    3dClustSim           : success
    build_afni.py        : success
    uber_subject.py      : success
    3dMVM                : FAILURE
        Unknown user: proto.
        Error in library(data.table) : there is no package called ‘data.table’
        Calls: source ... suppressPackageStartupMessages -> withCallingHandlers -> library
        Execution halted
    rPkgsInstall         : success

------------------------ dependent program tests -------------------------
checking for dependent programs...

which tcsh           : /usr/bin/tcsh
tcsh version         : 6.20.00
which Xvfb           : /usr/bin/Xvfb

checking for R packages...
    rPkgsInstall -pkgs ALL -check : FAILURE
        Unknown user: proto.
        
        oo Warning: 
           These packages are not installed on the computer: afex!
        These packages are not installed on the computer: phia!
        These packages are not installed on the computer: snow!
        These packages are not installed on the computer: lme4!
        These packages are not installed on the computer: lmerTest!
        These packages are not installed on the computer: gamm4!
        These packages are not installed on the computer: data.table!
        These packages are not installed on the computer: paran!
        These packages are not installed on the computer: psych!
        These packages are not installed on the computer: brms!
        These packages are not installed on the computer: corrplot!
        These packages are not installed on the computer: metafor!
        

R RHOME : /usr/lib/R

------------------------------ python libs -------------------------------

++ module loaded: matplotlib.pyplot
   module file : /opt/user_pip_packages/lib/python3.6/site-packages/matplotlib/pyplot.py
   matplotlib version : 3.3.4

** failed to load module flask
-- flask is required

** failed to load module flask_cors
-- flask_cors is required

-------------------------------- env vars --------------------------------
PATH                       = /opt/afni/src/../install:/opt/cmake/cmake-3.14.7-Linux-x86_64/bin:/opt/user_pip_packages/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

PYTHONPATH                 = 
R_LIBS                     = 
LD_LIBRARY_PATH            = /.singularity.d/libs
DYLD_LIBRARY_PATH          = 
DYLD_FALLBACK_LIBRARY_PATH = 
CONDA_SHLVL                = 
CONDA_DEFAULT_ENV          = 
CC                         = 
HOMEBREW_PREFIX            = 

----------------------------- eval dot files -----------------------------

----------- AFNI $HOME files -----------

    .afnirc                   : missing
    .sumarc                   : missing
    .afni/help/all_progs.COMP : missing

--------- shell startup files ----------

   -- no .tcshrc, will create one as a follower of .cshrc
   -- considered operations: path, apsearch
   
   -- note: followers should not need edits, so edit flags should be 0
      (have 1 follower(s), which can be ignored)
   
   dot file test : want 2 modifications across 2 files:
   
      file             path  flatdir  apsearch        follower
      ---------------  ----  -------  --------        --------
      .cshrc           1     0        1               0     
      .tcshrc          0     0        0               1     
   
------------------------------ data checks -------------------------------
data dir : missing AFNI_data6
data dir : missing AFNI_data7
data dir : missing AFNI_demos
data dir : missing suma_demo
data dir : missing afni_handouts
atlas    : did not find TT_N27+tlrc

------------------------------ OS specific -------------------------------
which apt-get        : /usr/local/bin/apt-get
apt-get version      : apt 1.6.12 (amd64)

which git            : /usr/bin/git
git version          : git version 2.24.0
which gcc            : /usr/bin/gcc
gcc version          : gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0

have Ubuntu system: Ubuntu 18.04 bionic
have Ubuntu afni  : Precompiled binary linux_ubuntu_16_64_glw_local_shared: Nov 19 2025 

=========================  summary, please fix:  =========================
*  AFNI programs show FAILURE
*  consider adding /opt/afni/install to your PATH
*  missing R packages (see rPkgsInstall)
*  python library flask is required
*  python library flask_cors is required
*  please run: cp /opt/afni/src/../install/AFNI.afnirc ~/.afnirc
*  please run: "suma -update_env" for .sumarc
*  please run: apsearch -update_all_afni_help
*  dot file test : want 2 modifications across 2 files:
*  insufficient data for AFNI bootcamp
   (see "Prepare for Bootcamp" on install pages)
*  possibly missing atlases

Best,
Lauren