runfmriprep.sh 1.2 KB

12345678910111213141516171819202122232425262728
  1. #!/bin/bash
  2. subid=$1
  3. # create workdir for fmriprep inside the dataset to simplify singularity call
  4. # PWD will be available in the container
  5. mkdir -p .git/tmp/wdir
  6. # pybids (inside fmriprep) will try to read all JSON files in a dataset. In case
  7. # of a recomputation, JSON files of other subjects can be dangling symlinks.
  8. # We prevent pybids from crashing the fmriprep run when it can't read those, by
  9. # wiping them out temporarily via renaming.
  10. # We spare only those that belong to the participant we want to process.
  11. # After job completion, the jsons will be restored.
  12. # See https://github.com/bids-standard/pybids/issues/631 for more information.
  13. find inputs/data -mindepth 2 -name '*.json' -a ! -wholename "$subid" | sed -e "p;s/json/xyz/" | xargs -n2 mv
  14. # execute fmriprep. Its runscript is available as /singularity within the
  15. # container. Custom fmriprep parametrization can be done here.
  16. /singularity inputs/data . participant --participant-label $subid \
  17. -w .git/tmp/wdir --skip-bids-validation \
  18. --use-aroma --fs-license-file code/license.txt
  19. # restore the jsons we have moved out of the way
  20. find inputs/data -mindepth 2 -name '*.xyz' -a ! -wholename "$subid" | sed -e "p;s/xyz/json/" | xargs -n2 mv