IndexError: list index out of range (

Dear all,

I am processing a clinical dataset. Normally, I run SSwarper first. Then, in a second step, I provide the processed files from SSwarper to AFNI proc (as it is suggested by you AFNI people). However, the alignment was very bad using this approach. tried out all kinds of cost functions too. There was no way to get a proper alignment for the functional/EPI files. The brains were always more or less misaligned.

I then used a different approach where I run several steps before using AFNI proc. Here, I don’t use SSwarper, as skullstripping is part of the code. This code is shown below.


mkdir /volumes/SanDisk2/fmri/dataset_2/processed/Warp
for subject in Subject1
mkdir /volumes/SanDisk2/fmri/dataset_2/processed/Warp/$subject


cd $directory

-prefix Warp_Anatomical_${subject}

-prefix Warp_RestingState_${subject}

-prefix Warp_Task_${subject}

-anat Warp_Anatomical_${subject}+orig
-epi Warp_RestingState_${subject}+orig
-child_epi Warp_Task_${subject}+orig
-epi_base 10
-suffix _Align_epi_anat

Auto warp - nonlinear registration
-base MNI152_2009_template_SSW.nii.gz
-input Warp_Anatomical_${subject}+orig
-skull_strip_input yes


-prefix anat_ns awpy/Warp_Anatomical_${subject}.aw.nii

-prefix anat_final awpy/anat.un.aff.qw.nii

cp awpy/anat.un.aff.Xat.1D
cp awpy/anat.un.aff.qw_WARP.nii
cd $directory/awpy

3dNwarpApply - Apply a nonlinear 3D warp from 3dQwarp etc. to a 3D dataset

-master $directory/anat_ns+tlrc -dxyz 3
-source $directory/Warp_RestingState_${subject}Align_epi_anat+orig
-nwarp “anat.un.aff.qw_WARP.nii anat.un.aff.Xat.1D”
-prefix $directory/Warp_Align_Nwarp_RestingState

-master $directory/anat_ns+tlrc -dxyz 3
-source $directory/Warp_Task_${subject}Align_epi_anat+orig
-nwarp “anat.un.aff.qw_WARP.nii anat.un.aff.Xat.1D”
-prefix $directory/Warp_Align_Nwarp_Task


The method above yields a good alignment between the anatomical and functional datasets. The functional datasets are no longer misaligned (warped all over the place) as in my initial method where I first start with SSwarper and then continue with AFNI proc.
The next step would be to run AFNI proc since I still need to regress the data, censor frames with too high motion, etc. Here is my script:

AFNI proc

mkdir /volumes/SanDisk2/fmri/dataset_2/processed/Preprocessing_RestingState
for subject in Subject1
mkdir /volumes/SanDisk2/fmri/dataset_2/processed/Preprocessing_RestingState/$subject


cd $directory
-subj_id ${subject}Rest
-out_dir $directory/Results
-blocks despike tshift volreg mask blur regress
-copy_anat $directory_warp/anat_final+tlrc
-anat_has_skull no
-tcat_remove_first_trs 4
-mask_segment_anat yes
-mask_segment_erode yes
-regress_ROI WMe
-regress_apply_mot_types demean deriv
-regress_censor_motion 0.3
-regress_censor_outliers 0.05
-blur_size 6.0
-html_review_style pythonic


Now comes the problem: when running the AFNI proc script above, it stops after a while of processing with the following message, which appears after the blocks pb00 (tcat) to pb04 (blur) and .errts have already been computed: -review_style pythonic -subj_dir . -uvar_json out.ss_review_uvars.json
+* WARN: failed to get modern matplotlib (ver 1.3.1 < 2.2):
‘pythonic’ → ‘basic’ APQC
++ Found 32 files for QCing.
Traceback (most recent call last):
File “/applications/AFNI/abin/”, line 585, in
tspace = lat.get_space_from_dset(ap_ssdict[‘template’])
File “/Applications/AFNI/abin/afnipy/”, line 313, in get_space_from_dset
dset_fullpath =[0]
IndexError: list index out of range

I have matplotlib 3.5.0 installed. Do I need to downgrade to, say, version 2.2.0? Or is the problem related to something else? This problem is kinda strange, since when using SSwarper first, and then AFNI proc in a second step (where all the tlrc functions are used in AFNI proc), the quality control images are perfectly computed and this error does not occur.

Another question I would like to ask is: since I already aligned/warped everything in the first steps, I do no longer need to add the “trlc” block (with its related functions) in AFNI proc. Is that correct?