Newer
Older
# siena_flow2std - warp flow image into standard space
echo "Usage: siena_flow2std <fileroot2> <fileroot2> [-d]"
}
if [ _$FSLDIR = _ ] ; then
FSLDIR=/usr/local/fsl
export FSLDIR
fi
[ "$2" = "" ] && Usage
[ `${FSLDIR}/bin/imtest $1` = 0 ] && Usage
[ `${FSLDIR}/bin/imtest $2` = 0 ] && Usage
A=`${FSLDIR}/bin/remove_ext $1`
B=`${FSLDIR}/bin/remove_ext $2`
debug=0
for opts in $@ ; do
if [ $opts = -d ] ; then
debug=1
fi
done
# register to MNI152 if not already done, and create halfway2std transform
if [ ! -f ${A}_to_std.mat ] ; then
if [ `${FSLDIR}/bin/imtest ${A}_brain` = 0 ] ; then
${FSLDIR}/bin/flirt -ref ${FSLDIR}/etc/standard/avg152T1_brain -in ${A}_brain -omat ${A}_to_std.mat -o ${A}_to_std
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_std.mat -concat ${A}_to_std.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/avwmaths ${B}_to_${A}_flow -dil -dil -dil -dil -dil -dil -dil -dil -dil -dil -dil -dil -dil -dil ${A}_to_${B}_flow_dilback
${FSLDIR}/bin/avwmaths ${A}_to_${B}_flow_dil -sub ${A}_to_${B}_flow_dilback -div 2 ${A}_to_${B}_flow_dil
/bin/rm ${A}_to_${B}_flow_dilback*
${FSLDIR}/bin/flirt -in ${A}_to_${B}_flow_dil -ref ${FSLDIR}/etc/standard/avg152T1_brain -out ${A}_to_${B}_flow_to_std -applyxfm -init ${A}_halfwayto_${B}_to_std.mat
${FSLDIR}/bin/avwmaths ${A}_to_${B}_flow_to_std -mas ${FSLDIR}/etc/standard/avg152T1_edges ${A}_to_${B}_flow_to_std
${FSLDIR}/bin/ip ${A}_to_${B}_flow_to_std ${A}_to_${B}_flow_to_std 0 -s 10
${FSLDIR}/bin/avwmaths ${A}_to_${B}_flow_to_std -mas ${FSLDIR}/etc/standard/avg152T1_edges ${A}_to_${B}_flow_to_std
/bin/rm -f ${A}_halfwayto_${B}_inv.mat `$FSLDIR/bin/imglob -oneperimage ${A}_brain.* ${A}_to_${B}_flow_dil.* ${A}_to_std.*`