I've taken a look at this data and had some success. Based on the information in the DICOM header, all the EPI data you sent seems to be oblique by an angle of 36.9 degrees. I am working on providing our users with a more integrated method, but I am able to provide you with a good interim solution. We were able to take advantage of the 3doblique script from your very helpful colleagues there at Princeton who provided us with their perl script for doing oblique corrections. Michael Benharrosh there provided us with their script. The angle can be calculated several ways from the DICOM header. One way is included in the script below.
Running this tcsh script (that calls the Princeton perl script) rotates the oblique EPI data to match the anatomical dataset. A DICOM slice file and the oblique AFNI format dataset should be changed in this script for each dataset.
If you'd like, I can post an image of your rotated EPI dataset overlaying the anatomical with your permission. Next week I hope to have something working completely within standard AFNI commands without additional scripting.
#!/bin/tcsh
# obliscript
# use simple inverse cosine of vector element with Princeton's 3doblique script
# to remove obliquity
# some data needed an additional 90 degrees added to the computed data
set dicomslice = '1.3.12.2.1107.5.2.0.35119.30000006052308570565600033293.dcm'
set oblique_dset = 'EPI_run_003'
#
# Shift the times to match across slices
3dTshift -prefix {$oblique_dset}_tshift -quintic {$oblique_dset}+orig
# Add blank spaces above and below volume
3dZeropad -I 20 -S 20 -prefix {$oblique_dset}_zpad {$oblique_dset}_tshift+orig
set IMAGEORIENT = `dicom_hdr $dicomslice | grep '//REL Image Orientation' \
| awk '{print$9}' `
echo "Image orientation field is $IMAGEORIENT"
# now get just 5th element
set IMAGEORIENT = `dicom_hdr $dicomslice | grep '//REL Image Orientation' \
| awk '{print$9}' | awk -F\\ '{print $5}'`
set ANGLEDEGREES = `ccalc "-180 / PI * acos($IMAGEORIENT)"`
echo "Computed rotation angle is $ANGLEDEGREES around the R-L axis"
~/oblique/3doblique --prefix {$oblique_dset}_deoblique -dcm $dicomslice \
-r {$ANGLEDEGREES}R {$oblique_dset}_zpad+orig
If your other datasets are similarly acquired, it might be possible to duplicate the operations. So extracting the commands using 3dinfo shows these steps (after to3d):
3dTshift -prefix EPI_run_003_tshift -quintic EPI_run_003+orig
3dZeropad -I 20 -S 20 -prefix EPI_run_003_zpad EPI_run_003_tshift+orig
3dcopy EPI_run_003_zpad+orig tmp_EPI_run_003_deoblique
3drefit -dxorigin 1.5 -dyorigin -76.38889830485 -dzorigin -11.340135593 tmp_EPI_run_003_deoblique+orig
3dZeropad -prefix EPI_run_003_deoblique_pad -A 8.16770046638663 -P 8.16770046638663 tmp_EPI_run_003_deoblique+orig
3drotate -prefix EPI_run_003_deoblique -cubic -rotate -36.399980 0A 0I EPI_run_003_deoblique_pad+orig
Let me know how this works for you. I'll try to keep everyone updated on the status of obliquity inside AFNI.