Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

localizerstats2mask.sh 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/bin/bash
  2. # Take all localizer 1st-level GLM analysis results, computes and average zstat map
  3. # for both contrasts of interest, masks them with the given mask image, and thresholds to
  4. # identify the voxels matching the desired percentile of largest values
  5. #
  6. # Usage:
  7. # code/localizerstats2mask.sh sub-4 VT_roi 90
  8. set -e
  9. set -u
  10. sub=$1
  11. mask=$2
  12. percentile=$3
  13. dsdir="$(readlink -f .)"
  14. wdir=$(mktemp -d --suffix=localizer2mask)
  15. trap "rm -rf $wdir" SIGINT SIGTERM
  16. cd "$wdir"
  17. # define contrast names
  18. contrasts=(dummy all ffa ppa eba loc vis ffa_alt ppa_alt eba_alt loc_alt)
  19. ##combine MNI2T1 and T12BOLD
  20. #$FSLDIR/bin/convert_xfm \
  21. # -omat mni2bold.mat \
  22. # -concat ${dsdir}/src/tnt/${sub}/t1w/in_bold/xfm_6dof.mat \
  23. # ${dsdir}/src/tnt/${sub}/t1w/in_mni152/tmpl2subj.mat
  24. ## re-slice mask
  25. #$FSLDIR/bin/flirt \
  26. # -in "${dsdir}/${mask}" \
  27. # -ref ${dsdir}/src/tnt/${sub}/bold/brain \
  28. # -applyxfm -init mni2bold.mat \
  29. # -out mask \
  30. # -interp nearestneighbour
  31. ## apply transformation to subject template for all runs
  32. #for f in ${dsdir}/${sub}/run-*.feat; do
  33. # $FSLDIR/bin/featregapply "$f"
  34. # # make zstats
  35. # $FSLDIR/bin/fslmaths $f/reg_standard/stats/varcope1 -sqrt $f/reg_standard/stats/stdcope1
  36. # $FSLDIR/bin/fslmaths $f/reg_standard/stats/varcope2 -sqrt $f/reg_standard/stats/stdcope2
  37. # $FSLDIR/bin/fslmaths $f/reg_standard/stats/cope1 -div $f/reg_standard/stats/stdcope1 $f/reg_standard/stats/zstat1
  38. # $FSLDIR/bin/fslmaths $f/reg_standard/stats/cope2 -div $f/reg_standard/stats/stdcope2 $f/reg_standard/stats/zstat2
  39. #done
  40. # make average zstat across all runs -- mask
  41. for i in $(seq 10); do
  42. $FSLDIR/bin/fslmerge -t zstat${i}_merged ${dsdir}/${sub}/run-*.feat/stats/zstat${i}.nii*
  43. #$FSLDIR/bin/fslmaths zstat${i}_merged -Tmean -mas mask zstat${i}
  44. $FSLDIR/bin/fslmaths zstat${i}_merged -Tmean zstat${i}
  45. # take desired upper percentile and threshold for mask
  46. fslmaths zstat${i} \
  47. -thr $($FSLDIR/bin/fslstats zstat${i} -P "$percentile") \
  48. ${dsdir}/${sub}/${contrasts[$i]}_thr${percentile}
  49. done
  50. cd -
  51. rm -rf "$wdir"