diff --git a/bedpostx b/bedpostx index 9a20960e55ac95868c559ec4e1d7416bbaced8cd..e1ee2a267884548302f4fdb68c243d645e567b7d 100755 --- a/bedpostx +++ b/bedpostx @@ -5,10 +5,10 @@ # SHCOPYRIGHT if [ "x$SGE_ROOT" = "x" ] ; then - if [ -f /usr/local/share/sge-6.0/default/common/settings.sh ] ; then - . /usr/local/share/sge-6.0/default/common/settings.sh - else if [ -f /usr/local/sge-6/default/common/settings.sh ] ; then - . /usr/local/sge-6/default/common/settings.sh + if [ -f /usr/local/share/sge/default/common/settings.sh ] ; then + . /usr/local/share/sge/default/common/settings.sh + else if [ -f /usr/local/sge/default/common/settings.sh ] ; then + . /usr/local/sge/default/common/settings.sh else echo "bedpostX: Fatal error: couldn\'t locate SGE_ROOT\!" exit 255 @@ -27,7 +27,7 @@ Usage() { echo "-w (ARD weight, more weight means less fibres killed per voxel, default 1)" echo "-b (burnin period, default 1000)" echo "" - exit + exit 1 } make_absolute(){ @@ -104,35 +104,30 @@ mkdir -p ${subjdir}.bedpostX/xfms mailto=`whoami`@fmrib.ox.ac.uk echo Queuing preprocessing stages -preprocid=`qsub -M $mailto -V -q short.q \ - -o ${subjdir}.bedpostX/logs -e ${subjdir}.bedpostX/logs \ - ${FSLDIR}/bin/sge_bedpostX_preproc.sh ${subjdir} | \ - awk '{print $3}'` +preprocid=`${FSLDIR}/bin/fsl_sub -F -l ${subjdir}.bedpostX/logs ${FSLDIR}/bin/sge_bedpostX_preproc.sh ${subjdir}` echo Queuing parallel processing stage -echo I am using this file nslices=`avwval ${subjdir}/data dim3` -bedpostid=`qsub -M $mailto -hold_jid $preprocid -V -q long.q -t 1-$nslices \ - -o ${subjdir}.bedpostX/logs -e ${subjdir}.bedpostX/logs \ - ${FSLDIR}/bin/sge_bedpostX_single_slice.sh $subjdir $nfibres $fudge $burnin | \ - awk '{print $3}' | awk -F. '{print $1}'` +[ -f ${subjdir}.bedpostX/commands.txt ] && rm ${subjdir}.bedpostX/commands.txt +for ((slice=0; slice < $nslices; slice++)) ; do + echo "${FSLDIR}/bin/sge_bedpostX_single_slice.sh $subjdir $nfibres $fudge $burnin $slice" \ + >> ${subjdir}.bedpostX/commands.txt +done +bedpostid=`${FSLDIR}/bin/fsl_sub -j $preprocid -l ${subjdir}.bedpostX/logs -M $mailto -N bedpostx -t ${subjdir}.bedpostX/commands.txt` echo Queuing post processing stage -mergeid=`qsub -M $mailto -hold_jid $bedpostid -V -q short.q \ - -o ${subjdir}.bedpostX/logs -e ${subjdir}.bedpostX/logs \ - ${FSLDIR}/bin/sge_bedpostX_postproc.sh $subjdir | \ - awk '{print $3}'` +mergeid=`${FSLDIR}/bin/fsl_sub -j $bedpostid -F -l ${subjdir}.bedpostX/logs ${FSLDIR}/bin/sge_bedpostX_postproc.sh $subjdir` echo echo Type ${subjdir}.bedpostX/monitor to show progress. cat <<EOM > ${subjdir}.bedpostX/monitor -# #!/bin/sh +#!/bin/sh finished=0 logdir=${subjdir}.bedpostX/logs while [ \$finished -eq 0 ] ; do nfin=0 if [ -f \$logdir/bedpost.o$bedpostid.1 ] ; then - nfin=\`cat \$logdir/bedpostX.o$bedpostid.* |\ + nfin=\`cat \$logdir/bedpostx.o$bedpostid.* |\ grep Done | wc -w | awk '{print \$1}'\` fi if [ \$nfin -eq $nslices ] ; then @@ -145,9 +140,9 @@ done EOM chmod +x ${subjdir}.bedpostX/monitor -echo Type ${subjdir}.bedpostX/cancel to terminate the task. +echo Type ${subjdir}.bedpostX/cancel to terminate all the queued tasks. cat <<EOC > ${subjdir}.bedpostX/cancel -# #!/bin/sh +#!/bin/sh qdel $mergeid $bedpostid $preprocid EOC chmod +x ${subjdir}.bedpostX/cancel diff --git a/bedpostx_postproc.sh b/bedpostx_postproc.sh index fb5b3bc9f1a0edf3a30ff408af98cf9c6fb76288..43558a0013d027246a65dd661fe5bec72d597707 100755 --- a/bedpostx_postproc.sh +++ b/bedpostx_postproc.sh @@ -1,18 +1,17 @@ #!/bin/sh -subjdir=$1 - +#$ -cwd +#$ -q short.q #$ -S /bin/sh #$ -V #$ -N bpx_postproc #$ -m ae +subjdir=$1 numfib=`${FSLDIR}/bin/imglob -oneperimage ${subjdir}.bedpostX/diff_slices/data_slice_0000/f*samples |wc -w` - -fib=1; -while [ $fib -le $numfib ];do +for ((fib=1; fib<=$numfib; fib++));do ${FSLDIR}/bin/avwmerge -z ${subjdir}.bedpostX/merged_th${fib}samples `${FSLDIR}/bin/imglob -oneperimage ${subjdir}.bedpostX/diff_slices/data_slice_*/th${fib}samples` ${FSLDIR}/bin/avwmerge -z ${subjdir}.bedpostX/merged_ph${fib}samples `${FSLDIR}/bin/imglob -oneperimage ${subjdir}.bedpostX/diff_slices/data_slice_*/ph${fib}samples` ${FSLDIR}/bin/avwmerge -z ${subjdir}.bedpostX/merged_f${fib}samples `${FSLDIR}/bin/imglob -oneperimage ${subjdir}.bedpostX/diff_slices/data_slice_*/f${fib}samples` @@ -21,8 +20,6 @@ while [ $fib -le $numfib ];do ${FSLDIR}/bin/avwmaths ${subjdir}.bedpostX/merged_f${fib}samples -Tmean ${subjdir}.bedpostX/mean_f${fib}samples ${FSLDIR}/bin/make_dyadic_vectors ${subjdir}.bedpostX/merged_th${fib}samples ${subjdir}.bedpostX/merged_ph${fib}samples ${subjdir}.bedpostX/nodif_brain_mask ${subjdir}.bedpostX/dyads${fib} - - fib=`echo "$fib +1"|bc`; done echo Removing intermediate files diff --git a/bedpostx_preproc.sh b/bedpostx_preproc.sh index b848aae47b64450d4602c4f4d39ae749a4b275c4..1bf5a061c25f84bf92db9e841eceab554c49c621 100755 --- a/bedpostx_preproc.sh +++ b/bedpostx_preproc.sh @@ -1,11 +1,13 @@ #!/bin/sh -subjdir=$1 - +#$ -cwd +#$ -q short.q #$ -S /bin/sh #$ -V #$ -N bpx_preproc -#$ -m a +#$ -m as + +subjdir=$1 echo Copying files to bedpost directory cp ${subjdir}/bvecs ${subjdir}/bvals ${subjdir}.bedpostX diff --git a/bedpostx_single_slice.sh b/bedpostx_single_slice.sh index c6c96d389c3c8d823f5fd000146f130d8a88ddfc..ab89276f7ed1c517adbe79e2c4ec9d7997488fe4 100755 --- a/bedpostx_single_slice.sh +++ b/bedpostx_single_slice.sh @@ -1,18 +1,25 @@ #!/bin/sh -subjdir=$1 -slice=`expr $SGE_TASK_ID - 1` -slicezp=`${FSLDIR}/bin/zeropad $slice 4` - -#$ -cwd -q long.q +#$ -cwd +#$ -q long.q #$ -S /bin/sh -#$ -V -N bedpostX +#$ -V +#$ -N bedpostx #$ -m a +#$ -o $1.bedpostX/logs -e $1.bedpostX/logs + +subjdir=$1 +nfibres=$2 +fudge=$3 +bi=$4 +slice=$5 + +slicezp=`${FSLDIR}/bin/zeropad $slice 4` ${FSLDIR}/bin/xfibres\ --data=$subjdir/data_slice_$slicezp\ --mask=$subjdir/nodif_brain_mask_slice_$slicezp\ -b $subjdir/bvals -r $subjdir/bvecs\ --forcedir --logdir=$subjdir.bedpostX/diff_slices/data_slice_$slicezp\ - --fudge=$3 --nj=5000 --bi=$4 --se=100 --upe=24 --nfibres=$2 > $subjdir.bedpostX/logs/log$slicezp && echo Done + --fudge=$fudge --nj=5000 --bi=$bi --se=100 --upe=24 --nfibres=$nfibres > $subjdir.bedpostX/logs/log$slicezp && echo Done