Chapter 4 MRIQC

On the remote computer make output directory.

mkdir -p /work/ashley.ware/data/ACAP/mriqc

4.1 Job Script

Create job script.

vi ~/scripts/ACAP/mriqc-job.sh

Copy and paste.

#!/bin/bash

#SBATCH --time=10:00:00   # walltime
#SBATCH --ntasks=1   # number of processor cores (i.e. tasks)
#SBATCH --nodes=1   # number of nodes
#SBATCH --mem-per-cpu=16G  # memory per CPU core

# LOAD ENVIRONMENTAL VARIABLES
username=`id -un`

# INSERT CODE, AND RUN YOUR PROGRAMS HERE
echo ${1} ${2}
singularity run \
--bind /work/${username}/BIDS/ACAP:/data:ro \
--bind /work/${username}/data/ACAP/mriqc:/out \
/home/${username}/apps/mriqc.img \
/data \
/out \
participant \
--participant_label ${1} \
--session-id ${2} \
-m T1w \
--no-sub

4.2 Batch Script

First check that your subjid and ses are correct.

for i in $(find /work/ashley.ware/BIDS/ACAP/ -name "*T1w.nii"); do
  subjid=`echo $i | cut -d "/" -f6`
  ses=`echo $i | cut -d "/" -f7`
  echo $subjid
done

If everything is correct then you can create your batch file.

Create batch script.

vi ~/scripts/ACAP/mriqc-batch.sh

Copy and paste.

#!/bin/bash
curTime=`date +"%Y%m%d-%H%M%S"`
username=`id -un`
mkdir -p ~/logfiles/ACAP/${curTime}
for i in $(find /work/${username}/BIDS/ACAP/ -name "*T1w.nii"); do
  subjid=`echo $i | cut -d "/" -f6`
  ses=`echo $i | cut -d "/" -f7`
  sbatch \
  -o ~/logfiles/ACAP/${curTime}/output-${subjid}_${ses}.txt \
  -e ~/logfiles/ACAP/${curTime}/error-${subjid}_${ses}.txt \
  ~/scripts/ACAP/mriqc-job.sh \
  ${subjid:4} \
  ${ses:4}
  sleep 1
done

4.3 Submit Jobs with Batch Script

Submit jobs.

sh ~/scripts/ACAP/mriqc-batch.sh

You can check the status of your jobs by checking if it is running or pending.

squeue

You can check the outputs.

tail -n 5 ~/logfiles/ACAP/<date>/output*

4.4 Download Directory / Sync Directory with Arc

Back on your local computer make sure you have the directory already.

mkdir -p /Volumes/bobo/data/ACAP/mriqc

Then sync the data from the remote computer to your local computer.

rsync -rauv \
ashley.ware@arc.ucalgary.ca:/work/ashley.ware/data/ACAP/mriqc/ \
/Volumes/bobo/data/ACAP/mriqc/