Chapter 16 FSL eddy
Log onto the remote computer.
16.1 Job Script
On the remote computer create job script.
vi ~/scripts/ACAP/fsl-eddy-job.sh
Copy and paste.
#!/bin/bash
#SBATCH --time=06: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`
module load lib/openblas/0.2.20-gnu
module load fsl/6.0.0
export ANTSPATH=/home/${username}/apps/ants/bin/
PATH=${ANTSPATH}:${PATH}
# Location of raw BIDS organized dwi images
DATA_DIR=/work/${username}/BIDS/ACAP/${1}/${2}
# Output of FSL processed data
mkdir -p /work/${username}/data/ACAP/fsl/${1}_${2}_acq-b900
cd /work/${username}/data/ACAP/fsl/${1}_${2}_acq-b900
pwd
# Copy over and rename bval/bvec files
cp -v ${DATA_DIR}/dwi/${1}_${2}_acq-b900_dwi.bval bvals
cp -v ${DATA_DIR}/dwi/${1}_${2}_acq-b900_dwi.bvec bvecs
# Copy dwi.nii.gz file
cp -v ${DATA_DIR}/dwi/${1}_${2}_acq-b900_dwi.nii.gz dwi.nii.gz
# Create acqparams.txt file
printf "0 -1 0 0.1" > acqparams.txt
# Create index.txt file
myVar=($(wc -w bvals))
indx=""
for ((i=1; i<=$myVar; i+=1)); do indx="$indx 1"; done
echo $indx > index.txt
# FSL Brain Extraction Tool (bet)
bet \
${DATA_DIR}/dwi/${1}_${2}_acq-b900_dwi.nii.gz \
dwi \
-f 0.05 \
-g 0 \
-m \
-n
# FSL eddy current and motion correction (using FSL eddy)
eddy_openmp \
--imain=dwi.nii.gz \
--mask=dwi_mask.nii.gz \
--bvals=bvals \
--bvecs=bvecs \
--acqp=acqparams.txt \
--index=index.txt \
--out=ecmoco \
--ref_scan_no=0 \
--ol_nstd=4 \
--verbose
16.2 Batch Script
First check that your subjid
and ses
are correct.
for i in $(find /work/ashley.ware/BIDS/ACAP/ -name "*b900_dwi.nii.gz"); do
subjid=`echo $i | cut -d "/" -f6`
ses=`echo $i | cut -d "/" -f7`
echo $subjid
echo $ses
done
If everything is correct then you can create your batch file.
Create batch script.
vi ~/scripts/ACAP/fsl-eddy-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 "*b900_dwi.nii.gz"); 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/fsl-eddy-job.sh \
${subjid} \
${ses}
sleep 1
done
16.3 Submit Jobs with Batch Script
Submit jobs.
sh ~/scripts/ACAP/fsl-eddy-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*
16.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/fsl
Then sync the data from the remote computer to your local computer.
rsync -rauv \
ashley.ware@arc.ucalgary.ca:/work/ashley.ware/data/ACAP/fsl/ \
/Volumes/bobo/data/ACAP/fsl/