/* FilmGlsOptions.cc Mark Woolrich, FMRIB Image Analysis Group Copyright (C) 1999-2000 University of Oxford */ /* CCOPYRIGHT */ #define WANT_STREAM #define WANT_MATH #include <iostream.h> #include <fstream.h> #include <stdlib.h> #include <stdio.h> #include "FilmGlsOptions.h" #include "utils/log.h" using namespace Utilities; namespace FILM { FilmGlsOptions* FilmGlsOptions::gopt = NULL; 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 (arg.size()<1) { n++; continue; } first = arg[0]; if (first!='-' || inp==3) { 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; gopt->tukey = false; n++; continue; } 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; 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) { print_usage(argc,argv); 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" << " -ms <num> (susan mask size)\n" << " -epith <num> (set susan brightness threshold - otherwise it is estimated)\n" << " -v (outputs full data)\n" << " -ac (perform autocorrelation estimation only)" << " -ar (fits autoregressive model - default " << "is to use tukey with M=sqrt(numvols))\n" << " -tukey <num> (uses tukey window to estimate autocorr with window size num - default " << "is to use tukey with M=sqrt(numvols))\n" << " -mt <num> (uses multitapering with slepian tapers and num is the time-bandwidth product - default " << "is to use tukey with M=sqrt(numvols))\n" << " -pava (estimates autocorr using PAVA - default " << "is to use tukey with M=sqrt(numvols))\n" << " -noest (do not estimate auto corrs)\n" << " -rn <dir> (directory name to store results in, default is " << gopt->datadir << ")\n" << " -help\n\n"; } #ifndef NO_NAMESPACE } #endif