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

This commit was manufactured by cvs2svn to create tag 'FSL6-0-2'.

Sprout from master 2019-06-11 15:25:37 UTC Matthew Webster <mwebster@fmrib.ox.ac.uk> 'read4D to avoid calling legacy read'
Cherrypick from master 2009-03-31 10:49:37 UTC Matthew Webster <mwebster@fmrib.ox.ac.uk> 'fixed copyrights':
    fsl2ascii.cc
Cherrypick from fsl-5_branch 2014-02-12 12:05:15 UTC Matthew Webster <mwebster@fmrib.ox.ac.uk> 'Changes for new utils parser':
    fslcc.cc
Delete:
    avwfixfloat.cc
    doc/index.html
    fslcheck.cc
    fslcorrecthd.cc
    fsldecorr4d.cc
    fslfromascii.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/fslswapdim_test.sh
    tests/header.xml
    tests/run_alltests.sh
parent 61d6cfff
No related branches found
No related tags found
No related merge requests found
Showing with 8 additions and 2139 deletions
/* 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;
}
}
This diff is collapsed.
......@@ -25,14 +25,14 @@ int fmrib_main(int argc, char *argv[])
string output_name=string(argv[2]);
ofstream output_file;
int i,j,k,t;
for(t=0;t<input_volume.tsize();t++)
for(t=0;t<=input_volume.maxt();t++)
{
output_file.open((output_name+num2str(t,5)).c_str(),ofstream::out);
for(k=0;k<input_volume.zsize();k++)
for(k=0;k<=input_volume.maxz();k++)
{
for(j=0;j<input_volume.ysize();j++)
for(j=0;j<=input_volume.maxy();j++)
{
for(i=0;i<input_volume.xsize();i++)
for(i=0;i<=input_volume.maxx();i++)
{
output_file << input_volume(i,j,k,t) << " ";
}
......
// fslcc.cc cross-correlate two time series timepoint by timepoint
// Steve Smith and Matthew Webster, FMRIB Image Analysis Group
// Copyright (C) 2001-2015 University of Oxford
// Copyright (C) 2001-2013 University of Oxford
// CCOPYRIGHT
#include "newimage/newimageall.h"
......@@ -36,7 +36,7 @@ int fmrib_main(int argc, char *argv[])
read_volume4D(input_volume1,input_name1);
read_volume4D(input_volume2,input_name2);
if (!samesize(input_volume1,input_volume2,3))
if (input_volume1.maxx() != input_volume2.maxx() || input_volume1.maxy() != input_volume2.maxy() || input_volume1.maxz() != input_volume2.maxz())
{
cerr << "Error: Mismatch in image dimensions" << endl;
return 1;
......@@ -45,7 +45,7 @@ int fmrib_main(int argc, char *argv[])
volume<T> mask;
if(fnmask.value().length()>0){
read_volume(mask,fnmask.value());
if(!samesize(input_volume1,mask,3)){
if(!samesize(input_volume1[0],mask)){
cerr << "Error: Mismatch in mask dimensions" << endl;
return 1;
}
......@@ -53,6 +53,7 @@ int fmrib_main(int argc, char *argv[])
mask=input_volume1[0];
mask=1;
}
if ( !nodemean.value() ) {
for(int t1=0;t1<=input_volume1.maxt();t1++)
......
/* fslcheck.cc - Utility to check validity of avw header file
Peter Bannister and Matthew Webster, FMRIB Image Analysis Group
Copyright (C) 1999-2007 University of Oxford */
/* CCOPYRIGHT */
#include <cmath>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <sstream>
#include "newmatap.h"
#include "newmatio.h"
#include "newimage/newimageall.h"
#include "utils/options.h"
#include "newimage/fmribmain.h"
using namespace MISCMATHS;
using namespace NEWMAT;
using namespace NEWIMAGE;
using namespace Utilities;
string title="fslcheck (Version 1.0)\nChecks Header file info for voxel dimensions\nCopyright(c) 2001, University of Oxford (Peter R Bannister)";
string examples="fslcheck -i <header_file>\n";
Option<bool> help(string("-h,--help"), false,
string("display this message"),
false, no_argument);
Option<bool> verbose(string("-v,--verbose"), false,
string("switch on diagnostic messages"),
false, no_argument);
Option<string> inputname(string("-i,--in"), string(""),
string("filename of input timeseries"),
true, requires_argument);
const float tolerance = 0.00000001;
template <class T>
int fmrib_main(int argc, char* argv[])
{
volume4D<T> timeseries;
volumeinfo vinfo;
float x_dim, y_dim, z_dim, t_dim;
short datatype;
if (inputname.set()) {
if (verbose. value()) { cout << "Reading header file" << endl; }
read_volume4D_hdr_only(timeseries,inputname. value(),vinfo);
}
if (fabs(timeseries. xdim()) <= tolerance) {
do {
cerr << "Invalid voxel x-dimension (" << timeseries. xdim() << " mm): Please enter a new value" << endl;
cin >> x_dim;
} while (fabs(x_dim) <= tolerance);
timeseries. setxdim(x_dim);
}
if (fabs(timeseries. ydim()) <= tolerance) {
do {
cerr << "Invalid voxel y-dimension (" << timeseries. ydim() << " mm): Please enter a new value" << endl;
cin >> y_dim;
} while (fabs(y_dim) <= tolerance);
timeseries. setydim(y_dim);
}
if (fabs(timeseries. zdim()) <= tolerance) {
do {
cerr << "Invalid voxel z-dimension (" << timeseries. zdim() << " mm): Please enter a new value" << endl;
cin >> z_dim;
} while (fabs(z_dim) <= tolerance);
timeseries. setzdim(z_dim);
}
if (fabs(timeseries. tdim()) <= tolerance) {
do {
cerr << "Invalid TR (" << timeseries. tdim() << " secs): Please enter a new value" << endl;
cin >> t_dim;
} while (fabs(t_dim) <= tolerance);
timeseries. settdim(t_dim);
}
// set bitpix correctly (via FslSetDataType) - NB: type T = datatype
FslGetDataType(&vinfo,&datatype);
FslSetDataType(&vinfo,datatype);
// read in whole file(!) and save it again
volume4D<T> tmp;
read_volume4D(tmp, inputname.value());
save_volume4D_filetype(tmp, inputname.value(), FslGetFileType(&vinfo), vinfo);
return 0;
}
int main (int argc,char** argv)
{
Tracer tr("main");
OptionParser options(title, examples);
try {
options.add(inputname);
options.add(help);
options.add(verbose);
options.parse_command_line(argc, argv);
if ( (help.value()) || (!options.check_compulsory_arguments(true)) )
{
options.usage();
exit(EXIT_FAILURE);
}
if ( inputname.unset())
{
options.usage();
cerr << endl
<< "--in or -i MUST be used."
<< endl;
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;
}
int retval=call_fmrib_main(dtype(inputname.value()), argc, argv);
if (retval!=0) {
cerr << "Failed to correctly read file, please check the .hdr using fslhd" << endl;
} else return retval;
}
// fslcorrecthd.cc - check and correct a nifti file for bad vox-offset
// Matthew Webster, FMRIB Image Analysis Group
// Copyright (C) 2007 University of Oxford
// CCOPYRIGHT
#include "newimage/newimageall.h"
#include "fslio/fslio.h"
#include <iostream>
using namespace NEWIMAGE;
void print_usage(const string& progname)
{
cout << endl;
cout << "Usage: fslcorrecthd <input> <output>" << endl;
cout << " Note that fslcorrecthd only operates on uncompressed NIFTI or ANALYZE files" << endl;
}
int main(int argc,char *argv[])
{
if (argc < 3)
{
print_usage(string(argv[0]));
return 1;
}
FSLIO* fslio=NULL;
fslio = FslOpen(FslMakeBaseName(argv[1]),"rb");
FslClose(fslio);
struct dsr *hdr;
hdr = (struct dsr *)calloc(1,sizeof(struct dsr));
FslReadRawHeader(hdr,fslio->niftiptr->fname);
if (fslio->niftiptr->byteorder != nifti_short_order())
{
cout << "Byte swapping" << endl;
AvwSwapHeader(hdr);
}
//check nifti-libs output versus raw header info
int offset =(int) ( fslio->niftiptr->iname_offset - hdr->dime.vox_offset );
int minft=(int)MIN(fslio->niftiptr->iname_offset,hdr->dime.vox_offset);
cout << "number of bytes wrong: " << offset << endl << "start at byte location: " << minft << endl;
if (offset==0) {
cout << "No byte correction needed, exiting." << endl;
return 0;
}
if (FslIsCompressedFileType(FslGetFileType(fslio))) {
cerr << "Error: fslcorrecthd requires uncompressed input" << endl;
return 1;
}
ifstream input_file;
ofstream output_file;
char *temp,*outputName,*inputName;
FslGetHdrImgNames(argv[2],fslio,&temp,&outputName);
FslGetHdrImgNames(argv[1],fslio,&temp,&inputName);
char byte[1];
input_file.open(inputName,ios::in | ios :: binary);
output_file.open(outputName,ofstream::out | ofstream::binary);
for(int i=1;i<=minft;i++) //Write Header
{
input_file.read(byte,1);
if (input_file.eof()) break;
output_file.write(byte,1);
}
for(int i=1;i<=abs(offset) && offset>0;i++) //Pad if we have missing 4 bytes
{
byte[0]=0;
output_file.write(byte,1);
}
for(int i=1;i<=abs(offset) && offset<0;i++) //Read past bad extensions/junk
{
input_file.read(byte,1);
}
while(true) //Copy the data
{
input_file.read(byte,1);
if (input_file.eof()) break;
output_file.write(byte,1);
}
output_file.close();
input_file.close();
system(("FSLOUTPUTTYPE=NIFTI; ${FSLDIR}/bin/fslmaths " + string(outputName)).c_str()); //To clean up header
free(temp);
free(outputName);
free(hdr);
return 0;
}
/* fsldecorr4d.cc
Mark Jenkinson, FMRIB Image Analysis Group
Copyright (C) 2007 University of Oxford */
/* CCOPYRIGHT */
// Decorrelates a set of separable 4D components from
// a 4D dataset
#include "newimage/newimageall.h"
#include "miscmaths/miscmaths.h"
#include "utils/options.h"
using namespace NEWIMAGE;
using namespace MISCMATHS;
using namespace Utilities;
// The two strings below specify the title and example usage that is
// printed out as the help or usage message
string title="fsldecorr4d (Version 1.0)\nCopyright(c) 2004, University of Oxford (Mark Jenkinson)\nRemoves 4D components (by decorrelation) from a 4D dataset.\nEach component needs to be specified by a separate timecourse and spatial map.\nThe spatial maps are input as a single 4D file and the timecourses as a text matrix (with each column being a timecourse with the same ordering as the corresponding spatial maps.\n";
string examples="fsldecorr4d -s <spatial maps> -t <timecourses> -i <input> -o <output> [-m mask]";
// Each (global) object below specificies as option and can be accessed
// anywhere in this file (since they are global). The order of the
// arguments needed is: name(s) of option, default value, help message,
// whether it is compulsory, whether it requires arguments
// Note that they must also be included in the main() function or they
// will not be active.
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<string> smapname(string("-s"), string(""),
string("~<filename>\tinput set of spatial maps (4D)"),
false, requires_argument);
Option<string> tcname(string("-t"), string(""),
string("~<filename>\tinput set of timecourses (text matrix)"),
false, requires_argument);
Option<string> maskname(string("-m"), string(""),
string("~<filename>\tinput 3D mask"),
false, requires_argument);
Option<string> outname(string("-o"), string(""),
string("~<filename>\toutput 4D dataset"),
true, requires_argument);
Option<string> inname(string("-i"), string(""),
string("~<filename>\tinput 4D dataset"),
true, requires_argument);
int nonoptarg;
int decorr1D(volume4D<float>& vol, const Matrix& tc, const volume<float>& mask)
{
int nt=tc.Nrows();
int nc=tc.Ncols();
Matrix XX(nc,nc);
ColumnVector Y(nt), Beta(nc);
XX = tc.t() * tc;
if (verbose.value()) { cout << "Processing slices "; }
for (int z=vol[0].minz(); z<=vol[0].maxz(); z++) {
for (int y=vol[0].miny(); y<=vol[0].maxy(); y++) {
for (int x=vol[0].minx(); x<=vol[0].maxx(); x++) {
if (mask(x,y,z)>0.5) {
for (int t=0; t<nt; t++) { Y(t+1) = vol(x,y,z,t); }
Beta = pinv(XX) * tc.t() * Y;
Y -= tc * Beta;
for (int t=0; t<nt; t++) { vol(x,y,z,t) = Y(t+1); }
}
}
}
if (verbose.value()) { cout << "."; }
}
if (verbose.value()) { cout << endl; }
return 0;
}
int decorr4D(volume4D<float>& vol, const Matrix& tc,
const volume4D<float>& smaps, const volume<float>& mask)
{
int nt=tc.Nrows();
int nc=tc.Ncols();
// set up required matrices
Matrix XX(nc,nc);
ColumnVector XY(nc);
XY=0.0; XX=0.0;
if (verbose.value()) { cout << "Calculating matrix values:" << endl; }
// calculate matrix elements (4D correlations)
for (int n=1; n<=nc; n++) {
if (verbose.value()) { cout << "Component #" << n << endl; }
for (int t=0; t<nt; t++) {
for (int z=smaps[n-1].minz(); z<=smaps[n-1].maxz(); z++) {
for (int y=smaps[n-1].miny(); y<=smaps[n-1].maxy(); y++) {
for (int x=smaps[n-1].minx(); x<=smaps[n-1].maxx(); x++) {
XY(n) += smaps(x,y,z,n-1) * tc(t+1,n) * vol(x,y,z,t);
}
}
}
}
for (int m=1; m<=n; m++) {
volume<float> tmp;
tmp = smaps[n-1] * smaps[m-1];
XX(m,n) = tmp.sum();
double tval=0.0;
for (int t=0; t<nt; t++) {
tval += tc(t+1,n) * tc(t+1,m);
}
XX(m,n) *= tval;
XX(n,m) = XX(m,n);
}
}
if (verbose.value()) { cout << "XY = " << XY.t()/nt << endl; }
if (verbose.value()) { cout << "XX = " << (XX/nt)/nt << endl; }
if (verbose.value()) { cout << "Finding amplitudes" << endl; }
// find amplitudes for each component
ColumnVector Beta(nc);
Beta = pinv(XX)*XY;
if (verbose.value()) { cout << "Amplitudes = " << Beta.t() << endl << endl; }
if (verbose.value()) { cout << "Removing components" << endl; }
// remove components from input data
for (int n=1; n<=nc; n++) {
for (int t=0; t<nt; t++) {
for (int z=smaps[n-1].minz(); z<=smaps[n-1].maxz(); z++) {
for (int y=smaps[n-1].miny(); y<=smaps[n-1].maxy(); y++) {
for (int x=smaps[n-1].minx(); x<=smaps[n-1].maxx(); x++) {
vol(x,y,z,t) -= Beta(n) * smaps(x,y,z,n-1) * tc(t+1,n);
}
}
}
}
}
return 0;
}
int decorr3D(volume4D<float>& vol, const volume4D<float>& smaps,
const volume<float>& mask)
{
int nt=vol.tsize();
int nc=smaps.tsize();
// set up required matrices
Matrix XX(nc,nc);
ColumnVector XY(nc);
XY=0.0; XX=0.0;
// calculate matrix elements (4D correlations)
for (int n=1; n<=nc; n++) {
for (int m=1; m<=n; m++) {
volume<float> tmp;
tmp = smaps[n-1] * smaps[m-1];
XX(m,n) = tmp.sum();
XX(n,m) = XX(m,n);
}
}
if (verbose.value()) { cout << "XX = " << (XX/nt)/nt << endl; }
Matrix pinvXX;
pinvXX=pinv(XX);
if (verbose.value()) { cout << "Calculating matrix values:" << endl; }
// calculate matrix elements (4D correlations)
for (int t=0; t<nt; t++) {
if (verbose.value()) { cout << "."; }
XY=0.0;
for (int n=1; n<=nc; n++) {
for (int z=smaps[n-1].minz(); z<=smaps[n-1].maxz(); z++) {
for (int y=smaps[n-1].miny(); y<=smaps[n-1].maxy(); y++) {
for (int x=smaps[n-1].minx(); x<=smaps[n-1].maxx(); x++) {
XY(n) += smaps(x,y,z,n-1) * vol(x,y,z,t);
}
}
}
}
// find amplitudes for each component
ColumnVector Beta(nc);
Beta = pinvXX*XY;
// remove components from input data
for (int n=1; n<=nc; n++) {
for (int z=smaps[n-1].minz(); z<=smaps[n-1].maxz(); z++) {
for (int y=smaps[n-1].miny(); y<=smaps[n-1].maxy(); y++) {
for (int x=smaps[n-1].minx(); x<=smaps[n-1].maxx(); x++) {
vol(x,y,z,t) -= Beta(n) * smaps(x,y,z,n-1);
}
}
}
}
}
if (verbose.value()) { cout << endl; }
return 0;
}
int do_work(int argc, char *argv[])
{
volume4D<float> vin;
read_volume4D(vin,inname.value());
// ** MASK ** //
volume<float> mask;
if (maskname.set()) {
read_volume(mask,maskname.value());
} else {
mask = vin[0];
mask = 1.0;
}
if (!samesize(vin[0],mask)) {
cerr << "ERROR: Mask and Input volumes have different (x,y,z) size."
<< endl;
return 2;
}
mask.binarise(1e-8); // arbitrary "0" threshold
// ** TIME COURSES ** //
Matrix tc;
if (tcname.set()) {
tc = read_ascii_matrix(tcname.value());
if (tc.Nrows() != vin.tsize()) {
cerr << "ERROR: Different number of timepoints in timecourse file and input volume." << endl;
return 3;
}
// demean timecourses (to stop any correlation with the mean)
tc = remmean(tc);
}
// ** SPATIAL MAPS ** //
// if no smaps specified then go for simple 1D decorrelation
volume4D<float> smaps;
if (smapname.set()) {
// if smaps are specified then do the full 4D decorrelation
read_volume4D(smaps,smapname.value());
if (!samesize(vin[0],smaps[0])) {
cerr << "ERROR: Spatial maps and Input volumes have different (x,y,z) size."
<< endl;
return 1;
}
if (tcname.set() && (tc.Ncols() != smaps.tsize())) {
cerr << "ERROR: Different number of components for timecourses and spatial maps." << endl;
return 4;
}
// mask spatial maps
smaps *= mask;
// demean spatial maps (wrt mask)
for (int n=0; n<smaps.tsize(); n++) {
smaps[n] -= ((float) smaps[n].mean())*mask;
}
}
// ** DECORRELATION ** //
int retval=0;
if (smapname.set() && tcname.set()) {
retval = decorr4D(vin,tc,smaps,mask);
}
if (!smapname.set() && tcname.set()) {
retval = decorr1D(vin,tc,mask);
}
if (smapname.set() && !tcname.set()) {
retval = decorr3D(vin,smaps,mask);
}
if (!smapname.set() && !tcname.set()) {
cerr << "ERROR: Must pass in either spatial maps or timecourses or both"
<< endl;
return 3;
}
// save the result
if (retval==0) save_volume4D(vin,outname.value());
return retval;
}
int main(int argc,char *argv[])
{
Tracer tr("main");
OptionParser options(title, examples);
options.add(inname);
options.add(outname);
options.add(smapname);
options.add(tcname);
options.add(maskname);
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)) )
{
options.usage();
exit(EXIT_FAILURE);
}
// OK, now do the job ...
return do_work(argc,argv);
}
// fsl2ascii.cc - convert AVW to raw ASCII text
// Stephen Smith and Matthew Webster, FMRIB Image Analysis Group
// Copyright (C) 2001-2005 University of Oxford
// COPYRIGHT
#include "newimage/newimageall.h"
#include "miscmaths/miscmaths.h"
#include <fstream>
using namespace NEWIMAGE;
using namespace MISCMATHS;
void print_usage(const string& progname) {
cout << endl;
cout << "Usage: fslfromascii <input> <xsize> <ysize> <zsize> <tsize> <output>" << endl;
}
int main(int argc,char *argv[])
{
if (argc != 7)
{
print_usage(string(argv[0]));
return 1;
}
volume4D<float> output_volume(atoi(argv[2]),atoi(argv[3]),atoi(argv[4]),atoi(argv[5]));
ifstream input(argv[1]);
for(int t=0;t<=output_volume.maxt();t++)
for(int z=0;z<=output_volume.maxz();z++)
for(int y=0;y<=output_volume.maxy();y++)
for(int x=0;x<=output_volume.maxx();x++)
input >> output_volume(x,y,z,t);
save_volume4D(output_volume,string(argv[6]));
input.close();
return 0;
}
#!/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
#!/bin/bash
## NOTE: needs links or copies of various fsl utilities to exist in ../bin at the moment (annoyingly!)
mni=/home/fs0/mark/fslsrc/avwutils/tests/mni
#mni=$FSLDIR/data/standard/MNI152_T1_2mm
for fn in fooOLD_*.nii.gz ; do
echo $fn
( export FSLDIR=`pwd`/.. ; $FSLDIR/bin/fslreorient2std $mni fooRNEW )
( export FSLDIR=/usr/local/fsl-alpha ; $FSLDIR/bin/fslreorient2std $mni fooROLD )
diff fooRNEW.nii.gz fooROLD.nii.gz
done
# num=1;
# for aa in RL LR ; do
# for bb in RL LR ; do
# for cc in RL LR ; do
# for tr1 in RLAPSI RLSIAP APSIRL APRLSI SIRLAP SIAPRL ; do
# aaa=`echo $aa | tr R ${tr1:0:1} | tr L ${tr1:1:1}`;
# bbb=`echo $bb | tr R ${tr1:2:1} | tr L ${tr1:3:1}`;
# ccc=`echo $cc | tr R ${tr1:4:1} | tr L ${tr1:5:1}`;
# echo $aaa $bbb $ccc
# ( export FSLDIR=`pwd`/.. ; $FSLDIR/bin/fslswapdim $mni $aaa $bbb $ccc fooNEW_$num )
# echo $FSLDIR
# ( export FSLDIR=/usr/local/fsl-alpha ; $FSLDIR/bin/fslswapdim $mni $aaa $bbb $ccc fooOLD_$num )
# diff fooNEW_${num}.nii.gz fooOLD_${num}.nii.gz
# num=`echo $num + 1 | bc`
# done
# done
# done
# done
# num=1;
# for aa in x -x ; do
# for bb in x -x ; do
# for cc in x -x ; do
# for tr1 in xyz yzx zxy xzy yxz zyx ; do
# aaa=`echo $aa | tr x ${tr1:0:1}`;
# bbb=`echo $bb | tr x ${tr1:1:1}`;
# ccc=`echo $cc | tr x ${tr1:2:1}`;
# echo $aaa $bbb $ccc
# ( export FSLDIR=`pwd`/.. ; $FSLDIR/bin/fslswapdim $mni $aaa $bbb $ccc fooNEW_$num )
# echo $FSLDIR
# ( export FSLDIR=/usr/local/fsl-alpha ; $FSLDIR/bin/fslswapdim $mni $aaa $bbb $ccc fooOLD_$num )
# diff fooNEW_${num}.nii.gz fooOLD_${num}.nii.gz
# num=`echo $num + 1 | bc`
# done
# done
# done
# done
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