Chapter 16 FSL eddy

Log onto the remote computer.

16.1 Job Script

On the remote computer create job script.

vi ~/scripts/ACAP/

Copy and paste.


#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

username=`id -un`
module load lib/openblas/0.2.20-gnu
module load fsl/6.0.0
export ANTSPATH=/home/${username}/apps/ants/bin/

# Location of raw BIDS organized dwi images

# 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

# 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))
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 \

# 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 \

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

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

Create batch script.

vi ~/scripts/ACAP/

Copy and paste.

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/ \
  ${subjid} \
  sleep 1

16.3 Submit Jobs with Batch Script

Submit jobs.

sh ~/scripts/ACAP/

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


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 \ \