reslice_7to3 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/bin/bash
  2. # Author: Michael Hanke <michael.hanke@gmail.com>
  3. # License: MIT
  4. set -e
  5. set -u
  6. # fake test for FSL
  7. ignore=$FSLDIR
  8. inbold=$(readlink -f $1) || true
  9. initref=$(readlink -f $2) || true
  10. finalref=$(readlink -f $3) || true
  11. finalxfm=$(readlink -f $4) || true
  12. outbold=$(readlink -m $5)
  13. initflirtopts=${6:--dof 6}
  14. for f in "$inbold" "$initref" "$finalref" "$finalxfm"; do
  15. if [ -z "$f" ]; then
  16. echo "File not found '$1'"
  17. exit 1
  18. fi
  19. done
  20. outbolddir=$(dirname "${outbold}")
  21. mkdir -p "$outbolddir"
  22. wdir=$(mktemp -d --suffix=7to3reslice)
  23. echo $wdir
  24. trap "rm -rf $wdir" SIGINT SIGTERM
  25. cd "$wdir"
  26. $FSLDIR/bin/fslroi "$inbold" bold 0 1
  27. $FSLDIR/bin/bet bold bold_brain -Z -f 0.1
  28. $FSLDIR/bin/flirt ${initflirtopts} -in bold_brain -ref $initref -omat bold2brain.mat
  29. $FSLDIR/bin/convert_xfm -omat bold2final.mat -concat "$finalxfm" bold2brain.mat
  30. #$FSLDIR/bin/flirt -in bold_brain -ref "$finalref" -applyxfm -init bold2final.mat -out "$outbold" -interp sinc
  31. $FSLDIR/bin/flirt -in "$inbold" -ref "$finalref" -applyxfm -init bold2final.mat -out "$outbold" -interp sinc
  32. cd -
  33. rm -rf "$wdir"