#!/bin/bash
#   Copyright (C) 2016 University of Oxford 
#   SHCOPYRIGHT
set -e -u

if [[ $# -ne 4 ]]
then
    echo "Usage: mist_FA_reg <FA volume> <S0 volume> <reference T1 volume> <output filename>"
fi

fa=$1
s0=$2
t1=$3
faout=$(remove_ext $4)

bet $t1 ${faout}_t1brain

epi_reg --epi=$s0 --t1=$t1 --t1brain=${faout}_t1brain --out=${faout}_s0reg --noclean
flirt -ref ${faout}_t1brain -in $fa -wmseg ${faout}_s0reg_fast_wmseg -init ${faout}_s0reg.mat \
    -omat ${faout}.mat -out ${faout} -schedule $FSLDIR/etc/flirtsch/bbr.sch \
    -cost bbr -bbrtype global_abs -interp spline

