Newer
Older
Mark Woolrich, FMRIB Image Analysis Group
Copyright (C) 1999-2000 University of Oxford */
/* CCOPYRIGHT */
#include <iostream>
#include <fstream>
#include "newmat/newmatap.h"
#include "newmat/newmatio.h"
using namespace FILM;
using namespace MISCMATHS;
// the real defaults are provided in the function parse_command_line
class globaloptions {
public:
string zscoresfname;
public:
globaloptions();
~globaloptions() {};
};
globaloptions globalopts;
globaloptions::globaloptions()
{
// set up defaults
zscoresfname = "zstats";
}
void print_usage(int argc, char *argv[])
{
cout << "Usage: " << argv[0] << " [options] <fsfile> <dof1> <dof2> \n"
<< " Available options are:\n"
<< " -zout <outputvol> (default is "
<< globalopts.zscoresfname << ")\n"
<< " -help\n\n";
}
void parse_command_line(int argc, char* argv[])
{
if(argc<2){
print_usage(argc,argv);
exit(1);
}
int inp = 1;
int n=1;
string arg;
char first;
while (n<argc) {
arg=argv[n];
if (arg.size()<1) { n++; continue; }
first = arg[0];
if (first!='-') {
if(inp == 1)
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
else
{
cerr << "Mismatched argument " << arg << endl;
break;
}
n++;
inp++;
continue;
}
// put options without arguments here
if ( arg == "-help" ) {
print_usage(argc,argv);
exit(0);
}
if (n+1>=argc)
{
cerr << "Lacking argument to option " << arg << endl;
break;
}
// put options with 1 argument here
if ( arg == "-zout") {
globalopts.zscoresfname = argv[n+1];
n+=2;
} else {
cerr << "Unrecognised option " << arg << endl;
n++;
}
} // while (n<argc)
if (globalopts.fsfname.size()<1) {
cerr << "Fs filename not found\n\n";
print_usage(argc,argv);
exit(2);
}
}
int main(int argc,char *argv[])
{
try{
parse_command_line(argc, argv);
Volume fs;
fs.read(globalopts.fsfname.c_str());
F2z::ComputeFStats(fs, globalopts.dof1, globalopts.dof2, zs);
zs.setDims(fs.getDims());