Resting State proc.py

Hi AFNI experts,

#!/bin/tcsh

foreach subj (ls -d /Volumes/JW/AES2016/data/AES* | sed 's/\// /g' | awk '{print $5}')

foreach cond (Ex Rest)

echo "subj = " ${subj} ", cond = " ${cond}

cd /Volumes/JW/AES2016/data/AES101/${subj}.${cond}

        afni_proc.py                                                                                                                                        \
              -blocks despike tlrc align volreg mask regress                                                                                                       \
              -copy_anat /Volumes/JW/AES2016/data/${subj}/${subj}.${cond}/fs_output/mri/SUMA/${subj}.${cond}_SurfVol.nii                             \
              -anat_has_skull no                                                                                                                            \
              -anat_follower_ROI aaseg anat /Volumes/JW/AES2016/data/${subj}/${subj}.${cond}/fs_output/mri/SUMA/aparc.a2009s+aseg.nii                       \
              -anat_follower_ROI aeseg epi /Volumes/JW/AES2016/data/${subj}/${subj}.${cond}/fs_output/mri/SUMA/aparc.a2009s+aseg.nii                       \
              -anat_follower_ROI FSvent epi /Volumes/JW/AES2016/data/${subj}/${subj}.${cond}/fs_output/mri/SUMA/${subj}.${cond}_vent.nii                        \
              -anat_follower_ROI FSwm epi /Volumes/JW/AES2016/data/${subj}/${subj}.${cond}/fs_output/mri/SUMA/${subj}.${cond}_wm.nii                              \
              -anat_follower_erode FSvent FSwm                                                                                                              \
	          -dsets /Volumes/JW/AES2016/data/${subj}/${subj}.${cond}/resting/epi.resting_t.slicemocoxy_afni.slomoco+orig    \
              -align_opts_aea -cost lpc+ZZ                                                                \
              -tlrc_base MNI152_T1_2009c+tlrc                                                             \
              -tlrc_NL_warp                                                                               \
              -tlrc_NL_awpy_rm no                                                                         \
              -volreg_align_to MIN_OUTLIER                                                                \
              -volreg_align_e2a                                                                           \
              -volreg_tlrc_warp                                                                           \
              -regress_motion_per_run                                                                     \
              -volreg_warp_dxyz 2.0                                                                       \
              -regress_apply_mask                                                                         \
              -regress_ROI_PC FSvent 3                                                                    \
              -regress_make_corr_vols aeseg FSvent                                                        \
              -regress_anaticor_fast                                                                      \
              -regress_anaticor_label FSwm                                                                \
              -regress_censor_motion 0.2                                                                  \
              -regress_censor_outliers 0.1                                                                \
              -regress_apply_mot_types demean deriv                                                       \
              -regress_est_blur_epits                                                                     \
              -regress_est_blur_errts                                                                     \

tcsh -xef proc.SUBJ |& tee output.proc.SUBJ

@ linenum++
end
end

I was running the above resting-state proc script and got an error message below.

Warping used up maximum iterations
even after doubling number of iterations to 274.
Convergence might not have been reached.

If you find the alignment poor, try
rerunning the script with a transform
type of fewer parameters (-xform) or by using
an even higher number of iterations (-maxite).
You can also choose to continue with the
current result (dset: __ats_tmp__reg_warpdriveout+orig
by using the option: -OK_maxite

Script will stop …

#**ERROR Failed in affine step
** ERROR - script failed
3dbucket: No match.

I wasn’t sure what is the issue here. Is it simply be solved by adding -OK_maxite to the script?

Thank you in advance for your help,
Jun

Perhap I am wrong about this, but I was just looking at SUMA output today so I’ll take the time to comment - I thought the SurfVolume still had a skull? I notice that in line 4 of your afni_proc call you specify that it does not.

HI dowdlelt,

Thank you so much for your comment! I’ll try without the line. Could you please let me know what is the difference between adding that line and without the line?

Thanks,
Jun

I am guessing here, but I would imagine that including -anat_has_skull no prevents skull stripping from being performed. You are then performing non-linear normalization to the 2009 MNI template, with no skull. That is definitely going to cause problems for the algorithm trying to match the images, and that is my guess for what went wrong.

I’ve been very fond for using @SSwarper, the AFNI program that performs skull stripping and normalization all in one go, with some tweaks and optimizations. You can use that on your SurfVol in the SUMA folder, and then import the needed files in AFNI proc. This is very useful as you only have to run non-linear normalization, which is slow, just once - so if you decide to run afni_proc again, and again as you tweak settings your life will be much more pleasant.

I’ve found this recent AFNI publication extraordinarily useful: link to post.

Hi dowdlelt,

Thank you so much for your help! I’ll take a look at the link you sent as well as @SSwarper.

Best,
Jun