runfmriprep.sh 1.3 KB

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