diff --git a/rubix_parallel.sh b/rubix_parallel.sh
new file mode 100644
index 0000000000000000000000000000000000000000..6ebbc37be0db0c07306b87d2451690ca2c7d4ef4
--- /dev/null
+++ b/rubix_parallel.sh
@@ -0,0 +1,110 @@
+#!/bin/sh
+
+#   Copyright (C) 2012 University of Oxford
+#
+#   Stamatios Sotiropoulos
+
+if [ "x$SGE_ROOT" = "x" ] ; then
+    if [ -f /usr/local/share/sge/default/common/settings.sh ] ; then
+	. /usr/local/share/sge/default/common/settings.sh
+    elif [ -f /usr/local/sge/default/common/settings.sh ] ; then
+	. /usr/local/sge/default/common/settings.sh
+    fi
+fi
+
+Usage() {
+    echo ""
+    echo "Usage: rubix_parallel dataLR maskLR bvecsLR bvalsLR dataHR bvecsHR bvalsHR out_dir nfib nModes modelnum other_rubix_params"
+    echo "       Call rubix help menu, for other_rubix_params (usually need --fsumPrior --dPrior)"
+    echo ""
+    exit 1
+}
+
+[ "$1" = "" ] && Usage
+
+
+
+devel_dir=/home/stam/fsldev/fdt  # Where the binary is 
+script_dir=/home/stam/Rubix_src # Where the scripts are
+
+#option arguments
+burnin=5000
+
+dataLR=`${FSLDIR}/bin/imglob $1`; shift;  #Remove ending if exists
+maskLR=`${FSLDIR}/bin/imglob $1`; shift;
+bvecsLR=$1; shift;
+bvalsLR=$1; shift;
+dataHR=`${FSLDIR}/bin/imglob $1`; shift;
+bvecsHR=$1; shift;
+bvalsHR=$1; shift;
+out_dir=$1; shift;
+nfibres=$1; shift;
+nModes=$1; shift;
+modelnum=$1; shift;
+opts="$*";
+
+#check that all required files exist
+
+if [ ! -e $bvecsLR ]; then
+	echo "bvecsLR not found"
+	exit 1
+fi
+
+if [ ! -e $bvalsLR ]; then
+	echo "$bvalsLR not found"
+	exit 1
+fi
+
+
+if [ ! -e $bvecsHR ]; then
+	echo "bvecsHR not found"
+	exit 1
+fi
+
+if [ ! -e $bvalsHR ]; then
+	echo "$bvalsHR not found"
+	exit 1
+fi
+
+
+if [ `${FSLDIR}/bin/imtest $dataLR` -eq 0 ]; then
+	echo "dataLR not found"
+	exit 1
+fi
+
+if [ `${FSLDIR}/bin/imtest $dataHR` -eq 0 ]; then
+	echo "dataHR not found"
+	exit 1
+fi
+
+if [ `${FSLDIR}/bin/imtest $maskLR` -eq 0 ]; then
+	echo "brain maskLR not found"
+	exit 1
+fi
+
+
+mkdir -p $out_dir 
+mkdir -p $out_dir/diff_slices
+mkdir -p $out_dir/logs
+
+
+nslices=`$FSLDIR/bin/fslval $dataLR dim3`
+
+
+echo Queuing preprocessing stage
+preprocid=`$FSLDIR/bin/fsl_sub -T 60 -R 8000 -N rubix_pre -l $out_dir/logs  $script_dir/rubix_preproc.sh $dataLR $maskLR $dataHR $out_dir`
+
+echo Queuing parallel processing stage
+[ -f $out_dir/commands.txt ] && rm $out_dir/commands.txt
+ slice=0
+ while [ $slice -lt $nslices ]
+ do
+    slicezp=`$FSLDIR/bin/zeropad $slice 4`
+    echo "$devel_dir/rubix --dLR=${out_dir}/${dataLR}_slice_${slicezp} --mLR=${out_dir}/${maskLR}_slice_${slicezp} --rLR=$bvecsLR --bLR=$bvalsLR --dHR=${out_dir}/${dataHR}_newslice_${slicezp} --rHR=$bvecsHR --bHR=$bvalsHR --forcedir --nf=$nfibres --nM=$nModes --bi=$burnin --model=$modelnum --logdir=$out_dir/diff_slices/data_slice_$slicezp ${opts}" >> $out_dir/commands.txt
+    slice=$(($slice + 1))
+ done
+    
+ RubiXid=`${FSLDIR}/bin/fsl_sub -T 1400 -j $preprocid -l $out_dir/logs -N rubix -t $out_dir/commands.txt`
+    
+ echo Queuing post processing stage
+ mergeid=`${FSLDIR}/bin/fsl_sub -T 60 -R 8000 -j $RubiXid -N rubix_post -l $out_dir/logs $script_dir/rubix_postproc.sh $out_dir $dataLR $maskLR $dataHR`
\ No newline at end of file
diff --git a/rubix_postproc.sh b/rubix_postproc.sh
new file mode 100644
index 0000000000000000000000000000000000000000..75ea19a638f854f346f9fa228c9bc7799fbfd998
--- /dev/null
+++ b/rubix_postproc.sh
@@ -0,0 +1,94 @@
+#!/bin/sh
+
+out_dir=$1
+dataLR=$2
+maskLR=$3
+dataHR=$4
+
+
+numfib=`${FSLDIR}/bin/imglob ${out_dir}/diff_slices/data_slice_0000/f*samples* | wc -w | awk '{print $1}'`
+
+fib=1
+while [ $fib -le $numfib ]
+do
+    ${FSLDIR}/bin/fslmerge -z ${out_dir}/merged_th${fib}samples `${FSLDIR}/bin/imglob ${out_dir}/diff_slices/data_slice_*/th${fib}samples*`
+    ${FSLDIR}/bin/fslmerge -z ${out_dir}/merged_ph${fib}samples `${FSLDIR}/bin/imglob ${out_dir}/diff_slices/data_slice_*/ph${fib}samples*`
+    ${FSLDIR}/bin/fslmerge -z ${out_dir}/merged_f${fib}samples  `${FSLDIR}/bin/imglob ${out_dir}/diff_slices/data_slice_*/f${fib}samples*`
+    ${FSLDIR}/bin/fslmaths ${out_dir}/merged_f${fib}samples -Tmean ${out_dir}/mean_f${fib}samples
+    ${FSLDIR}/bin/make_dyadic_vectors ${out_dir}/merged_th${fib}samples ${out_dir}/merged_ph${fib}samples ${out_dir}/mean_f${fib}samples ${out_dir}/dyads${fib} 95
+    fib=$(($fib + 1))
+done
+
+
+if [ `${FSLDIR}/bin/imtest ${out_dir}/diff_slices/data_slice_0000/mean_dsamples` -eq 1 ];then
+    ${FSLDIR}/bin/fslmerge -z ${out_dir}/mean_dsamples `${FSLDIR}/bin/imglob ${out_dir}/diff_slices/data_slice_*/mean_dsamples*`
+fi
+
+if [ `${FSLDIR}/bin/imtest ${out_dir}/diff_slices/data_slice_0000/mean_S0samples` -eq 1 ];then
+    ${FSLDIR}/bin/fslmerge -z ${out_dir}/mean_S0samples `${FSLDIR}/bin/imglob ${out_dir}/diff_slices/data_slice_*/mean_S0samples*`
+fi
+
+if [ `${FSLDIR}/bin/imtest ${out_dir}/diff_slices/data_slice_0000/mean_tausamples` -eq 1 ];then
+    ${FSLDIR}/bin/fslmerge -z ${out_dir}/mean_tausamples `${FSLDIR}/bin/imglob ${out_dir}/diff_slices/data_slice_*/mean_tausamples*`
+fi
+
+if [ `${FSLDIR}/bin/imtest ${out_dir}/diff_slices/data_slice_0000/mean_tau_LRsamples` -eq 1 ];then
+    ${FSLDIR}/bin/fslmerge -z ${out_dir}/mean_tau_LRsamples `${FSLDIR}/bin/imglob ${out_dir}/diff_slices/data_slice_*/mean_tau_LRsamples*`
+fi
+
+if [ `${FSLDIR}/bin/imtest ${out_dir}/diff_slices/data_slice_0000/mean_S0_LRsamples` -eq 1 ];then
+    ${FSLDIR}/bin/fslmerge -z ${out_dir}/mean_S0_LRsamples `${FSLDIR}/bin/imglob ${out_dir}/diff_slices/data_slice_*/mean_S0_LRsamples*`
+fi
+
+if [ `${FSLDIR}/bin/imtest ${out_dir}/diff_slices/data_slice_0000/En_Lik_LRsamples` -eq 1 ];then
+    ${FSLDIR}/bin/fslmerge -z ${out_dir}/En_Lik_LRsamples `${FSLDIR}/bin/imglob ${out_dir}/diff_slices/data_slice_*/En_Lik_LRsamples*`
+fi
+
+if [ `${FSLDIR}/bin/imtest ${out_dir}/diff_slices/data_slice_0000/En_Prior_LRsamples` -eq 1 ];then
+    ${FSLDIR}/bin/fslmerge -z ${out_dir}/En_Prior_LRsamples `${FSLDIR}/bin/imglob ${out_dir}/diff_slices/data_slice_*/En_Prior_LRsamples*`
+fi
+
+if [ `${FSLDIR}/bin/imtest ${out_dir}/diff_slices/data_slice_0000/mean_dstd_samples` -eq 1 ];then
+    ${FSLDIR}/bin/fslmerge -z ${out_dir}/mean_dstd_samples `${FSLDIR}/bin/imglob ${out_dir}/diff_slices/data_slice_*/mean_dstd_samples*`
+fi
+
+if [ `${FSLDIR}/bin/imtest ${out_dir}/diff_slices/data_slice_0000/HRbrain_mask` -eq 1 ];then
+    ${FSLDIR}/bin/fslmerge -z ${out_dir}/HRbrain_mask `${FSLDIR}/bin/imglob ${out_dir}/diff_slices/data_slice_*/HRbrain_mask*`
+fi
+
+if [ `${FSLDIR}/bin/imtest ${out_dir}/diff_slices/data_slice_0000/mean_fsumPriorMode_LRsamples` -eq 1 ];then
+    ${FSLDIR}/bin/fslmerge -z ${out_dir}/mean_fsumPriorMode_LRsamples `${FSLDIR}/bin/imglob ${out_dir}/diff_slices/data_slice_*/mean_fsumPriorMode_LRsamples*`
+fi
+
+if [ `${FSLDIR}/bin/imtest ${out_dir}/diff_slices/data_slice_0000/mean_dPriorMode_LRsamples` -eq 1 ];then
+    ${FSLDIR}/bin/fslmerge -z ${out_dir}/mean_dPriorMode_LRsamples `${FSLDIR}/bin/imglob ${out_dir}/diff_slices/data_slice_*/mean_dPriorMode_LRsamples*`
+fi
+
+numModes=`${FSLDIR}/bin/imglob ${out_dir}/diff_slices/data_slice_0000/Pk*samples* | wc -w | awk '{print $1}'`
+
+mode=1
+while [ $mode -le $numModes ]
+do
+    ${FSLDIR}/bin/fslmerge -z ${out_dir}/merged_Pth${mode}samples `${FSLDIR}/bin/imglob ${out_dir}/diff_slices/data_slice_*/Pth${mode}samples*`
+    ${FSLDIR}/bin/fslmerge -z ${out_dir}/merged_Pph${mode}samples `${FSLDIR}/bin/imglob ${out_dir}/diff_slices/data_slice_*/Pph${mode}samples*`
+    ${FSLDIR}/bin/fslmerge -z ${out_dir}/merged_Pk${mode}samples  `${FSLDIR}/bin/imglob ${out_dir}/diff_slices/data_slice_*/Pk${mode}samples*`
+    ${FSLDIR}/bin/fslmaths ${out_dir}/merged_Pk${mode}samples -Tmean ${out_dir}/mean_Pk${mode}samples
+    ${FSLDIR}/bin/make_dyadic_vectors ${out_dir}/merged_Pth${mode}samples ${out_dir}/merged_Pph${mode}samples ${out_dir}/mean_Pk${mode}samples ${out_dir}/Pdyads${mode}
+    mode=$(($mode + 1))
+done
+
+
+echo Removing intermediate files
+
+if [ `imtest ${out_dir}/merged_th1samples` -eq 1 ];then
+  if [ `imtest ${out_dir}/merged_ph1samples` -eq 1 ];then
+    if [ `imtest ${out_dir}/merged_f1samples` -eq 1 ];then
+      rm -rf ${out_dir}/diff_slices
+      rm -f ${out_dir}/${dataLR}_slice_*
+      rm -f ${out_dir}/${dataHR}_newslice_* 
+      rm -f ${out_dir}/${maskLR}_slice_*
+    fi
+  fi
+fi
+
+echo Done
\ No newline at end of file
diff --git a/rubix_preproc.sh b/rubix_preproc.sh
new file mode 100644
index 0000000000000000000000000000000000000000..fe23981f66c9191c7d2ba8a2c1d30da4a86f8d7b
--- /dev/null
+++ b/rubix_preproc.sh
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+dataLR=$1
+maskLR=$2
+dataHR=$3
+out_dir=$4
+
+${FSLDIR}/bin/fslslice $dataLR $out_dir/$dataLR
+${FSLDIR}/bin/fslslice $maskLR $out_dir/$maskLR
+${FSLDIR}/bin/fslslice $dataHR $out_dir/$dataHR
+
+pixdim3LR=`$FSLDIR/bin/fslval $dataLR pixdim3`
+pixdim3HR=`$FSLDIR/bin/fslval $dataHR pixdim3`
+nslicesLR=`$FSLDIR/bin/fslval $dataLR dim3`
+nslicesHR=`$FSLDIR/bin/fslval $dataHR dim3`
+zratio=`echo "scale=0; $pixdim3LR / $pixdim3HR" | bc -l`
+
+slice=0
+while [ $slice -lt $nslicesLR ]
+do
+    slicezp=`$FSLDIR/bin/zeropad $slice 4`
+    count=$zratio
+    arr_cnt=0
+    while [ $count -ge 1 ]
+    do 
+	HRslice=`echo "( ( $slice + 1 ) * $zratio ) - $count" | bc -l`
+	HRslicezp=`$FSLDIR/bin/zeropad $HRslice 4`
+	filenames[arr_cnt]=${out_dir}/${dataHR}_slice_${HRslicezp}
+	count=$(($count - 1))
+	arr_cnt=$(($arr_cnt + 1))
+    done
+    fslmerge -z ${out_dir}/${dataHR}_newslice_${slicezp} `echo ${filenames[*]}` 
+    slice=$(($slice + 1))
+done
+
+rm -f ${out_dir}/${dataHR}_slice_*
+
+echo Done