Skip to content
Snippets Groups Projects
Commit beda119d authored by Matthew Webster's avatar Matthew Webster
Browse files

OpenScience master script v1.0

parent e3e149b5
No related branches found
No related tags found
No related merge requests found
#!/bin/bash -e
#################### WIN OpenScience Wrapper version 6.0.1 ##############
#########################################################################
### This script expects to be run in a directory where the user has
### read-write access, all files generated by this script will be
### created in that directory.
#################### Standard set-up functions ##########################
DEFAULTDIR=`pwd`
#### Usage
function usage {
echo "$0: [-d] [-f] [-o]"
echo "OpenScience wrapped version of an analysis."
echo "-d <directory>: Use existing data in <directory> instead of downloading"
echo "-f <directory>: Use existing FSL in <directory> instead of downloading"
echo "-o <directory>: Output to <directory> instead of current directory"
echo ""
}
##### FSL - Download
function downloadFSL {
echo "Installing FSL via internet"
curl -s https://fsl.fmrib.ox.ac.uk/fsldownloads/fslinstaller.py > fslinstaller.py
chmod u+x fslinstaller.py
./fslinstaller.py -V 6.0.1 -q -p -d $1
}
##### FSL - Setup
function setupFSL {
echo "Setting up FSL"
if [ $# -eq 0 ]; then
NEWFSLDIR=${DEFAULTDIR}/fsl
downloadFSL ${NEWFSLDIR}
else
NEWFSLDIR=$1
fi
if [ ! -z "${FSLDIR}" ]; then
PATH=${PATH/$FSLDIR/}
fi
export FSLDIR=${NEWFSLDIR}
export PATH=${FSLDIR}/bin:${PATH}
. ${FSLDIR}/etc/fslconf/fsl.sh
}
##### Data - Setup
function setupData {
echo "Setting up data"
if [ $# -gt 1 ]; then
DATADIR=$2
return
fi
echo "Downloading data via internet"
curl -s $1 | tar -zxf -
DATADIR=${DEFAULTDIR}
}
#################### Standard OpenScience entrypoint ####################
OUTPUTDIR=${DEFAULTDIR}
unset existingFSLDIR
unset existingDATADIR
while getopts "f:d:o:" Option
do
case $Option in
d )
existingDATADIR=$OPTARG
;;
f )
existingFSLDIR=$OPTARG
;;
o )
OUTPUTDIR=$OPTARG
;;
* )
usage
exit 1
;;
esac
done
#################### Analysis-specific URL ############################
DATAURL='https://users.fmrib.ox.ac.uk/~mwebster/data2.tar.gz'
#################### Setup Environment ################################
setupFSL ${existingFSLDIR}
setupData ${DATAURL} ${existingDATADIR}
#################### Start of data processing #########################
echo "Starting analysis"
echo "with FSLDIR:${FSLDIR} DATADIR:${DATADIR} OUTPUTDIR:${OUTPUTDIR}"
#################### Analysis-specific commands #######################
${FSLDIR}/bin/bet ${DATADIR}/structural ${OUTPUTDIR}/structural_brain -f 0.5 -g 0 -m -s
${DATADIR}/scripts/myScript.sh ${OUTPUTDIR}/structural_brain > myOutput.txt
#################### End of Analysis ##################################
echo "Done"
#################### End of data processing ###########################
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment