Newer
Older
/* FilmGlsOptions.cc
Mark Woolrich, FMRIB Image Analysis Group
Copyright (C) 1999-2000 University of Oxford */
#include <iostream>
#include <fstream>
#include <stdlib.h>
#include <stdio.h>
using namespace Utilities;
namespace FILM {
void FilmGlsOptions::parse_command_line(int argc, char** argv, Log& logger)
{
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(inp == 1)
gopt->inputfname = arg;
else if(inp == 2)
{
if(ac_only)
gopt->thresh = atof(argv[n]);
else
gopt->paradigmfname = arg;
}
else if(inp == 3 && !ac_only)
gopt->thresh = atof(argv[n]);
else
{
cerr << "Mismatched argument " << arg << endl;
break;
}
n++;
inp++;
continue;
}
// put options without arguments here
if ( arg == "-help" ) {
print_usage(argc,argv);
exit(0);
} else if ( arg == "-v" ) {
gopt->verbose = true;
n++;
continue;
} else if ( arg == "-ar" ) {
gopt->fitAutoRegressiveModel = true;
} else if ( arg == "-ac" ) {
gopt->ac_only = true;
n++;
continue;
} else if ( arg == "-pava" ) {
gopt->pava = true;
gopt->tukey = false;
n++;
continue;
} else if ( arg == "-sa" ) {
gopt->smoothACEst = true;
n++;
continue;
} else if ( arg == "-noest" ) {
gopt->noest = true;
} else if ( arg == "-output_pwdata" ) {
gopt->output_pwdata = true;
n++;
continue;
if (n+1>=argc)
{
cerr << "Lacking argument to option " << arg << endl;
break;
}
// put options with 1 argument here
if ( arg == "-ms") {
gopt->ms = atoi(argv[n+1]);
n+=2;
} else if ( arg == "-sp" ) {
gopt->susanpath = argv[n+1];
n+=2;
} else if ( arg == "-rn" ) {
gopt->datadir = argv[n+1];
n+=2;
} else if ( arg == "-tukey" ) {
gopt->tukeysize = atoi(argv[n+1]);
gopt->tukey = true;
n+=2;
} else if ( arg == "-mt" ) {
gopt->multitapersize = atoi(argv[n+1]);
gopt->tukey = false;
gopt->multitaper = true;
n+=2;
}
else if ( arg == "-epith" ) {
gopt->epith = atoi(argv[n+1]);
n+=2;
} else {
cerr << "Unrecognised option " << arg << endl;
n++;
}
} // while (n<argc)
logger.makeDir(gopt->datadir);
cout << "Log directory is: " << logger.getDir() << endl;
for(int a = 0; a < argc; a++)
logger.str() << argv[a] << " ";
logger.str() << endl << "---------------------------------------------" << endl << endl;
if (gopt->inputfname.size()<1) {
print_usage(argc,argv);
throw Exception("Input filename not found");
}
if (gopt->paradigmfname.size()<1 && !ac_only) {
throw Exception("Paradigm filenam needs to be specified");
}
void FilmGlsOptions::print_usage(int argc, char *argv[])
{
cout << "Usage: " << argv[0] << " [options] <groupfile> [optional:<paradigmfile>] <thresh>\n\n"
<< " Available options are:\n"
<< " -sa (smooths auto corr estimates)\n"
<< " -epith <num> (set susan brightness threshold - otherwise it is estimated)\n"
<< " -ac (perform autocorrelation estimation only)"
<< " -ar (fits autoregressive model - default "
<< " -tukey <num> (uses tukey window to estimate autocorr with window size num - default "
<< " -mt <num> (uses multitapering with slepian tapers and num is the time-bandwidth product - default "
<< " -pava (estimates autocorr using PAVA - default "
<< " -output_pwdata (output prewhitened data and average design matrix)\n"
<< " -rn <dir> (directory name to store results in, default is "
<< gopt->datadir << ")\n"
<< " -help\n\n";
}
#ifndef NO_NAMESPACE
}
#endif