Hi, Clément-
OK, I have looked at the data and I have a few thoughts:
+ the original coordinates are a bit odd-- while the anatomical and EPI overlay each other, the (x, y, z) = (0, 0, 0) location is far outside the brain; this can affect some alignment issues.
+ the EPI has fairly low contrast (not a lot of details easily seen).
+ both datasets were acquired with oblique coordinates.
So, my thoughts on this:
+ purge the obliquity information, rather than applying it for alignment, because for the anatomical-template alignment, applying the obliquity information will introduce a larger relative rotation to the template brain. Once we purge the anatomical obliquity info, then we should do the same to the EPI (so there isn't a relative rotation introduced).
+ we should put have (0, 0, 0) of each dset be somewhere in the brain-- mainly to help the anatomical-template alignment.
+ align_epi_anat.py will try to remove the skull of both the anatomical and the EPI by default; after @animal_warper, we will have a skullstripped version of the anatomical, so we should tell align_epi_anat.py that "-anat_has_skull no"; for this EPI, align_epi_anat.py tended to remove a lot of actual brain if it tried to remove the skull (I think because of the general lack of contrast); therefore, one can either not remove the skull of the EPI, or tell it to use "3dAutomask" to do so, via "-epi_strip 3dAutomask".
Note that when I ran/tested this here, I just used the first 5 time points or so from the EPI time series, for the sake of speed of running.
#!/bin/tcsh
set dset_anat = anatT1.nii.gz
set dset_bold = BOLD_restingstate.nii.gz
set dset_anat_deob = a00_deob.nii
set dset_anat_ss = a01_ss.nii
set dset_bold_deob = e00_deob.nii
set refvol = template/NMT_SS.nii.gz
set refatl = template/D99_atlas_1.2a_al2NMT.nii.gz
set aw_dir = s01_anwarp
# ==========================================================================
# copy and get rid of obliquity info of anatomical
3dcopy \
${dset_anat} \
${dset_anat_deob}
3drefit \
-deoblique \
${dset_anat_deob}
# ------------------- for center of mass of anatomical
# this should be good enough to center mass around 0 0 0 for template
# alignment
3dSkullStrip \
-prefix ${dset_anat_ss} \
-input ${dset_anat_deob} \
-blur_fwhm 2 \
-orig_vol
3dCM \
-set 0 0 0 \
${dset_anat_ss}
3drefit \
-duporigin ${dset_anat_ss} \
${dset_anat_deob}
# --------------------- for obliquity and center of mass of EPI
3dcalc \
-a ${dset_bold} \
-expr 'a' \
-prefix ${dset_bold_deob}
# purge obliquity info, and apply shifts so BOLD dset overlays anat dset well
3drefit \
-deoblique \
${dset_bold_deob}
3dCM \
-set 0 0 0 \
${dset_bold_deob}
# ---------------------------------- run main prog for nonlinear warp + skullstripping
@animal_warper \
-input ${dset_anat_deob} \
-base ${refvol} \
-atlas ${refatl} \
-outdir ${aw_dir} \
-ok_to_exist
# -----------------------------------------------------------------
# use skullstripped anatomical in orig space (and don't skullstrip it again!); either use 3dAutomask to skullstrip EPI, or do none at all; results are quite similar:
align_epi_anat.py \
-epi2anat \
-epi ${dset_bold_deob} \
-anat ${aw_dir}/a00_deob_ns.nii.gz \
-anat_has_skull no \
-epi_strip 3dAutomask \
-epi_base 0 -volreg off -tshift off \
-suffix TRY5 \
-cost lpc+ZZ
align_epi_anat.py \
-epi2anat \
-epi ${dset_bold_deob} \
-anat ${aw_dir}/a00_deob_ns.nii.gz \
-anat_has_skull no \
-epi_strip None \
-epi_base 0 -volreg off -tshift off \
-suffix TRY6 \
-cost lpc+ZZ
echo "++ Done with aligning anatomical with template"
To provide the same kind of info used in the align_epi_anat.py commands to afni_proc.py, you would use something like the following (exact paths and file names might be different):
-copy_anat ${aw_dir}/a00_deob_ns.nii.gz \
-anat_has_skull no \
...
-align_opts_aea \
-cost lpc+ZZ \
-epi_strip None \
... or the same iwth "-epi_strip 3dAutomask", instead.
Happy to answer any followup questions.
--pt