highspeed-bids-stimuli.sh 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/usr/bin/bash
  2. # ==============================================================================
  3. # SCRIPT INFORMATION:
  4. # ==============================================================================
  5. # SCRIPT: DOWNLOAD STIMULI AND MOVE SELECTION INTO STIMULI FOLDER
  6. # PROJECT: HIGHSPEED
  7. # WRITTEN BY LENNART WITTKUHN, 2020
  8. # CONTACT: WITTKUHN AT MPIB HYPHEN BERLIN DOT MPG DOT DE
  9. # MAX PLANCK RESEARCH GROUP NEUROCODE
  10. # MAX PLANCK INSTITUTE FOR HUMAN DEVELOPMENT
  11. # MAX PLANCK UCL CENTRE FOR COMPUTATIONAL PSYCHIATRY AND AGEING RESEARCH
  12. # LENTZEALLEE 94, 14195 BERLIN, GERMANY
  13. # ==============================================================================
  14. # DEFINE ALL PATHS:
  15. # ==============================================================================
  16. PATH_BASE=${HOME}
  17. PATH_PROJECT="highspeed"
  18. PATH_BIDS=${PATH_BASE}/${PATH_PROJECT}/bids
  19. PATH_OUTPUT=${PATH_BIDS}/stimuli
  20. # ==============================================================================
  21. # DOWNLOAD AND MOVE STIMULI FILES:
  22. # ==============================================================================
  23. # download stimuli from Haxby et al. (2001), Science to the base directory:
  24. wget http://data.pymvpa.org/datasets/haxby2001/stimuli-2010.01.14.tar.gz -P ${PATH_BASE}
  25. # unpack the .tar.gz file into the stimuli folder (this creates a 'stimuli' folder):
  26. tar -zxvf ${PATH_BASE}/stimuli-2010.01.14.tar.gz -C ${PATH_BIDS}
  27. # ==============================================================================
  28. # CREATE RELEVANT DIRECTORIES:
  29. # ==============================================================================
  30. # create stimuli directory:
  31. if [ ! -d ${PATH_OUTPUT} ]; then
  32. mkdir -p ${PATH_OUTPUT}
  33. echo "created ${PATH_OUTPUT}"
  34. fi
  35. # create output directory (always overwrite old one):
  36. rm -rf ${PATH_OUTPUT}/images
  37. mkdir -p ${PATH_OUTPUT}/images
  38. echo "created ${PATH_OUTPUT}/images"
  39. # create arrays with old and new file names:
  40. FILES=("pepper5.jpg" "d9a.jpg" "Tim_3.jpg" "house2.3.jpg" "shoec3.jpg")
  41. NAMES=("cat.jpg" "chair.jpg" "face.jpg" "house.jpg" "shoe.jpg")
  42. # copy relevant files into 'images' (a sub-directory of 'stimuli')
  43. for ((i=0;i<${#FILES[@]};++i)); do
  44. printf "copy %s to %s\n" "${FILES[i]}" "${NAMES[i]}"
  45. cp -v ${PATH_OUTPUT}/*/"${FILES[i]}" "${PATH_OUTPUT}/images/${NAMES[i]}"
  46. done
  47. # remove all folders inside 'stimuli' except 'images'
  48. find ${PATH_OUTPUT} -mindepth 1 -maxdepth 1 -not -name images -exec rm -rf '{}' \;
  49. # remove original zipped stimulus folder:
  50. rm -rf ${PATH_BASE}/stimuli-2010.01.14.tar.gz*