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.
3dWarp
mkdir /volumes/SanDisk2/fmri/dataset_2/processed/Warp
for subject in Subject1
do
mkdir /volumes/SanDisk2/fmri/dataset_2/processed/Warp/$subject
directory=/volumes/SanDisk2/fmri/dataset_2/processed/Warp/$subject
directory_awpy=/volumes/SanDisk2/fmri/dataset_2/processed/Warp/$subject/awpy
directory_raw=/volumes/SanDisk2/fmri/dataset_2/raw/$subject
cd $directory
3dWarp
-deoblique
-prefix Warp_Anatomical_${subject}
$directory_raw/anat1to3d+orig
3dWarp
-deoblique
-prefix Warp_RestingState_${subject}
$directory_raw/rest1to3d+orig
3dWarp
-deoblique
-prefix Warp_Task_${subject}
$directory_raw/task1to3d+orig
Align_epi_anat
align_epi_anat.py
-epi2anat
-anat Warp_Anatomical_${subject}+orig
-epi Warp_RestingState_${subject}+orig
-child_epi Warp_Task_${subject}+orig
-epi_base 10
-edge
-partial_axial
-suffix _Align_epi_anat
Auto warp - nonlinear registration
auto_warp.py
-base MNI152_2009_template_SSW.nii.gz
-input Warp_Anatomical_${subject}+orig
-skull_strip_input yes
3dbucket
3dbucket
-DAFNI_NIFTI_VIEW=tlrc
-prefix anat_ns awpy/Warp_Anatomical_${subject}.aw.nii
3dbucket
-DAFNI_NIFTI_VIEW=tlrc
-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
3dNwarpApply
-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${subject}
3dNwarpApply
-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${subject}
done
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
do
mkdir /volumes/SanDisk2/fmri/dataset_2/processed/Preprocessing_RestingState/$subject
directory=/volumes/SanDisk2/fmri/dataset_2/processed/preprocessing_restingstate/$subject
directory_warp=/volumes/SanDisk2/fmri/dataset_2/processed/warp/$subject
cd $directory
afni_proc.py
-subj_id ${subject}Rest
-out_dir $directory/Results
-dsets
$directory_warp/Warp_Align_Nwarp_RestingState${subject}+tlrc
-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_anaticor
-regress_ROI WMe
-regress_apply_mot_types demean deriv
-regress_motion_per_run
-regress_censor_motion 0.3
-regress_censor_outliers 0.05
-blur_size 6.0
-regress_est_blur_epits
-regress_est_blur_errts
-html_review_style pythonic
-execute
done
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:
apqc_make_tcsh.py -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/apqc_make_tcsh.py”, line 585, in
tspace = lat.get_space_from_dset(ap_ssdict[‘template’])
File “/Applications/AFNI/abin/afnipy/lib_apqc_tcsh.py”, line 313, in get_space_from_dset
dset_fullpath = com.so[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?
Thanks,
Philipp