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.

highspeed-mriqc-subject-level.sh 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. #!/usr/bin/bash
  2. # ==============================================================================
  3. # SCRIPT INFORMATION:
  4. # ==============================================================================
  5. # SCRIPT: CREATE PARTICIPANT-LEVEL MRIQC REPORTS FOR A BIDS-STRUCTURED DATASET
  6. # PROJECT: HIGHSPEED
  7. # WRITTEN BY LENNART WITTKUHN, 2018 - 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 (MPIB)
  11. # MAX PLANCK UCL CENTRE FOR COMPUTATIONAL PSYCHIATRY AND AGEING RESEARCH
  12. # LENTZEALLEE 94, 14195 BERLIN, GERMANY
  13. # ACKNOWLEDGEMENTS: THANKS TO ALEXANDER SKOWRON AND NIR MONETA @ MPIB FOR HELP
  14. # ==============================================================================
  15. # DEFINE ALL PATHS:
  16. # ==============================================================================
  17. # path to the base directory:
  18. PATH_BASE="${HOME}"
  19. # path to the project root directory
  20. PATH_ROOT="${PATH_BASE}/highspeed"
  21. # define the name of the project:
  22. PROJECT_NAME="highspeed-mriqc"
  23. # define the path to the project folder:
  24. PATH_PROJECT="${PATH_ROOT}/${PROJECT_NAME}"
  25. # define the name of the current task:
  26. TASK_NAME="mriqc"
  27. # define the path to the script main directory:
  28. PATH_CODE="${PATH_PROJECT}/code"
  29. # cd into the directory of the current task:
  30. cd "${PATH_CODE}"
  31. # define the path to the singularity container:
  32. PATH_CONTAINER="${PATH_PROJECT}/tools/${TASK_NAME}/${TASK_NAME}_0.15.2rc1.sif"
  33. # define the path for the templateflow cache
  34. PATH_TEMPLATEFLOW="${PATH_BASE}/.cache/templateflow"
  35. # path to the data directory (in bids format):
  36. PATH_INPUT="${PATH_PROJECT}/bids"
  37. # path to the output directory:
  38. PATH_OUTPUT=${PATH_PROJECT}
  39. # path to the working directory:
  40. PATH_WORK=${PATH_PROJECT}/work
  41. # path to the log directory:
  42. PATH_LOG=${PATH_PROJECT}/logs/$(date '+%Y%m%d_%H%M%S')
  43. # path to the text file with all subject ids:
  44. PATH_SUB_LIST="${PATH_CODE}/highspeed-participant-list.txt"
  45. # ==============================================================================
  46. # CREATE RELEVANT DIRECTORIES:
  47. # ==============================================================================
  48. # create output directory:
  49. if [ ! -d ${PATH_OUTPUT} ]
  50. then
  51. mkdir -p ${PATH_OUTPUT}
  52. fi
  53. # create working directory:
  54. if [ ! -d ${PATH_WORK} ]
  55. then
  56. mkdir -p ${PATH_WORK}
  57. fi
  58. # create directory for log files:
  59. if [ ! -d ${PATH_LOG} ]
  60. then
  61. mkdir -p ${PATH_LOG}
  62. else
  63. # remove old log files inside the log container:
  64. rm -r ${PATH_LOG}/*
  65. fi
  66. # ==============================================================================
  67. # DEFINE PARAMETERS:
  68. # ==============================================================================
  69. # maximum number of cpus per process:
  70. N_CPUS=5
  71. # memory demand in *GB*
  72. MEM_GB=9
  73. # read subject ids from the list of the text file:
  74. SUB_LIST=$(cat ${PATH_SUB_LIST} | tr '\n' ' ')
  75. # declare an array with sessions you want to run:
  76. declare -a SESSIONS=("01" "02")
  77. #for SUB in ${SUB_LIST}; do
  78. # ==============================================================================
  79. # RUN MRIQC:
  80. # ==============================================================================
  81. # initilize a subject counter:
  82. SUB_COUNT=0
  83. for SUB in ${SUB_LIST}; do
  84. # update the subject counter:
  85. let SUB_COUNT=SUB_COUNT+1
  86. # create the subject number with zero-padding:
  87. SUB_PAD=$(printf "%02d\n" ${SUB_COUNT})
  88. # loop over all sessions:
  89. for SES in ${SESSIONS[@]}; do
  90. # create a new job file:
  91. echo "#!/bin/bash" > job
  92. # name of the job
  93. echo "#SBATCH --job-name mriqc_sub-${SUB_PAD}_ses-${SES}" >> job
  94. # add partition to job
  95. echo "#SBATCH --partition gpu" >> job
  96. # set the expected maximum running time for the job:
  97. echo "#SBATCH --time 24:00:00" >> job
  98. # determine how much RAM your operation needs:
  99. echo "#SBATCH --mem ${MEM_GB}GB" >> job
  100. # email notification on abort/end, use 'n' for no notification:
  101. echo "#SBATCH --mail-type NONE" >> job
  102. # write log to log folder:
  103. echo "#SBATCH --output ${PATH_LOG}/slurm-%j.out" >> job
  104. # request multiple cpus:
  105. echo "#SBATCH --cpus-per-task ${N_CPUS}" >> job
  106. # export template flow environment variable:
  107. echo "export SINGULARITYENV_TEMPLATEFLOW_HOME=/templateflow" >> job
  108. # define the main command:
  109. echo "singularity run -B ${PATH_INPUT}:/input:ro \
  110. -B ${PATH_OUTPUT}:/output:rw -B ${PATH_WORK}:/work:rw \
  111. -B ${PATH_TEMPLATEFLOW}:/templateflow:rw \
  112. ${PATH_CONTAINER} /input/ /output/ participant --participant-label ${SUB_PAD} \
  113. --session-id ${SES} -w /work/ --verbose-reports --write-graph \
  114. --n_cpus ${N_CPUS} --mem_gb ${MEM_GB} --no-sub" >> job
  115. # submit job to cluster queue and remove it to avoid confusion:
  116. sbatch job
  117. rm -f job
  118. done
  119. done