From 20ced5e0d4cd4965dc626b0881622e0016ecc5d7 Mon Sep 17 00:00:00 2001 From: Matthew Webster <mwebster@fmrib.ox.ac.uk> Date: Tue, 11 Jun 2019 15:25:38 +0000 Subject: [PATCH] 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 --- avwfixfloat.cc | 128 ---------- doc/index.html | 465 ------------------------------------ fsl2ascii.cc | 8 +- fslcc.cc | 7 +- fslcheck.cc | 140 ----------- fslcorrecthd.cc | 94 -------- fsldecorr4d.cc | 325 ------------------------- fslfromascii.cc | 37 --- tests/avw2ascii_test.sh | 33 --- tests/avwcc_test.sh | 38 --- tests/avwcpgeom_test.sh | 97 -------- tests/avwcreatehd_test.sh | 35 --- tests/avwhd_test.sh | 61 ----- tests/avwinterleave_test.sh | 50 ---- tests/avwmaths_test.sh | 389 ------------------------------ tests/avwmerge_test.sh | 48 ---- tests/avwnvols_test.sh | 31 --- tests/avwroi_test.sh | 77 ------ tests/avwsplit_test.sh | 28 --- tests/fslswapdim_test.sh | 56 ----- tests/header.xml | 28 --- tests/run_alltests.sh | 36 --- 22 files changed, 8 insertions(+), 2203 deletions(-) delete mode 100644 avwfixfloat.cc delete mode 100644 doc/index.html delete mode 100644 fslcheck.cc delete mode 100755 fslcorrecthd.cc delete mode 100644 fsldecorr4d.cc delete mode 100755 fslfromascii.cc delete mode 100755 tests/avw2ascii_test.sh delete mode 100755 tests/avwcc_test.sh delete mode 100755 tests/avwcpgeom_test.sh delete mode 100755 tests/avwcreatehd_test.sh delete mode 100755 tests/avwhd_test.sh delete mode 100755 tests/avwinterleave_test.sh delete mode 100755 tests/avwmaths_test.sh delete mode 100755 tests/avwmerge_test.sh delete mode 100755 tests/avwnvols_test.sh delete mode 100755 tests/avwroi_test.sh delete mode 100755 tests/avwsplit_test.sh delete mode 100755 tests/fslswapdim_test.sh delete mode 100644 tests/header.xml delete mode 100755 tests/run_alltests.sh diff --git a/avwfixfloat.cc b/avwfixfloat.cc deleted file mode 100644 index 81744e8..0000000 --- a/avwfixfloat.cc +++ /dev/null @@ -1,128 +0,0 @@ -/* 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; - } -} diff --git a/doc/index.html b/doc/index.html deleted file mode 100644 index 00a63c7..0000000 --- a/doc/index.html +++ /dev/null @@ -1,465 +0,0 @@ -<HTML><HEAD><link REL="stylesheet" TYPE="text/css" href="../fsl.css"><TITLE>FSLUTILS DOCS</TITLE></HEAD><BODY><hr><TABLE BORDER=0 WIDTH="100%"><TR><TD ALIGN=CENTER><H1> -FSLUTILS -</H1> -Miscellaneous FSL Image Utilities -<TD ALIGN=RIGHT><a href="../index.html"><IMG BORDER=0 SRC="../images/fsl-logo.jpg"></a></TR></TABLE><HR> - -<P>FSLUTILS is a set of useful command-line utilities which allow the -conversion, processing etc. of Analyze and Nifti format data sets. -Many of them work on both 3D and 4D data. For each of these programs, -<i>type just the program name to get the usage help</i>. - - -<p>The different FSLUTILS programs are: -<UL> - -<LI><b>fsl2ascii</b> - convert image files to ASCII text file (or files if -data is 4D). - -<br><br><LI><b>fslcc</b> - run cross-correlations between every volume in -one 4D data set with every volume in another (for investigating -similarities in ICA outputs). - -<br><br><LI><b>fslchfiletype</b> - used to change the file type of -an image (e.g. from ANALYZE_GZ to NIFTI). The first argument is -the desired file type (one of ANALYZE, ANALYZE_GZ, NIFTI, NIFTI_GZ, -NIFTI_PAIR, NIFTI_PAIR_GZ) and the second is the input file. If -no third argument is given then the input file is converted in place. -This in place conversion removes the original files: e.g. for an -Analyze file called stdimg then -<kbd>fslchfiletype NIFTI_GZ stdimg</kbd> would replace stdimg.hdr and -stdimg.img with stdimg.nii.gz. Note that having multiple copies of -an image with the same basename and different filetypes (e.g. stdimg.nii.gz -and stdimg.hdr and stdimg.img) creates many problems for determining -what images to read, and in general will cause FSL programs to stop. - -<br><br><a name="fslcomplex"></a><LI><b>fslcomplex</b> - a utility that allows 3D or 4D complex -image files to be split or constructed from corresponding real -components (either Cartesian or polar). The initial flag indicates -what kind of processing is done. In addition, two optional arguments -at the end specify the first and last 3D volumes to be processed when -the input is 4D (default is to do all volumes). - -<br><br><LI><b>fslcpgeom</b> - copy certain parts of the header -information (image -dimensions, voxel dimensions, voxel dimensions units string, image -orientation/origin or qform/sform info) from one image to another. -Note that only copies from Analyze to Analyze or Nifti to Nifti -will work properly. Copying from different files will result in -loss of information or potentially incorrect settings. - -<br><br><LI><b>fslcreatehd</b> - creates a new image header along with -a zero intensity data image. There are two forms of input: one takes -a list of minimal information on the command line, the other takes in -an xml-style file, as written by <kbd>fslhd -x</kbd>. The information -required in the first version is: x/y/z/tsize for image dimensions, -x/y/zvoxsize for voxel dimensions (eg in mm), tr in seconds for time -between volumes (for 3D data set to 0), x/y/zorigin for voxel -co-ordinate origin (eg for standard space - otherwise leave as 0 0 0), -datatype for the voxel data type (the commonest are: 1=binary, -2=unsigned char, 4=signed short, 8=signed int, 16=float). Note that -this is <b><i>different</i></b> from the previous versions in that an -entire image is created, and will <b><i>overwrite</i></b> any -<kbd>.img</kbd> file contents of the same image name. - -<br><br><LI><b>fsledithd</b> - allows the header information in -and image to be edited in a text-based xml-style format (like the -output of <kbd>fslhd -x</kbd> but with redundant fields removed -and some help text provided). Note that -the default text editor used is nano, but other editors can be -specified by the second argument. - -<br><br><LI><b>fslfft</b> - outputs the Fast-Fourier Transform (or inverse) -for a complex input volume. - -<br><br><LI><b>fslhd</b> - report every field of an Analyze or Nifti -header (note that the fields are different although some are common, -e.g. pixdims). The option "-x" produces an xml-style output which can -be used in conjunction with <kbd>fslcreatehd</kbd>. The reported -values are those used internally in FSL programs and are sometimes -different from the raw values stored in the file to avoid incorrect -settings (e.g. dimN has a minimum value of 1, not 0). - -<br><br><LI><b>fslinfo</b> - report a basic subset of an Analyze or -Nifti header. - -<br><br><LI><b>fslinterleave</b> - interleave two inputs to form a -combined image. - -<br><br><LI><b>fslmaths</b> - simple but powerful program to allow -mathematical manipulation of images. Now includes spatial and -temporal filtering, statistic conversion (e.g. z to p-values), -diffusion tensor decomposition, and TFCE calculation. - -<br><br><LI><b>fslmeants</b> - output the average timeseries of a set of voxels, or the individual time series for each of these voxels. - -<br><br><LI><b>fslmerge</b> - concatenate image files into a single -output. This concatenation can be in time, or in X, Y or Z. All image -dimensions (except for the one being concatenated over) must be the -same in all input images. For example, this can be used to take -multiple 3D files (eg as output by SPM) and create a single 4D image -file. - -<br><br><LI><b>fslnvols</b> - report how many time points are in the -input 4D data set. - -<br><br><LI><b>fslpspec</b> - outputs the spectral power density of an -input 4D data set. - -<br><br><LI><b>fslroi</b> - extract region of interest (ROI) from an -image. You can a) take a 3D ROI from a 3D data set (or if it is 4D, -the same ROI is taken from each time point and a new 4D data set is -created), b) extract just some time points from a 4D data set, or c) -control time and space limits to the ROI. Note that the arguments are -minimum index and <i>size</i> (not maximum index). So to extract -voxels 10 to 12 inclusive you would specify 10 and 3 (not 10 and 12). - -<br><br><LI><b>fslslice</b> - split a 3D file into lots of 2D files (along z-axis). - -<br><br><LI><b>fslsplit</b> - split a 4D file into lots of 3D files -(eg for inputting to SPM). - -<br><br><LI><b>fslstats</b> - report certain summary statistics for an -input 3D/4D image. Of particular value is the "robust intensity range" -which calculates values similar to the 2% and 98% percentiles, but -ensuring that the majority of the intensity range is captured, even -for binary images. In addition, it can take an aribitrary mask as -input so that statistics are only calculated within the mask and can -also generate histogram data. - -<br><br><LI><b>fslval</b> - report a particular parameter (given a -particular keyword eg "dim4") from an image header. To see the list of -keywords run <kbd>fslhd</kbd> on the header and look at the first column. - -</ul> - -<hr> -<h2>Orientation-related Utilities</h2> - -<p> Orientation, labelling and getting left and right correct are -important but often confusing issues. You should always look at your -data and check if the labels in FSLView are correct. <b><i>No further -analysis should ever be done if the labels in FSLView are incorrect or -missing.</i></b> If your labels are fine then you probably will not -need to use any other these tools, although -<code>fslreorient2std</code> may be useful. If not, then you will need -to read on. We have tried to simplify the usage of the tools for -common tasks involving orientation issues, although still providing -flexible and powerful tools for the expert user. - -<p> -<b>Common problems</b> -<br>We describe here the most common problems and how to solve -them. If you have a different problem then you will need to work -with the advanced tools described later (and read the information on -NIfTI orientation). -<ol> - <li> <b>The labels in FSLView are wrong or missing</b> - <br> This is <i>very serious</i> and needs to be fixed before doing - any analysis at all. Ideally it should be fixed by using a - tool that creates a correct NIfTI file. There are numerous - converters from DICOM to NIfTI -- for recommendations, see the - <a href="http://www.fmrib.ox.ac.uk/fslfaq">FSL FAQ</a>. - A correct converter should store the correct information in the - NIfTI file so that the labels are correct when viewed in FSLView. - If you have tried many converters and still cannot get the images - converted correctly then you will need to use the advanced tools, - <code>fslswapdim</code> and <code>fslorient</code>, to fix the - problem (more info below). - <li> <b>The labels in FSLView are correct but the image is oriented - "wrongly"</b> - <br> By default FSLView shows the image in the way that the scanner - acquired it, so that sagittal, coronal and axial scans look very - different. Hence this is not really "wrong" - just how FSLView - chooses to display the images. If you do not want this but want to - see the image in the same orientation as the standard templates - (MNI152) then you can run the tool <code>fslreorient2std</code> - which is designed for just this task. However, make sure that the - labels are correct in FSLView to start with, as this tool only works if they are correct. -</ol> - -<!--- -The following utilities allow you to report and modify the -orientation information in NIFTI files (and ANALYZE to some extent). -For more information about orientation and the NIFTI format see -the <a href="http://www.fmrib.ox.ac.uk/fslfaq">FSL FAQ</a>. -!---> - -<p> -<b>Tools</b> -<ul> - <LI><b>fslreorient2std</b> - this is a simple tool designed to - reorient an image to match the orientation of the standard template - images (MNI152) so that they appear "the same way around" in - FSLView. It requires that the image labels are correct in FSLView - before this is run. It is also not a registration tool, so it will - not align the image to standard space, it will only apply 90, - 180 or 270 degree rotations about the different axes as necessary to - get the labels in the same position as the standard template. - - <br><br><LI><b>fslorient</b> - this is an advanced tool that reports -or sets the orientation information in a file. Note that only in -NIfTI files can the orientation be changed - Analyze files are -<i>always treated as "radiological"</i> (meaning that they could -be simply rotated into the same alignment as the <code>MNI152</code> standard -images - equivalent to the appropriate <i>sform</i> or <i>qform</i> in -a NIfTI file having a negative determinant). - -<p>In nifti files it is possible to independently report or modify -the <i>qform</i> or <i>sform</i> fields (see below for background - information on NIfTI orientation). However, the FSL4.1 output -routines will try to keep -<i>qform and sform matrices the same</i> whenever one would otherwise -be unset. Therefore it is not possible, for instance, to delete only -the qform, as if the sform is set then doing this will result in the -qform being set equal (as close as possible) to the sform. This is -currently done to aid interoperability with other packages. However, if both -qform and sform are given different values then these are -preserved by the output routines. - -<p>This command does not change the data storage at all - only the -orientation information in the header and so should be used with great - caution. Only modify header information if you understand the - information about the NIfTI orientation given below or are following - (exactly) a set of steps prescribed by someone who does. - -<p>The option <code>-deleteorient</code> is useful for the first stage -of correcting orientation/label information in images where the -conversion to NIfTI does not provide the correction information. Note -that the first, and by far the best, solution to this problem is to -find a method of converting the images to NIfTI in a way that -correctly stores the information (see above) but if this really is -not possible then a combination of <code>fslorient</code> and -<code>fslswapdim</code> can be used to fix it (see below). - -<br><br><LI><b>fslswapdim</b> - this is an advanced tool that -re-orders the data storage to permit changes between axial, sagittal -and coronal slicing. When used in this mode the same left-right -convention (also called coordinate handedness or -radiological/neurological convention) will be maintained <i>as long as -no warning is printed</i>. - -<p> -The new orientation of the data is specified by selecting what the new -axes should represent. This can either be done in terms of the old -axes (<kbd>x y z -x -y -z</kbd>) or in terms of anatomical labels -<i>when this information is available</i> (in a nifti image where -either the sform or qform code is non-zero). The anatomical labels -are RL LR AP PA SI IS. Note that the anatomical label version will not -allow the left-right convention to be changed. - -<p> -Ordinarily <kbd>fslswapdim</kbd> will change the orientation -information in the header as well as reordering the data. This is so -that the anatomical labels stay attached to the same parts of the -image and not fixed to the voxel coordinates. Hence, reordering a -coronal image to axial slicing should keep the labels correctly -attached to the relevant parts of the image, as long as they were -correct initially. If the initial labels are incorrect (see the -labels in <kbd>fslview</kbd>) then <kbd>fslorient</kbd> needs to be -used in conjunction with <kbd>fslswapdim</kbd> in order to correct -this. - -<p> When <kbd>fslswapdim</kbd> is given arguments that will change the -left-right orientation it will issue a warning that the left-right -orientation is being flipped. It will also try to modify the -orientation information in the header (only when either the sform or -qform code is non-zero), but <i>not</i> in a way that swaps this -left-right orientation in the header. Hence there is a net change in -orientation as the data is swapped while the header is not. If the -swap occurs on the x-axis then nothing is done to the header at all. -Otherwise, the axis which is being swapped, together with the x-axis, -have their orientation changed. In this way the handedness of the -header is preserved, the labels associated with the y-axis and z-axis -follow the image change, but the x-axis labels do not. It is -recommended that if a left-right swap in storage is desired (and this -should only be done if the reconstruction is initially incorrect, and -cannot be fixed by finding any better conversion method) then the -arguments <kbd>-x y z</kbd> should be used as this is the simplest -form of swapping since it only affects the x-axis data and no labels -or header information is changed. - -</UL> - -<p> -<b>Serious (uncommon) problems</b> -<br> -<ol> - <li><b>The labels in FSLView are wrong or missing and no conversion - to NIfTI can fix this</b> - <br>If this really cannot be fixed at the conversion stage, then it - is possible to fix by the follow (only to be attempted after reading - the following section on background information on NIfTI - orientation): - <br> <code>fslorient -deleteorient <i>imagename</i></code> - <br> <code>fslswapdim <i>imagename</i> <i>a b c</i> <i>imagename</i></code> - <br> <code>fslorient -setqformcode 1 <i>imagename</i></code> - <br> where <i>a b c</i> need to be chosen, usually by trial and - error, so that the image after this is in the same orientation (as - viewed in FSLView) as the MNI152 images. However, unless you have - some way of telling left from right in the image (e.g. by a vitamin - capsule or clearly known structural asymmetry) this method can - easily result in an incorrect left-right labelling and so should not - be attempted. -</ol> - -<p> -<b>Background information on NIfTI Orientation</b> -<br> - -This section is purely optional but is extremely useful to understand -if you are working with any of the advanced tools, have unusual -problems, or are just plain interested. - -<p> - -The NIfTI standard is confusing for many people on the issue of -orientation, largely because it is intrinsically a confusing issue. -It is complicated because the intensity data is stored on disk as a -list of numbers - there is no concept of spatial or anatomical -location with these numbers, and so information and standard -conventions are used to associate spatial and anatomical location -information with these numbers. - -<p> - -To start with, voxel coordinates are associated with the numbers (intensity values), such -that the first number is at coordinate (0,0,0) the second at (1,0,0), -the third at (2,0,0), etc. So, for example, say the image was 64 by -64 by 20 in size, then the coordinates would go as (0,0,0) then -(1,0,0) ... then (63,0,0) then (0,1,0) then (1,1,0) then (2,1,0) -... then (63,1,0) then (0,2,0) ... then (63,63,0) then (0,0,1) then -(1,0,1) ... until (63,63,19). Note that all coordinates start at 0, -not 1, and that the first coordinate (i) here is the one that -increases the fastest as you go through the list, followed by second -(j) and then the third (k). These voxel coordinates - (i,j,k) - give -spatial information (using information about how many voxels are in -the three spatial directions) but do not attribute any anatomical -information at all. - -<p> - -To go from voxel coordinates to more anatomically meaningful -coordinates is the job of the <code>qform</code> and -<code>sform</code> matrices that are stored in the NIfTI file. Note -that these matrices only provide useful information if they have a -non-zero <code>code</code>, since a zero <code>code</code> indicates -that the matrix is "Unknown" and hence cannot be used. Having two -matrices here is a common source of confusion. They were originally -proposed so that two different coordinates could be kept track of - -one representing the scanner coordinate system (the real space inside -the scanner bore) and the other one relating to standard space -coordinates (e.g. MNI152). However, in practice, it is rare that both -contain different information as they are often set to be the same, or -one of them is "Unknown" in which case the other contains all the -useful information. - -<p> - -Either matrix (qform or sform) is used to convert the voxel coordinates into -"real world" coordinates (also called continuous coordinates, or mm -coordinates, or other names). These new coordinates - called (x,y,z) -here - have units of mm, and can take any values, not just positive -whole numbers like the (i,j,k) voxel coordinates. Note that FSLView -displays both voxel and mm coordinates. -[Aside: the conversion is done by -multiplying the matrix with the voxel coordinate, reshaped as a 4x1 -vector with the last element equal to 1 - although this detail is not -important for any of the discussion or understanding.] - -<p> - -If the <code>qform</code> (or <code>sform</code>) is set so that it -gives information about scanner coordinates (as indicated by the -<code>code</code>), then a standard convention is used to relate the -coordinate values to the anatomy. The convention is: +x = Right; +y = -Anterior; +z = Superior. That is, moving in the positive x-direction -(so that the x-coordinate increases) will be moving to the right, -etc. This now allows left and right to be distinguished, which is -usually not possible just by looking at brain images. Hence this -information is absolutely crucial and getting this right for the -conversion of the image to NIfTI format is extremely important. -If it is incorrect then it would be easy for left and right to be -assigned incorrectly and all analysis results to be on the wrong side. -The information from the <code>qform</code> and <code>sform</code> -is what is used by FSLView to determine the labels that are shown on -the image. - -<p> - -If the <code>sform</code> is set so that it gives information about -standard space coordinates then the situation is the same as above, -since the standard convention used above was chosen to be the same as -the convention chosen for the standard space coordinate systems -(MNI152 and Talairach). The main difference between the two -situations is that the transformation to standard space (represented -by the <code>sform</code> matrix) also involves scaling and shearing -of the coordinate axes to make the brain "fit" the standard templates, -whereas the transformation to scanner space coordinates is normally just a -rotation and translation. - -<p> - -An aside on left-right conventions: it is possible to <i>store</i> an -image in many different ways that are totally and completely -equivalent in terms of the intensities and the (x,y,z) coordinates. -What can be different is the voxel coordinates (and hence the order of -the intensities stored in the file) but these are completely -unimportant for all analysis purposes - they are purely related to the -storage format, in this case NIfTI - only the (x,y,z) coordinates and -the intensity values count with respect to the analysis. That being -said, one common confusion arises when the left-right order of the -storage is changed (but the mm coordinates and intensities are -unchanged). For instance, imagine taking an image where the first -voxel is on the left and then swapping the left-right order so that -the new image is stored such that the first voxel is now the rightmost -one, but modifying the <code>qform</code> and <code>sform</code> -matrices appropriately so that this rightmost voxel still has the same -(x,y,z) coordinate as it had before - just a different voxel -coordinate. This kind of change will not affect any analysis in FSL -or any programs that are fully NIfTI compliant. However, some -programs are only happy with one sort of ordering (sometimes called -left-handed/right-handed, or radiological/neurological, or RAS/LAS, -etc.) -This used to be the case for old versions of FSL, but is no longer true. -But if only the order of the intensities in the file is swapped, -<i>without</i> compensating for this in the <code>sform</code> and -<code>qform</code> matrices, then the swapped version is no longer -equivalent to the original. This is why both the data order and -header information need to be kept in sync, and why running either -<code>fslswapdim</code> or <code>fslorient</code> alone to change the -orientation information is dangerous and usually incorrect. - -<p> - -An aside on display orientation: everything that has been said above -about the NIfTI format refers to coordinates and data storage and has -<i>nothing</i> to do with what way the images can be <i>displayed</i> -in different viewing programs. Although the storage can be referred to -as "radiological" or "neurological" this does not mean anything with -respect to the displayed orientation. A valid NIfTI image can be -displayed in any orientation that the viewing tool chooses, with the -left side of the brain shown on the right side of the screen (so -called radiological convention) or the other way around (neurological -convention). It is also possible to display the inferior side of the -brain at the top of the image, or any other configuration. It is -entirely up to the display software how it chooses to show the image -on the screen. What the NIfTI format does do is provide information -to determine how to label the different parts of the image (with mm -coordinates or anatomical labels such as left, right, anterior, -posterior, superior and inferior). As long as the display tool -correctly interprets this information and keeps it consistent with its -choice of display orientation, there is no conflict between any type -of NIfTI image and any displayed orientation. - -<p><HR><FONT SIZE=1>Copyright © 2000-2008, University of -Oxford. Written by <A -HREF="http://www.fmrib.ox.ac.uk/~steve/index.html">S. Smith</A> and M. Jenkinson.</FONT> - -<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br> -<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br> -<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br> -<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br> - -</BODY></HTML> - diff --git a/fsl2ascii.cc b/fsl2ascii.cc index 92ded9c..c790df2 100755 --- a/fsl2ascii.cc +++ b/fsl2ascii.cc @@ -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) << " "; } diff --git a/fslcc.cc b/fslcc.cc index e82a094..5de2041 100755 --- a/fslcc.cc +++ b/fslcc.cc @@ -1,6 +1,6 @@ // 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++) diff --git a/fslcheck.cc b/fslcheck.cc deleted file mode 100644 index 899f012..0000000 --- a/fslcheck.cc +++ /dev/null @@ -1,140 +0,0 @@ -/* 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; -} - diff --git a/fslcorrecthd.cc b/fslcorrecthd.cc deleted file mode 100755 index 261bf5f..0000000 --- a/fslcorrecthd.cc +++ /dev/null @@ -1,94 +0,0 @@ -// 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; -} - - diff --git a/fsldecorr4d.cc b/fsldecorr4d.cc deleted file mode 100644 index 9401239..0000000 --- a/fsldecorr4d.cc +++ /dev/null @@ -1,325 +0,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); -} - diff --git a/fslfromascii.cc b/fslfromascii.cc deleted file mode 100755 index 7ff89f4..0000000 --- a/fslfromascii.cc +++ /dev/null @@ -1,37 +0,0 @@ -// 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; -} - - diff --git a/tests/avw2ascii_test.sh b/tests/avw2ascii_test.sh deleted file mode 100755 index d3527e3..0000000 --- a/tests/avw2ascii_test.sh +++ /dev/null @@ -1,33 +0,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 diff --git a/tests/avwcc_test.sh b/tests/avwcc_test.sh deleted file mode 100755 index 10d64c1..0000000 --- a/tests/avwcc_test.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/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 diff --git a/tests/avwcpgeom_test.sh b/tests/avwcpgeom_test.sh deleted file mode 100755 index d128a9f..0000000 --- a/tests/avwcpgeom_test.sh +++ /dev/null @@ -1,97 +0,0 @@ -#!/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 diff --git a/tests/avwcreatehd_test.sh b/tests/avwcreatehd_test.sh deleted file mode 100755 index 192b49d..0000000 --- a/tests/avwcreatehd_test.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/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 diff --git a/tests/avwhd_test.sh b/tests/avwhd_test.sh deleted file mode 100755 index 7209514..0000000 --- a/tests/avwhd_test.sh +++ /dev/null @@ -1,61 +0,0 @@ -#!/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 diff --git a/tests/avwinterleave_test.sh b/tests/avwinterleave_test.sh deleted file mode 100755 index a150e7d..0000000 --- a/tests/avwinterleave_test.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/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 diff --git a/tests/avwmaths_test.sh b/tests/avwmaths_test.sh deleted file mode 100755 index dbe012c..0000000 --- a/tests/avwmaths_test.sh +++ /dev/null @@ -1,389 +0,0 @@ -#!/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 diff --git a/tests/avwmerge_test.sh b/tests/avwmerge_test.sh deleted file mode 100755 index 54801e9..0000000 --- a/tests/avwmerge_test.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/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 diff --git a/tests/avwnvols_test.sh b/tests/avwnvols_test.sh deleted file mode 100755 index 5afd986..0000000 --- a/tests/avwnvols_test.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/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 diff --git a/tests/avwroi_test.sh b/tests/avwroi_test.sh deleted file mode 100755 index 7e4063d..0000000 --- a/tests/avwroi_test.sh +++ /dev/null @@ -1,77 +0,0 @@ -#!/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 diff --git a/tests/avwsplit_test.sh b/tests/avwsplit_test.sh deleted file mode 100755 index c9a9802..0000000 --- a/tests/avwsplit_test.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/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 diff --git a/tests/fslswapdim_test.sh b/tests/fslswapdim_test.sh deleted file mode 100755 index f7c960e..0000000 --- a/tests/fslswapdim_test.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/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 - diff --git a/tests/header.xml b/tests/header.xml deleted file mode 100644 index 068fb2a..0000000 --- a/tests/header.xml +++ /dev/null @@ -1,28 +0,0 @@ -<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' -/> - diff --git a/tests/run_alltests.sh b/tests/run_alltests.sh deleted file mode 100755 index 0a49fe0..0000000 --- a/tests/run_alltests.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/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 -- GitLab