Newer
Older
/* FilmGlsOptionsRes.cc
Mark Woolrich, FMRIB Image Analysis Group
Copyright (C) 1999-2000 University of Oxford */
/* CCOPYRIGHT */
#define WANT_STREAM
#define WANT_MATH
#include <iostream>
#include <fstream>
#include <stdlib.h>
#include <stdio.h>
#include "newmatap.h"
#include "newmatio.h"
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
#include "FilmGlsOptionsRes.h"
#ifndef NO_NAMESPACE
using namespace NEWMAT;
namespace FILM {
#endif
FilmGlsOptionsRes* FilmGlsOptionsRes::gopt = NULL;
void FilmGlsOptionsRes::parse_command_line(int argc, char** argv, ofstream& logfile)
{
if(argc<2){
print_usage(argc,argv);
exit(1);
}
int inp = 1;
int n=1;
string arg;
char first;
logfile << "Arguments: " << endl;
while (n<argc) {
arg=argv[n];
// output argument to logfile:
logfile << arg << " ";
if (arg.size()<1) { n++; continue; }
first = arg[0];
if (first!='-') {
if(inp == 1)
gopt->inputfname = arg;
else if(inp == 2)
gopt->paradigmfname = arg;
else if(inp == 3)
gopt->thresh = atoi(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 == "-vdms" ) {
gopt->verbose_dms = true;
n++;
continue;
} else if ( arg == "-ar" ) {
gopt->fitAutoRegressiveModel = true;
gopt->tukey = false;
n++;
continue;
} else if ( arg == "-pava" ) {
gopt->pava = true;
gopt->tukey = false;
n++;
continue;
} else if ( arg == "-hfr" ) {
gopt->highfreqremoval=true;
n++;
continue;
} else if ( arg == "-sa" ) {
gopt->smoothACEst = true;
n++;
continue;
} else if ( arg == "-det" ) {
gopt->detrend = true;
n++;
continue;
} else if ( arg == "-noest" ) {
gopt->noest = true;
n++;
continue;
} else if ( arg == "-justpw" ) {
gopt->justprewhiten = 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]);
logfile << argv[n+1] << " ";
n+=2;
} else if ( arg == "-iters") {
gopt->numiters = atoi(argv[n+1]);
logfile << argv[n+1] << " ";
n+=2;
} else if ( arg == "-rn" ) {
gopt->datadir = argv[n+1];
logfile << argv[n+1] << " ";
n+=2;
} else if ( arg == "-tukey" ) {
gopt->tukeysize = atoi(argv[n+1]);
gopt->tukey = true;
logfile << argv[n+1] << " ";
n+=2;
} else if ( arg == "-mt" ) {
gopt->multitapersize = atoi(argv[n+1]);
gopt->tukey = false;
gopt->multitaper = true;
logfile << argv[n+1] << " ";
n+=2;
}
else if ( arg == "-epith" ) {
gopt->epith = atoi(argv[n+1]);
logfile << argv[n+1] << " ";
n+=2;
} else {
cerr << "Unrecognised option " << arg << endl;
n++;
}
} // while (n<argc)
logfile << endl << "---------------------------------------------" << endl << endl;
if (gopt->inputfname.size()<1) {
print_usage(argc,argv);
throw Exception("Input filename not found");
}
if (gopt->paradigmfname.size()<1) {
print_usage(argc,argv);
throw Exception("Paradigm filename not found");
}
if (gopt->thresh < 0) {
print_usage(argc,argv);
throw Exception("Invalid thresh");
}
}
void FilmGlsOptionsRes::print_usage(int argc, char *argv[])
{
cout << "Usage: " << argv[0] << " [options] <groupfile> <paradigmfile> <thresh>\n\n"
<< " Available options are:\n"
<< " -zout <zscoresfile> (default is "
<< gopt->zscoresfname << ")\n"
<< " -sa (smooths auto corr estimates)\n"
<< " -ms <num> (susan mask size)\n"
<< " -iters <num> (number of prewhitening iterations to use - default is "
<< gopt->numiters << ")\n"
<< " -hfr (perform high frequency artefact removal)\n"
<< " -epith <num> (set susan brightness threshold - otherwise it is estimated)\n"
<< " -v (outputs full data)\n"
<< " -vdms (outputs prewhiten design matrices)\n"
<< " -ar (fits autoregressive model - default "
<< "is to use tukey with M=2*sqrt(numvols))\n"
<< " -tukey <num> (uses tukey window to estimate autocorr with window size num - default "
<< "is to use tukey with M=2*sqrt(numvols))\n"
<< " -mt <num> (uses multitapering with slepian tapers and num is the time-bandwidth product - default "
<< "is to use tukey with M=2*sqrt(numvols))\n"
<< " -pava (estimates autocorr using PAVA - default "
<< "is to use tukey with M=2*sqrt(numvols))\n"
<< " -noest (do not estimate auto corrs)\n"
<< " -det (linear detrend data)\n"
<< " -rn <dir> (directory name to store results in, default is "
<< gopt->datadir << ")\n"
<< " -justpw (just prewhiten and output prewhitened data)\n"
<< " -help\n\n";
}
#ifndef NO_NAMESPACE
}
#endif