pRF_run_analyzePRF_LISA_avg.sh 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #! /bin/bash
  2. # compiles & calls the compiled matlab file specified as first parameter,
  3. # passes the 2nd to 6th parameters as input
  4. # PARAMETERS ====================
  5. echo 'Matlab file name: '$1
  6. MATLAB_SCRIPT=$1
  7. echo 'Monkey name: '$2
  8. MONKEY=$2
  9. echo 'Session: '$3
  10. SESS=$3
  11. echo 'Slices: '$4
  12. SLICES=$4
  13. # create folder label
  14. SLICELABEL=${SLICES/:/-}
  15. echo 'HRF: '$5
  16. HRF=$5
  17. echo 'Number of workers: '$6
  18. NWORKERS=$6
  19. echo 'Modeltype: '$7
  20. MODTYPE=$7
  21. echo 'Crossvalidation mode: '$8
  22. XVAL=$8
  23. echo 'Results folder: '$9
  24. RESFLD=$9
  25. echo 'Path to Logfile directory: '$10
  26. LOGFILE_DIR=$10
  27. echo 'Path to matlab file: '$11
  28. MATLAB_PATH=$11
  29. # check the number of arguments we need
  30. NARG=11
  31. if [ $# -ne $NARG ];then
  32. echo "ERROR: You must exactly provide $NARG arguments!" 1>&2
  33. exit 1
  34. fi
  35. LOC=`pwd`
  36. cd $HOME
  37. # ensure that you are in your home directory, to avoid matlab path problems
  38. # (by default, the path information is saved in the home directory, so starting
  39. # matlab from there uses the normal path of the user)
  40. HOSTNAME=`hostname`
  41. MYSELF=`whoami`
  42. DATE=`date`
  43. LOGFILE=$LOGFILE_DIR/log_job_$MONKEY_$SESS_$SLICES
  44. echo
  45. echo "Running job as $MYSELF on $HOSTNAME, $DATE" 2>&1
  46. echo
  47. # creating a new virtual screen using xvfb-run and calling then matlab,
  48. # including a 'mini-program' to ensure all paths are added correctly
  49. # " , \ " at end of line is necessary, because this whole little program
  50. # must be transmitted as one line to matlab.
  51. echo
  52. # go to the scratch PRF folder
  53. cd $TMPDIR/PRF
  54. # copy the matlab script that needs to be compiled from Code/BashScripts to scratch/PRF
  55. cp $HOME/PRF/Code/$MATLAB_SCRIPT* $TMPDIR/PRF
  56. # compile the matlab script (only need to do this once in theory)
  57. #module load matlab
  58. #echo "mcc -m $TMPDIR/PRF/$MATLAB_SCRIPT.m -a $TMPDIR/PRF/analyzePRF -a $TMPDIR/PRF/HRF -a $TMPDIR/PRF/NIfTI" | matlab -nodisplay
  59. #module unload matlab
  60. #wait
  61. # make it executable
  62. chmod +x $MATLAB_SCRIPT*
  63. # load the mcr module (runtime environment)
  64. module load mcr
  65. # execute the compiled function with the specified inputs
  66. ./$MATLAB_SCRIPT $MONKEY $SESS $SLICES $HRF $NWORKERS $MODTYPE $XVAL $RESFLD
  67. # unload the runtime environment
  68. module unload mcr
  69. # change back to the starting directory
  70. cd $LOC
  71. echo
  72. echo "Job finished with Exit code $EXIT, returning"
  73. echo "Copy data from scratch back to home " 2>&1
  74. echo
  75. mkdir -p $HOME/PRF/Results/$MONKEY/$RESFLD
  76. cp -r $TMPDIR/PRF/Results/$MONKEY/$RESFLD/Slices* $HOME/PRF/Results/$MONKEY/$RESFLD/
  77. exit $EXIT