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

This commit was manufactured by cvs2svn to create tag 'fsl-4_0_1'.

Sprout from master 2007-08-29 14:00:18 UTC Stephen Smith <steve@fmrib.ox.ac.uk> '*** empty log message ***'
Delete:
    avwconv.cc
    avwfixfloat.cc
    tests/avw2ascii_test.sh
    tests/avwcc_test.sh
    tests/avwcpgeom_test.sh
    tests/avwcreatehd_test.sh
    tests/avwhd_test.sh
    tests/avwinterleave_test.sh
    tests/avwmaths_test.sh
    tests/avwmerge_test.sh
    tests/avwnvols_test.sh
    tests/avwroi_test.sh
    tests/avwsplit_test.sh
    tests/header.xml
    tests/run_alltests.sh
parent dbdc0f3b
No related branches found
No related merge requests found
/* fslconv.cc
Mark Jenkinson, FMRIB Image Analysis Group
Copyright (C) 2003-2004 University of Oxford */
/* CCOPYRIGHT */
// General convolution and filtering utility
#define _GNU_SOURCE 1
#define POSIX_SOURCE 1
#include "newimage/newimageall.h"
#include "miscmaths/miscmaths.h"
#include "utils/options.h"
using namespace MISCMATHS;
using namespace NEWIMAGE;
using namespace Utilities;
string title="fslconv (Version 1.0)\nCopyright(c) 2003, University of Oxford (Mark Jenkinson)";
string examples="fslconv [options] -i <input image> -k <kernel image> -o <output image>";
Option<bool> verbose(string("-v,--verbose"), false,
string("switch on diagnostic messages"),
false, no_argument);
Option<bool> help(string("-h,--help"), false,
string("display this message"),
false, no_argument);
Option<bool> forcesum(string("--forcesum"), false,
string("forces convolution to be done by summation"),
false, no_argument);
Option<bool> forcefft(string("--forcefft"), false,
string("forces convolution to be done by fft"),
false, no_argument);
Option<bool> dilate(string("--dilate"), false,
string("perform gray-value dilation (max filter) using kernel as mask"),
false, no_argument);
Option<bool> erode(string("--erode"), false,
string("perform gray-value erosion (min filter) using kernel as mask"),
false, no_argument);
Option<bool> medianfilt(string("--median"), false,
string("perform median filtering using kernel as mask"),
false, no_argument);
Option<float> boxsize(string("-b,--box"), 0,
string("size of box kernel (in mm)"),
false, requires_argument);
Option<float> sphere(string("-s,--sphere"), 0,
string("radius of spherical kernel (in mm)"),
false, requires_argument);
Option<float> gaussian(string("-g,--gaussian"), 0,
string("size of Gaussian kernel (sigma in mm)"),
false, requires_argument);
Option<string> inname(string("-i,--in"), string(""),
string("input filename for base image"),
true, requires_argument);
Option<string> kername(string("-k,--kernel"), string(""),
string("input filename for kernel"),
false, requires_argument);
Option<string> outname(string("-o,--out"), string(""),
string("output filename for convolved image"),
true, requires_argument);
int nonoptarg;
////////////////////////////////////////////////////////////////////////////
// Convolution Kernel Calculations
volume<float> box_kernel(float boxsize, const volume<float>& vin) {
float b = boxsize;
int sx = ((int) floor(b/vin.xdim()/2))*2 + 1;
int sy = ((int) floor(b/vin.ydim()/2))*2 + 1;
int sz = ((int) floor(b/vin.zdim()/2))*2 + 1;
volume<float> vker(sx,sy,sz);
vker.copyproperties(vin);
vker = 1.0;
return vker;
}
volume<float> spherical_kernel(float radius, const volume<float>& vin) {
int sx = MISCMATHS::round(radius/vin.xdim())*2 + 1;
int sy = MISCMATHS::round(radius/vin.ydim())*2 + 1;
int sz = MISCMATHS::round(radius/vin.zdim())*2 + 1;
volume<float> vker(sx,sy,sz);
vker.copyproperties(vin);
vker = 0.0;
float dx2=Sqr(vin.xdim());
float dy2=Sqr(vin.ydim());
float dz2=Sqr(vin.zdim());
for (int z=-sz/2; z<=sz/2; z++) {
for (int y=-sy/2; y<=sy/2; y++) {
for (int x=-sx/2; x<=sx/2; x++) {
if ((x*x*dx2+y*y*dy2+z*z*dz2)<=Sqr(radius)) {
vker(x+sx/2,y+sy/2,z+sz/2)=1.0;
}
}
}
}
return vker;
}
volume<float> gaussian_kernel(float sigma, const volume<float>& vin) {
int sx = ((int) ceil(sigma*3/vin.xdim()))*2 + 1;
int sy = ((int) ceil(sigma*3/vin.ydim()))*2 + 1;
int sz = ((int) ceil(sigma*3/vin.zdim()))*2 + 1;
volume<float> vker(sx,sy,sz);
vker.copyproperties(vin);
float dx2=Sqr(vin.xdim());
float dy2=Sqr(vin.ydim());
float dz2=Sqr(vin.zdim());
for (int z=-sz/2; z<=sz/2; z++) {
for (int y=-sy/2; y<=sy/2; y++) {
for (int x=-sx/2; x<=sx/2; x++) {
vker(x+sx/2,y+sy/2,z+sz/2)=exp(-(x*x*dx2+y*y*dy2+z*z*dz2)/(2*sigma*sigma));
}
}
}
return vker;
}
////////////////////////////////////////////////////////////////////////////
// Convolution code
// template <class T, class S>
// int insertpart(volume<T>& v1, const volume<S>& v2)
// {
// for (int z=v2.minz(); z<=v2.maxz(); z++) {
// for (int y=v2.miny(); y<=v2.maxy(); y++) {
// for (int x=v2.minx(); x<=v2.maxx(); x++) {
// v1(x,y,z)=(T) v2(x,y,z);
// }
// }
// }
// return 0;
// }
// template <class T, class S>
// volume<S> extractpart(const volume<T>& v1, const volume<S>& v2,
// const volume<S>& kernel)
// {
// volume<S> vout=v2;
// vout = (S) 0.0;
// int kxoff = (kernel.xsize()-1)/2;
// int kyoff = (kernel.ysize()-1)/2;
// int kzoff = (kernel.zsize()-1)/2;
// for (int z=v2.minz(); z<=v2.maxz(); z++) {
// for (int y=v2.miny(); y<=v2.maxy(); y++) {
// for (int x=v2.minx(); x<=v2.maxx(); x++) {
// vout(x,y,z)=(S) v1(x+kxoff,y+kyoff,z+kzoff);
// }
// }
// }
// return vout;
// }
// float fsllog2(float x)
// {
// // a cygwin annoyance!
// return log(x)/log(2);
// }
volume<float> efficient_convolve(const volume<float>& vin,
const volume<float>& vker)
{
bool usefft=true;
if (forcesum.set()) { usefft=false; }
else if (forcefft.set()) { usefft=true; }
else {
// estimate calculation time for the two methods and pick the best
float offt = 2 * vin.nvoxels() * fsllog2(2 * vin.nvoxels());
float osum = vin.nvoxels() * vker.nvoxels();
float scalefactor = 44; // relative unit operation cost for fft vs sum
usefft = (osum > offt * scalefactor);
}
if (usefft) {
int sx = Max(vin.xsize(),vker.xsize())*2;
int sy = Max(vin.ysize(),vker.ysize())*2;
int sz = Max(vin.zsize(),vker.zsize())*2;
complexvolume vif, vkf;
vif.re().reinitialize(sx,sy,sz);
//vif.re().copyproperties(vin);
vif.re() = 0.0;
vif.im() = vif.re();
vkf = vif;
insertpart(vif.re(),vin);
insertpart(vkf.re(),vker);
fft3(vif);
fft3(vkf);
vif *= vkf;
ifft3(vif);
return extractpart(vif.re(),vin,vker);
} else {
// Direct intensity-based summation method
return convolve(vin,vker);
}
}
////////////////////////////////////////////////////////////////////////////
// Main execution stuff
int do_work(int argc, char* argv[])
{
volume<float> vin, vout, vker;
read_volume(vin,inname.value());
if (boxsize.set()) { vker = box_kernel(boxsize.value(),vin); }
if (sphere.set()) { vker = spherical_kernel(sphere.value(),vin); }
if (gaussian.set()) { vker = gaussian_kernel(gaussian.value(),vin); }
if (kername.set()) { read_volume(vker,kername.value()); }
if (verbose.value()) { print_volume_info(vker,"kernel"); }
if (dilate.value()) {
vout = morphfilter(vin,vker,"dilate");
} else if (erode.value()) {
vout = morphfilter(vin,vker,"erode");
} else if (medianfilt.value()) {
vout = morphfilter(vin,vker,"median");
} else {
if (kername.unset()) { vker /= vker.sum(); }
vout = efficient_convolve(vin,vker);
}
save_volume(vout,outname.value());
return 0;
}
////////////////////////////////////////////////////////////////////////////
int main(int argc,char *argv[])
{
Tracer tr("main");
OptionParser options(title, examples);
try {
options.add(inname);
options.add(outname);
options.add(kername);
options.add(gaussian);
options.add(boxsize);
options.add(sphere);
options.add(dilate);
options.add(erode);
options.add(medianfilt);
options.add(forcesum);
options.add(forcefft);
options.add(verbose);
options.add(help);
nonoptarg = options.parse_command_line(argc, argv);
// line below stops the program if the help was requested or
// a compulsory option was not set
if ( (help.value()) || (!options.check_compulsory_arguments(true)) ||
(kername.unset() && boxsize.unset() && sphere.unset()
&& gaussian.unset()) )
{
options.usage();
exit(EXIT_FAILURE);
}
} catch(X_OptionError& e) {
options.usage();
cerr << endl << e.what() << endl;
exit(EXIT_FAILURE);
} catch(std::exception &e) {
cerr << e.what() << endl;
}
// Call the local functions
return do_work(argc,argv);
}
/* avwfixfloat.cc
Mark Jenkinson, FMRIB Image Analysis Group
Copyright (C) 2003 University of Oxford */
/* CCOPYRIGHT */
#include <math.h>
#include <iostream>
#include <string>
#include "newimage/newimageall.h"
using namespace NEWIMAGE;
void dump_float(float *fptr) {
char *cptr;
cptr = (char *) fptr;
cerr << (int) *cptr << " , " << (int) *(cptr+1) << " , "
<< (int) *(cptr+2) << " , " << (int) *(cptr+3) << " ";
}
// void check_volume(const volume4D<float>& vol1) {
// long int count=0;
// float val, sum=0.0;
// for (int t=0; t<vol1.tsize(); t++) {
// for (int z=0; z<vol1.zsize(); z++) {
// for (int y=0; y<vol1.ysize(); y++) {
// for (int x=0; x<vol1.xsize(); x++) {
// count++;
// val = vol1(x,y,z,t);
// sum += val;
// }
// }
// }
// }
// }
int main(int argc, char *argv[])
{
if (argc<2) {
cerr << "Usage: " << argv[0] << " <input_volume> [output_volume] [-v]"
<< endl;
return -1;
}
string outname="";
bool verbose = false;
if (argc>=3) {
outname = argv[2];
if (outname == "-v" ) {
verbose = true;
outname = "";
}
}
string optarg;
if (argc>=4) {
optarg = argv[3];
if (optarg=="-v") {
verbose = true;
}
}
volume4D<float> vol1;
volumeinfo vinfo;
read_volume4D(vol1,argv[1],vinfo);
long int count=0, badcount=0, nancount=0;
float val, sum=0;
for (int t=0; t<vol1.tsize(); t++) {
for (int z=0; z<vol1.zsize(); z++) {
for (int y=0; y<vol1.ysize(); y++) {
for (int x=0; x<vol1.xsize(); x++) {
count++;
if (verbose) {
cerr << "x,y,z,t = " << x <<","<<y<<","<<z<<","<<t<<" : ";
dump_float(&vol1(x,y,z,t));
}
char *cptr;
cptr = (char *) &(vol1(x,y,z,t));
int ival0 = (int) *cptr;
int ival1 = (int) *(cptr+1);
int ival2 = (int) *(cptr+2);
int ival3 = (int) *(cptr+3);
if ( ( (ival3==0) && ( (ival0!=0) || (ival1!=0) || (ival2!=0) ) ) ||
(ival3<-125) )
{
badcount++;
if (verbose) {
cerr << "BAD VALUE DETECTED - fixing it" << endl;
dump_float((float *) cptr); cerr << endl;
}
*(cptr+0) = 0;
*(cptr+1) = 0;
*(cptr+2) = 0;
*(cptr+3) = 0;
}
if (! finite(vol1(x,y,z,t))) {
nancount++;
vol1(x,y,z,t) = 0.0;
}
val = vol1(x,y,z,t);
sum += val;
if (verbose) cerr << " :: " << vol1(x,y,z,t) << " :: " << endl;
}
if (verbose) cerr << y << ",";
}
if (verbose) cerr << endl << "Z = " << z << endl;
}
if (verbose) cerr << endl << "T = " << t << endl;
}
cout << "Successfully parsed volume" << endl;
cout << "Found " << badcount << " invalid elements out of " << count << endl;
cout << "Found " << nancount << " non-finite elements out of " << count
<< endl;
if (verbose) print_volume_info(vol1,"Volume");
if (outname.size()>0) {
cout << "Saving volume ... " << endl;
save_volume4D(vol1,outname,vinfo);
cout << "done" << endl;
}
}
#!/bin/sh
#test 3D volume
avw2ascii $FSLTESTDIR/common/filtered_func_data.nii.gz test
../avw2ascii++ $FSLTESTDIR/common/filtered_func_data.nii.gz test2
flag=0
i=0
while [ $i -lt 100 ]
do
if [ $i -lt 10 ]
then
cmp test0000${i} test20000${i}
else
cmp test000${i} test2000${i}
fi
j=$?
echo $i $j
if [ $j -ne 0 ]
then
echo "Problem found in this comparision"
flag=1
fi
i=`expr $i + 1`
done
rm test*
echo ""
if [ $flag -ne 0 ]
then
echo "non-zero comparison; possible problem with avw2ascii++"
else
echo "All comparisons zero. No problems detected with avw2ascii++"
fi
\ No newline at end of file
#!/bin/sh
#test 3D volume
echo "Running awcc non-compliant voxel dimension test"
avwcc $FSLTESTDIR/common/avg152T1_brain.img $FSLTESTDIR/common/filtered_func_data.nii.gz > test
../avwcc++ $FSLTESTDIR/common/avg152T1_brain.img $FSLTESTDIR/common/filtered_func_data.nii.gz > test2
flag=0
cmp test test2
j=$?
echo $j
if [ $j -ne 0 ]
then
echo "Problem found in this comparision"
flag=1
fi
rm test*
avwcc $FSLTESTDIR/common/filtered_func_data.nii.gz $FSLTESTDIR/common/filtered_func_data.nii.gz > test
../avwcc++ $FSLTESTDIR/common/filtered_func_data.nii.gz $FSLTESTDIR/common/filtered_func_data.nii.gz > test2
flag=0
cmp test test2
j=$?
echo $j
if [ $j -ne 0 ]
then
echo "Problem found in this comparision"
flag=1
fi
rm test*
echo ""
if [ $flag -ne 0 ]
then
echo "non-zero comparison; possible problem with avwcc"
else
echo "All comparisons zero. No problems detected with avwcc"
fi
\ No newline at end of file
#!/bin/sh
flag=0
cp $FSLTESTDIR/common/filtered_func_data.nii.gz temp.nii.gz
cp $FSLTESTDIR/common/filtered_func_data.nii.gz temp2.nii.gz
avwcpgeom $FSLTESTDIR/common/avg152T1_brain.hdr temp.nii.gz
../avwcpgeom++ $FSLTESTDIR/common/avg152T1_brain.hdr temp2.nii.gz
cmp temp.nii.gz temp2.nii.gz
j=$?
echo $j
if [ $j -ne 0 ]
then
echo "Problem found in 4D:3D comparison in avwcpgeom++"
flag=1
fi
rm temp*
cp $FSLTESTDIR/common/filtered_func_data.nii.gz temp.nii.gz
cp $FSLTESTDIR/common/filtered_func_data.nii.gz temp2.nii.gz
avwcpgeom $FSLTESTDIR/common/avg152T1_brain.hdr temp.nii.gz -d
../avwcpgeom++ $FSLTESTDIR/common/avg152T1_brain.hdr temp2.nii.gz -d
cmp temp.nii.gz temp2.nii.gz
j=$?
echo $j
if [ $j -ne 0 ]
then
echo "Problem found in 4D:3D comparison in avwcpgeom++"
flag=1
fi
rm temp*
cp $FSLTESTDIR/common/avg152T1_brain.hdr temp.hdr
cp $FSLTESTDIR/common/avg152T1_brain.img temp.img
cp $FSLTESTDIR/common/avg152T1_brain.hdr temp2.hdr
cp $FSLTESTDIR/common/avg152T1_brain.img temp2.img
avwcpgeom $FSLTESTDIR/common/filtered_func_data.nii.gz temp
../avwcpgeom++ $FSLTESTDIR/common/filtered_func_data.nii.gz temp2
cmp temp.hdr temp2.hdr
j=$?
echo $j
if [ $j -ne 0 ]
then
echo "Problem found in 3D:4D comparison in avwcpgeom++"
flag=1
fi
cmp temp.img temp2.img
j=$?
echo $j
if [ $j -ne 0 ]
then
echo "Problem found in 3D:4D comparison in avwcpgeom++"
flag=1
fi
rm temp*
cp $FSLTESTDIR/common/avg152T1_brain.hdr temp.hdr
cp $FSLTESTDIR/common/avg152T1_brain.img temp.img
cp $FSLTESTDIR/common/avg152T1_brain.hdr temp2.hdr
cp $FSLTESTDIR/common/avg152T1_brain.img temp2.img
avwcpgeom $FSLTESTDIR/common/filtered_func_data.nii.gz temp -d
../avwcpgeom++ $FSLTESTDIR/common/filtered_func_data.nii.gz temp2 -d
cmp temp.hdr temp2.hdr
j=$?
echo $j
if [ $j -ne 0 ]
then
echo "Problem found in 3D:4D comparison in avwcpgeom++"
flag=1
fi
cmp temp.img temp2.img
j=$?
echo $j
if [ $j -ne 0 ]
then
echo "Problem found in 3D:4D comparison in avwcpgeom++"
flag=1
fi
rm temp*
echo ""
if [ $flag -ne 0 ]
then
echo "non-zero comparison; possible problem with avwcpgeom++"
else
echo "All comparisons zero. No problems detected with avwcpgeom++"
fi
\ No newline at end of file
#!/bin/sh
flag=0
avwcreatehd header.xml temp
../avwcreatehd++ header.xml temp2
cmp temp.nii.gz temp2.nii.gz
j=$?
echo $j
if [ $j -ne 0 ]
then
echo "Problem found in xml header create in avwcreatehd++"
flag=1
fi
rm temp*
avwcreatehd 10 10 10 10 2 2 2 1 0 0 0 4 temp
../avwcreatehd++ 10 10 10 10 2 2 2 1 0 0 0 4 temp2
cmp temp.nii.gz temp2.nii.gz
j=$?
echo $j
if [ $j -ne 0 ]
then
echo "Problem found in manual header create in avecreatehd++"
flag=1
fi
rm temp*
echo ""
if [ $flag -ne 0 ]
then
echo "non-zero comparison; possible problem with avwcreatehd++"
else
echo "All comparisons zero. No problems detected with avwcreatehd++"
fi
\ No newline at end of file
#!/bin/sh
avwhd $FSLTESTDIR/common/avg152T1_brain.hdr > test
../avwhd++ $FSLTESTDIR/common/avg152T1_brain.hdr > test2
flag=0
cmp test test2
j=$?
echo $j
if [ $j -ne 0 ]
then
echo "Problem found in this comparision"
flag=1
fi
rm test*
avwhd $FSLTESTDIR/common/filtered_func_data.nii.gz > test
../avwhd++ $FSLTESTDIR/common/filtered_func_data.nii.gz > test2
cmp test test2
j=$?
echo $j
if [ $j -ne 0 ]
then
echo "Problem found in this comparision"
flag=1
fi
rm test*
avwhd -x $FSLTESTDIR/common/avg152T1_brain.hdr > test
../avwhd++ -x $FSLTESTDIR/common/avg152T1_brain.hdr > test2
cmp test test2
j=$?
echo $j
if [ $j -ne 0 ]
then
echo "Problem found in this comparision"
flag=1
fi
rm test*
avwhd -x $FSLTESTDIR/common/filtered_func_data.nii.gz > test
../avwhd++ -x $FSLTESTDIR/common/filtered_func_data.nii.gz > test2
cmp test test2
j=$?
echo $j
if [ $j -ne 0 ]
then
echo "Problem found in this comparision"
flag=1
fi
rm test*
echo ""
if [ $flag -ne 0 ]
then
echo "non-zero comparison; possible problem with avwhd++"
else
echo "All comparisons zero. No problems detected with avwhd++"
fi
\ No newline at end of file
#!/bin/sh
flag_maths=0
flag_bit=0
avwinterleave $FSLTESTDIR/common/vol0000.nii.gz $FSLTESTDIR/common/vol0001.nii.gz temp1
../avwinterleave++ $FSLTESTDIR/common/vol0000.nii.gz $FSLTESTDIR/common/vol0001.nii.gz temp2
cmp temp1.nii.gz temp2.nii.gz
output2=$?
if [ $output2 -ne 0 ]
then
flag_bit=1
echo "Standard merge failed bit-comparison test in avwinterleave++"
fi
avwmaths temp1 -sub temp2 temp3
output1=`avwstats temp3 -m`
echo "Result of interleave test:" $output1 $output2
if [ $output1 != 0.000000 ];
then
flag_maths=1
echo "standard merge failed maths test in avwinterleave++";
fi
rm temp*
avwinterleave $FSLTESTDIR/common/vol0000.nii.gz $FSLTESTDIR/common/vol0001.nii.gz temp1 -i
../avwinterleave++ $FSLTESTDIR/common/vol0000.nii.gz $FSLTESTDIR/common/vol0001.nii.gz temp2 -i
cmp temp1.nii.gz temp2.nii.gz
output2=$?
if [ $output2 -ne 0 ]
then
flag_bit=1
echo "inverse merge failed bit-comparison test in avwinterleave++"
fi
avwmaths temp1 -sub temp2 temp3
output1=`avwstats temp3 -m`
echo "Result of inverse interleave test:" $output1 $output2
if [ $output1 != 0.000000 ];
then
flag_maths=1
echo "inverse merge failed maths test in avwinterleave++";
fi
rm temp*
echo ""
if [ $flag_maths -ne 0 -o $flag_bit -ne 0 ]
then
echo "non-zero comparison; possible problem with avwinterleave++"
else
echo "All comparisons zero. No problems detected with avwinterleave++"
fi
\ No newline at end of file
#!/bin/sh
#testing avwmaths
flag=0
#avwmaths volume test
for setting in -T -X -Y -Z
do
for loop in mean std max maxn median
do
set2=`echo $setting$loop`
../avwmaths_32R $FSLTESTDIR/common/filtered_func_data.nii.gz $set2 temp
../avwmaths++ $FSLTESTDIR/common/filtered_func_data.nii.gz $set2 temp1 -odt float
avwmaths temp1 -Tmean temp2
avwmaths temp -Tmean temp1
avwmaths temp1 -sub temp2 -abs temp
output1=`avwstats temp -m`
echo "Result of $setting$loop test:" $output1
if [ $output1 != 0.000000 ];
then
flag=1
echo "Possible problem with $setting$loop test in avwmaths++";
fi
rm temp*
done
set2=`echo ${setting}perc`
avwmaths_32R $FSLTESTDIR/common/filtered_func_data.nii.gz $set2 40 temp
../avwmaths++ $FSLTESTDIR/common/filtered_func_data.nii.gz $set2 40 temp1 -odt float
avwmaths temp1 -Tmean temp2
avwmaths temp -Tmean temp1
avwmaths temp1 -sub temp2 -abs temp
output1=`avwstats temp -m`
echo "Result of $set2 test:" $output1
if [ $output1 != 0.000000 ];
then
flag=1
echo "Possible problem with $set2 test in avwmaths++";
fi
rm temp*
set2=`echo ${setting}ar1`
set3=`echo ${setting}mean`
../avwmaths++ $FSLTESTDIR/common/filtered_func_data.nii.gz $set3 tempmean -odt float
if [ $set2 = -Xar1 ]
then
avwmerge -x tempmean tempmean tempmean #2
avwmerge -x tempmean tempmean tempmean #4
avwmerge -x tempmean tempmean tempmean #8
avwmerge -x tempmean tempmean tempmean #16
avwmerge -x tempmean tempmean tempmean tempmean tempmean #32
fi
if [ $set2 = -Yar1 ]
then
avwmerge -y tempmean tempmean tempmean #2
avwmerge -y tempmean tempmean tempmean #4
avwmerge -y tempmean tempmean tempmean #8
avwmerge -y tempmean tempmean tempmean #16
avwmerge -y tempmean tempmean tempmean tempmean tempmean #32
fi
if [ $set2 = -Zar1 ]
then
../avwmerge -z tempout tempmean tempmean tempmean #3
../avwmerge -z tempmean tempout tempout tempout tempout tempout tempout tempout #21
fi
../avwmaths++ $FSLTESTDIR/common/filtered_func_data.nii.gz -sub tempmean tempmean -odt float
../avwmaths_32R tempmean $set2 temp
../avwmaths++ $FSLTESTDIR/common/filtered_func_data.nii.gz $set2 temp1 -odt float
../avwmaths++ temp1 -Tmean temp2
avwmaths temp -Tmean temp1
avwmaths temp1 -sub temp2 -abs temp
output1=`avwstats temp -m`
echo "Result of $set2 test:" $output1
if [ $output1 != 0.000000 ];
then
flag=1
echo "Possible problem with $set2 test in avwmaths++";
fi
rm temp*
done
ip_32R $FSLTESTDIR/common/filtered_func_data.nii.gz temp 0 -t 10 60
../avwmaths++ $FSLTESTDIR/common/filtered_func_data.nii.gz -bptf 10 60 temp1 -odt float
avwmaths temp1 -Tmean temp2
avwmaths temp -Tmean temp1
avwmaths temp1 -sub temp2 -abs temp
output1=`avwstats temp -m`
echo "Result of bptf test:" $output1
limit=0.05 #Good value, test seems sensitive to changes in algorithm/input errors
output2=`echo $output1 $limit | awk '{ print ($1 < $2) ? "passed" : "failed" }' `
echo "$output2"
if [ $output2 != passed ];
then
flag=1
echo "Possible problem with bptf test in avwmaths++";
else echo "bptf test within tolerance";
fi
rm temp*
avwmaths $FSLTESTDIR/common/filtered_func_data.nii.gz -Tmean tempvol
../avwconv --dilate -b 10 -i tempvol -o temp
../avwmaths++ tempvol -kernel box 10 -dilF temp1
avwmaths temp1 -Tmean temp2
avwmaths temp -Tmean temp1
avwmaths temp1 -sub temp2 -abs temp
output1=`avwstats temp -m`
echo "Result of avwconv erosion test:" $output1
limit=0.0001
output2=`echo $output1 $limit | awk '{ print ($1 < $2) ? "passed" : "failed" }' `
echo "$output2"
if [ $output2 != passed ];
then
flag=1
echo "Possible problem with avwconv erosion test in avwmaths++";
else echo "avwconv erosion test within tolerance";
fi
rm temp*
avwmaths $FSLTESTDIR/common/filtered_func_data.nii.gz -Tmean tempvol
../avwconv --erode -b 10 -i tempvol -o temp
../avwmaths++ tempvol -kernel box 10 -eroF temp1
avwmaths temp1 -Tmean temp2
avwmaths temp -Tmean temp1
avwmaths temp1 -sub temp2 -abs temp
output1=`avwstats temp -m`
echo "Result of avwconv dilation edge test:" $output1
limit=0.0001
output2=`echo $output1 $limit | awk '{ print ($1 < $2) ? "passed" : "failed" }' `
echo "$output2"
if [ $output2 != passed ];
then
flag=1
echo "Possible problem with avwconv dilation test in avwmaths++";
else echo "avwconv dilation test within tolerance";
fi
rm temp*
avwmaths $FSLTESTDIR/common/filtered_func_data.nii.gz -Tmean tempvol
avwconv -b 40 -i tempvol -o temp
../avwmaths++ tempvol -kernel box 40 -fmeanu temp1 -odt float
avwmaths temp1 -Tmean temp2
avwmaths temp -Tmean temp1
avwmaths temp1 -sub temp2 -abs temp
output1=`avwstats temp -m`
echo "Result of large box convolve edge test:" $output1
limit=0.0001
output2=`echo $output1 $limit | awk '{ print ($1 < $2) ? "passed" : "failed" }' `
echo "$output2"
if [ $output2 != passed ];
then
flag=1
echo "Possible problem with large box convolve test in avwmaths++";
else echo "large box convolve test within tolerance";
fi
rm temp*
avwmaths $FSLTESTDIR/common/filtered_func_data.nii.gz -Tmean tempvol
../avwconv -b 8 -i tempvol -o temp
../avwmaths++ tempvol -kernel box 8 -fmeanu temp1 -odt float
avwmaths temp1 -Tmean temp2
avwmaths temp -Tmean temp1
avwmaths temp1 -sub temp2 -abs temp
output1=`avwstats temp -m`
echo "Result of small box convolve edge test:" $output1
limit=0.0001
output2=`echo $output1 $limit | awk '{ print ($1 < $2) ? "passed" : "failed" }' `
echo "$output2"
if [ $output2 != passed ];
then
flag=1
echo "Possible problem with small box convolve test in avwmaths++";
else echo "small box convolve test within tolerance";
fi
rm temp*
avwmaths $FSLTESTDIR/common/filtered_func_data.nii.gz -Tmean tempvol
../avwconv -s 12 --median -i tempvol -o temp
../avwmaths++ tempvol -kernel sphere 12 -fmedian temp1
avwmaths temp1 -Tmean temp2
avwmaths temp -Tmean temp1
avwmaths temp1 -sub temp2 -abs temp
output1=`avwstats temp -m`
echo "Result of spherical kernel test:" $output1
limit=0.0001
output2=`echo $output1 $limit | awk '{ print ($1 < $2) ? "passed" : "failed" }' `
echo "$output2"
if [ $output2 != passed ];
then
flag=1
echo "Possible problem with spherical kernel test in avwmaths++";
else echo "spherical kernel test within tolerance";
fi
rm temp*
ip_16SI $FSLTESTDIR/common/filtered_func_data.nii.gz temp 0 -S 3
../avwmaths++ $FSLTESTDIR/common/filtered_func_data.nii.gz -kernel box 12 -fmedian temp1
avwmaths temp1 -Tmean temp2
avwmaths temp -Tmean temp1
avwmaths temp1 -sub temp2 -abs temp
output1=`avwstats temp -m`
echo "Result of ip median box kernel test:" $output1
if [ $output1 != 0.000000 ];
then
flag=1
echo "Possible problem with ip median box kernel test in avwmaths++";
fi
rm temp*
ip_32R $FSLTESTDIR/common/filtered_func_data.nii.gz temp 0 -s 4
../avwmaths++ $FSLTESTDIR/common/filtered_func_data.nii.gz -kernel gauss 4 -fmean temp1 -odt float
avwmaths temp1 -Tmean temp2
avwmaths temp -Tmean temp1
avwmaths temp1 -sub temp2 -abs temp
output1=`avwstats temp -m`
echo "Result of ip gaussian kernel test:" $output1
limit=0.0001
output2=`echo $output1 $limit | awk '{ print ($1 < $2) ? "passed" : "failed" }' `
echo "$output2"
if [ $output2 != passed ];
then
flag=1
echo "Possible problem with ip gaussian kernel test in avwmaths++";
else echo "ip gaussian kernel test within tolerance";
fi
rm temp*
avwmaths_32R $FSLTESTDIR/common/filtered_func_data.nii.gz -roi 10 30 10 30 10 30 0 10 temp
../avwmaths++ $FSLTESTDIR/common/filtered_func_data.nii.gz -roi 10 30 10 30 10 30 0 10 temp1 -odt float
avwmaths temp1 -Tmean temp2
avwmaths temp -Tmean temp1
avwmaths temp1 -sub temp2 -abs temp
output1=`avwstats temp -m`
echo "Result of roi test:" $output1
if [ $output1 != 0.000000 ];
then
flag=1
echo "Possible problem with roi test in avwmaths++";
fi
rm temp*
ip_32R $FSLTESTDIR/common/filtered_func_data.nii.gz temp 90 -m mask1
../avwmaths++ $FSLTESTDIR/common/filtered_func_data.nii.gz -thrp 90 -Tmin -bin mask -odt float
../avwmaths++ $FSLTESTDIR/common/filtered_func_data.nii.gz -mas mask temp1 -odt float
avwmaths temp1 -Tmean temp2
avwmaths temp -Tmean temp1
avwmaths temp1 -sub temp2 -abs temp
output1=`avwstats temp -m`
echo "Result of ip thresholding test:" $output1
limit=1
output2=`echo $output1 $limit | awk '{ print ($1 < $2) ? "passed" : "failed" }' `
echo "$output2"
if [ $output2 != passed ];
then
flag=1
echo "Possible problem with ip thresholding (-thrmt) test in avwmaths++";
else echo "ip thresholding test within tolerance";
fi
rm temp*
rm mask*
for loop in -sub -add -mul -div -mas -max -min
do
avwmaths_32R $FSLTESTDIR/common/filtered_func_data.nii.gz $loop $FSLTESTDIR/common/mask.nii.gz temp
../avwmaths++ $FSLTESTDIR/common/filtered_func_data.nii.gz $loop $FSLTESTDIR/common/mask.nii.gz temp1 -odt float
avwmaths temp1 -Tmean temp2
avwmaths temp -Tmean temp1
avwmaths temp1 -sub temp2 -abs temp
output1=`avwstats temp -m`
echo "Result of $loop volume test:" $output1
if [ $output1 != 0.000000 ];
then
flag=1
echo "Possible problem with $loop volume test in avwmaths++";
fi
rm temp*
done
for loop in -exp -log -sqr -sqrt -abs -edge -bin
do
avwmaths_32R $FSLTESTDIR/common/filtered_func_data.nii.gz $loop temp
../avwmaths++ $FSLTESTDIR/common/filtered_func_data.nii.gz $loop temp1 -odt float
avwmaths temp1 -Tmean temp2
avwmaths temp -Tmean temp1
avwmaths temp1 -sub temp2 -abs temp
output1=`avwstats temp -m`
echo "Result of $loop volume test:" $output1
if [ $output1 != 0.000000 ];
then
flag=1
echo "Possible problem with $loop volume test in avwmaths++";
fi
rm temp*
done
../avwmaths++ $FSLTESTDIR/common/filtered_func_data.nii.gz -exp infvol -odt float
for loop in -nan -nanm
do
avwmaths_32R infvol $loop temp
../avwmaths++ infvol $loop temp1 -odt float
avwmaths temp1 -Tmean temp2
avwmaths temp -Tmean temp1
avwmaths temp1 -sub temp2 -abs temp
output1=`avwstats temp -m`
echo "Result of $loop volume test:" $output1
if [ $output1 != 0.000000 ];
then
flag=1
echo "Possible problem with $loop volume test in avwmaths++";
fi
rm temp*
done
rm infvol*
ip_32R $FSLTESTDIR/common/filtered_func_data.nii.gz temp 0 -i 2000
../avwmaths++ $FSLTESTDIR/common/filtered_func_data.nii.gz -inm 2000 temp1 -odt float
avwmaths temp1 -Tmean temp2
avwmaths temp -Tmean temp1
avwmaths temp1 -sub temp2 -abs temp
output1=`avwstats temp -m`
echo "Result of ip norm test:" $output1
limit=4
output2=`echo $output1 $limit | awk '{ print ($1 < $2) ? "passed" : "failed" }' `
echo "$output2"
if [ $output2 != passed ];
then
flag=1
echo "Possible problem with ip norm (-inm) test in avwmaths++";
else echo "ip norm test within tolerance";
fi
rm temp*
ip_32R $FSLTESTDIR/common/filtered_func_data.nii.gz temp 0 -I 2000
../avwmaths++ $FSLTESTDIR/common/filtered_func_data.nii.gz -ing 2000 temp1 -odt float
avwmaths temp1 -Tmean temp2
avwmaths temp -Tmean temp1
avwmaths temp1 -sub temp2 -abs temp
output1=`avwstats temp -m`
echo "Result of ip global norm test:" $output1
limit=4
output2=`echo $output1 $limit | awk '{ print ($1 < $2) ? "passed" : "failed" }' `
echo "$output2"
if [ $output2 != passed ];
then
flag=1
echo "Possible problem with ip global norm (-ing) test in avwmaths++";
else echo "ip global norm test within tolerance";
fi
rm temp*
for loop in -sub -add -mul -div -thr -uthr -max -min
do
avwmaths_32R $FSLTESTDIR/common/filtered_func_data.nii.gz $loop 14000 temp
../avwmaths++ $FSLTESTDIR/common/filtered_func_data.nii.gz $loop 14000 temp1 -odt float
avwmaths temp1 -Tmean temp2
avwmaths temp -Tmean temp1
avwmaths temp1 -sub temp2 -abs temp
output1=`avwstats temp -m`
echo "Result of $loop data test:" $output1
if [ $output1 != 0.000000 ];
then
flag=1
echo "Possible problem with $loop data test in avwmaths++";
fi
rm temp*
done
rm kernel*
echo ""
if [ $flag -ne 0 ]
then
echo "non-zero comparison; possible problem with avwmaths++"
else
echo "All comparisons zero. No problems detected with avwmaths++"
fi
#!/bin/sh
#test 3D volume
flag=0
for setting in -t -x -y -z
do
avwmerge $setting temp $FSLTESTDIR/common/filtered_func_data.nii.gz $FSLTESTDIR/common/filtered_func_data2.nii.gz
../avwmerge++ $setting temp2 $FSLTESTDIR/common/filtered_func_data.nii.gz $FSLTESTDIR/common/filtered_func_data2.nii.gz
avwmaths temp2 -Tmean temp3
avwmaths temp -Tmean temp2
avwmaths temp3 -sub temp2 temp
output1=`avwstats temp -m`
echo "Result of $setting merge test:" $output1
if [ $output1 != 0.000000 ];
then
flag=1
echo "Possible problem with $setting test in avwmerge++";
fi
rm temp*
done
avwmerge -a temp $FSLTESTDIR/common//vol*
../avwmerge++ -a temp2 $FSLTESTDIR/common/vol*
avwmaths temp2 -Tmean temp3
avwmaths temp -Tmean temp2
avwmaths temp3 -sub temp2 temp
output1=`avwstats temp -m`
echo "Result of -a merge test:" $output1
if [ $output1 != 0.000000 ];
then
flag=1
echo "Possible problem with -a test in avwmerge++";
fi
rm temp*
echo ""
if [ $flag -ne 0 ]
then
echo "non-zero comparison; possible problem with avwmerge++"
else
echo "All comparisons zero. No problems detected with avwmerge++"
fi
\ No newline at end of file
#!/bin/sh
#test 3D volume
flag=0
output1=`../avwnvols++ $FSLTESTDIR/common/avg152T1_brain.img`
output2=`avwnvols $FSLTESTDIR/common/avg152T1_brain.img`
echo "Result of 3D nvols test:" $output1 $output2
if [ $output1 != $output2 ];
then
echo "Possible problem in avwnvols++"
flag=1
fi
#test 4D timeseries
output1=`../avwnvols++ $FSLTESTDIR/common/filtered_func_data.nii.gz`
output2=`avwnvols $FSLTESTDIR/common/filtered_func_data.nii.gz`
echo "Result of 4D 100 frame nvols test:" $output1 $output2
if [ X$output1 != X$output2 ];
then
echo "Possible problem in avwnvols++"
flag=1
fi
echo ""
if [ $flag -ne 0 ]
then
echo "volume count discrepancy; possible problem with avwnvols++"
else
echo "Counts are 1 and 100. No problems detected with avwnvols++"
fi
\ No newline at end of file
#!/bin/sh
flag_maths=0
flag_bit=0
#test 3D volume
avwroi $FSLTESTDIR/common/avg152T1_brain temp1 15 20 15 20 15 20
../avwroi++ $FSLTESTDIR/common/avg152T1_brain temp2 15 20 15 20 15 20
cmp temp1.nii.gz temp2.nii.gz
output2=$?
if [ $output2 -ne 0 ]
then
flag_bit=1
echo "3D roi failed bit-comparison test in avwroi++"
fi
avwmaths temp1 -sub temp2 temp3
output1=`avwstats temp3 -m`
echo "Result of 3D roi test:" $output1 $output2
if [ $output1 != 0.000000 ];
then
flag_maths=1
echo "3D roi failed math test in avwroi++";
fi
rm temp*
#test 4D timeseries
avwroi $FSLTESTDIR/common/filtered_func_data.nii.gz temp1 5 10
../avwroi++ $FSLTESTDIR/common/filtered_func_data.nii.gz temp2 5 10
cmp temp1.nii.gz temp2.nii.gz
output2=$?
if [ $output2 -ne 0 ]
then
flag_bit=1
echo "4D timeseries failed bit-comparison test in avwroi++"
fi
avwmaths temp2 -Tmean temp3
avwmaths temp1 -Tmean temp2
avwmaths temp3 -sub temp2 temp1
output1=`avwstats temp1 -m`
echo "Result of 4D timeseries test:" $output1 $output2
if [ $output1 != 0.000000 ];
then
echo "4D timeseries failed math test in avwroi++"
flag_maths=1
fi
rm temp*
#test 4D time and volume
avwroi $FSLTESTDIR/common/filtered_func_data.nii.gz temp1 15 20 15 20 5 10 5 10
../avwroi++ $FSLTESTDIR/common/filtered_func_data.nii.gz temp2 15 20 15 20 5 10 5 10
cmp temp1.nii.gz temp2.nii.gz
output2=$?
if [ $output2 -ne 0 ]
then
flag_bit=1
echo "4D timeseries and volume failed bit-comparison test in avwroi++"
fi
avwmaths temp2 -Tmean temp3
avwmaths temp1 -Tmean temp2
avwmaths temp3 -sub temp2 temp1
output1=`avwstats temp1 -m`
echo "Result of 4D time and volume test:" $output1 $output2
if [ $output1 != 0.000000 ]
then
echo "4D timeseries and volume failed math test in avwroi++"
flag_maths=1
fi
rm temp*
echo ""
if [ $flag_maths -ne 0 -o $flag_bit -ne 0 ]
then
echo "non-zero comparison; possible problem with avwroi++"
else
echo "All comparisons zero. No problems detected with avwroi++"
fi
\ No newline at end of file
#!/bin/sh
flag=0
for setting in -t -x -y -z
do
../avwsplit++ $FSLTESTDIR/common/filtered_func_data.nii.gz vol $setting
../avwmerge $setting temp vol*
avwmaths temp -Tmean temp2
avwmaths $FSLTESTDIR/common/filtered_func_data.nii.gz -Tmean temp
avwmaths temp -sub temp2 temp3
output1=`avwstats temp3 -m`
echo "Result of $setting split test:" $output1
if [ $output1 != 0.000000 ];
then
flag=1
echo "Possible problem with $setting test in avwsplit++";
fi
rm temp*
rm vol*
done
echo ""
if [ $flag -ne 0 ]
then
echo "non-zero comparison; possible problem with avwsplit"
else
echo "All comparisons zero. No problems detected with avwsplit"
fi
\ No newline at end of file
<nifti_image
nifti_type = 'NIFTI-1+'
header_filename = 'filtered_func_data.nii.gz'
image_filename = 'filtered_func_data.nii.gz'
image_offset = '352'
ndim = '4'
nx = '64'
ny = '64'
nz = '21'
nt = '100'
dx = '4'
dy = '4'
dz = '6'
dt = '1'
datatype = '4'
datatype_name = 'INT16'
nvox = '8601600'
nbyper = '2'
byteorder = 'LSB_FIRST'
cal_min = '3'
cal_max = '25500'
xyz_units = '2'
xyz_units_name = 'mm'
time_units = '8'
time_units_name = 's'
descrip = 'FSL3.2beta'
/>
#!/bin/sh
echo "************************************"
echo "Running avwroi tests"
./avwroi_test.sh
echo "************************************"
echo "Running avwnvols tests"
./avwnvols_test.sh
echo "************************************"
echo "Running avw2ascii tests"
./avw2ascii_test.sh
echo "************************************"
echo "Running avwsplit tests"
./avwsplit_test.sh
echo "************************************"
echo "Running avwcc tests"
./avwcc_test.sh
# echo "************************************"
# echo "Running avwmerge tests"
# ./avwmerge_test.sh
echo "************************************"
echo "Running avwinterleave tests"
./avwinterleave_test.sh
echo "************************************"
echo "Running avwcpgeom tests"
./avwcpgeom_test.sh
echo "************************************"
echo "Running avwhd tests"
./avwhd_test.sh
echo "************************************"
echo "Running avwcreatehd tests"
./avwcreatehd_test.sh
echo "************************************"
echo "Running avwmaths tests"
./avwmaths_test.sh
echo "************************************"
\ No newline at end of file
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