Skip to content
Snippets Groups Projects
Commit f6194ab2 authored by Mark Jenkinson's avatar Mark Jenkinson
Browse files

minor, but useful, touches

parent 2a369247
No related branches found
No related tags found
No related merge requests found
......@@ -2,7 +2,7 @@
/* avwcpgeom.c - Copy certain parts of an AVW header
Stephen Smith, FMRIB Image Analysis Group
Mark Jenkinson and Stephen Smith, FMRIB Image Analysis Group
Copyright (C) 2001 University of Oxford */
......@@ -36,8 +36,10 @@ int main(argc,argv)
{
/* struct dsr hdr, hdr2; */
FSLIO *src = NULL, *dest = NULL;
short x, y, z, v, copydim=1, t;
short x, y, z, v, copydim=1, t, scode, qcode, dt=-1;
float vx, vy, vz, tr;
int filetype;
mat44 smat, qmat;
void *buffer = NULL;
char desthdrname[10000];
......@@ -72,9 +74,12 @@ int main(argc,argv)
strcpy(desthdrname,dest->niftiptr->fname);
/* store the filetype and datatype */
filetype = FslGetFileType(dest);
FslGetDataType(dest,&dt);
FslClose(dest);
/* ...and now reopen destination for writing */
dest = FslOpen(desthdrname, "wb");
dest = FslXOpen(desthdrname, "wb", filetype);
FslCloneHeader(dest,src);
......@@ -93,12 +98,18 @@ int main(argc,argv)
/* hdr2.dime.dim[i]=hdr.dime.dim[i]; */
/* } */
FslGetVoxDim(src, &vx, &vy, &vz, &tr);
FslSetVoxDim(dest, vx, vy, vz, tr);
if (copydim) {
FslGetDim(src, &x, &y, &z, &v);
FslSetDim(src, x, y, z, v);
}
scode = FslGetStdXform(src,&smat);
FslSetStdXform(dest,scode,smat);
qcode = FslGetRigidXform(src,&qmat);
FslSetRigidXform(dest,qcode,qmat);
FslGetVoxDim(src, &vx, &vy, &vz, &tr);
FslSetVoxDim(dest, vx, vy, vz, tr);
if (copydim) {
FslGetDim(src, &x, &y, &z, &v);
FslSetDim(src, x, y, z, v);
}
/* }}} */
/* {{{ write destination */
......@@ -106,6 +117,9 @@ int main(argc,argv)
/* if ( doswap ) */
/* swap_hdr(&hdr2); */
/* Preserve the datatype */
FslSetDataType(dest,dt);
FslWriteHeader(dest);
FslWriteVolumes(dest, buffer, v);
FslClose(dest);
......
......@@ -23,10 +23,10 @@ storedval=$FSLOUTPUTTYPE
FSLOUTPUTTYPE=$1
export FSLOUTPUTTYPE
oldfile=$2
oldfile=`$FSLDIR/bin/remove_ext $2`
if [ $# -ge 3 ] ; then
newfile=$3
newfile=`$FSLDIR/bin/remove_ext $3`
inplace=0
else
newfile=`$FSLDIR/bin/tmpnam`
......@@ -49,7 +49,9 @@ fi
# for inplace stuff remove and copy old one
if [ $inplace = 1 ] ; then
$FSLDIR/bin/imrm $oldfile
if [ `$FSLDIR/bin/imtest $newfile` = 1 ] ; then
$FSLDIR/bin/imrm $oldfile
fi
$FSLDIR/bin/immv $newfile $oldfile
fi
......
......@@ -23,12 +23,14 @@ if [ _$FSLDIR = _ ] ; then
export FSLDIR
fi
EDITOR=pico
if [ X$EDITOR = X ] ; then
EDITOR=pico
fi
if [ $# -ge 2 ] ; then
EDITOR=$2
fi
tmpbase=`${FSLDIR}/bin/tmpnam`;
${FSLDIR}/bin/avwhd -x $1 > ${tmpbase}
${FSLDIR}/bin/avwhd -x $1 > ${tmpbase} || exit
${EDITOR} ${tmpbase}
${FSLDIR}/bin/avwcreatehd ${tmpbase} $1
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