Skip to content
Snippets Groups Projects
siena_flow2tal 1.9 KiB
Newer Older
Mark Jenkinson's avatar
Mark Jenkinson committed
#!/bin/sh

#   SIENAL - Local analysis of SIENA flow field
#
#   Stephen Smith, FMRIB Image Analysis Group
#
#   Copyright (C) 2002-2003 University of Oxford
#
#   SHCOPYRIGHT

Usage() {
    echo "Usage: sienal <fileroot2> <fileroot2> [-d]"
    echo "-d : debug (don't delete intermediate files)"
    exit
}

[ "$1" = "" ] && Usage
[ "$2" = "" ] && Usage
[ ! -f $1.hdr ] && Usage
[ ! -f $2.hdr ] && Usage
A=$1
B=$2
shift 2

if [ _$FSLDIR = _ ] ; then
    FSLDIR=/usr/local/fsl
    export FSLDIR
fi

debug=0

for opts in $@ ; do

    if [ $opts = -d ] ; then
        debug=1
    fi

done

# register to MNI152 if not already done, and create halfway2tal transform
if [ ! -f ${A}_to_tal.mat ] ; then
    if [ ! -f ${A}_brain.hdr ] ; then
	${FSLDIR}/bin/bet $A ${A}_brain
    fi
    ${FSLDIR}/bin/flirt -ref ${FSLDIR}/etc/standard/avg152T1_brain -in ${A}_brain -omat ${A}_to_tal.mat
fi
${FSLDIR}/bin/convert_xfm -omat ${A}_halfwayto_${B}_inv.mat -inverse ${A}_halfwayto_${B}.mat
${FSLDIR}/bin/convert_xfm -omat ${A}_halfwayto_${B}_to_tal.mat -concat ${A}_to_tal.mat ${A}_halfwayto_${B}_inv.mat

# dilate flow image, -> standard space -> mask with ss edge image -> blur -> remask
${FSLDIR}/bin/avwmaths ${A}_to_${B}_flow -dil -dil -dil -dil -dil -dil -dil -dil -dil -dil -dil -dil -dil -dil ${A}_to_${B}_flow_dil
${FSLDIR}/bin/flirt -in ${A}_to_${B}_flow_dil -ref ${FSLDIR}/etc/standard/avg152T1_brain -out ${A}_to_${B}_flow_to_tal -applyxfm -init ${A}_halfwayto_${B}_to_tal.mat
${FSLDIR}/bin/avwmaths ${A}_to_${B}_flow_to_tal -mas ${FSLDIR}/etc/standard/avg152T1_edges ${A}_to_${B}_flow_to_tal
${FSLDIR}/bin/ip ${A}_to_${B}_flow_to_tal ${A}_to_${B}_flow_to_tal 0 -s 10
${FSLDIR}/bin/avwmaths ${A}_to_${B}_flow_to_tal -mas ${FSLDIR}/etc/standard/avg152T1_edges ${A}_to_${B}_flow_to_tal

# cleanup
if [ $debug = 0 ] ; then
    /bin/rm -f ${A}_halfwayto_${B}_inv.mat ${A}_brain.hdr ${A}_brain.img ${A}_to_${B}_flow_dil.hdr ${A}_to_${B}_flow_dil.img
fi