-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathreadoptions.h
260 lines (212 loc) · 9.21 KB
/
readoptions.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
/* readoptions.h
Michael Chappell - FMRIB Image Analysis Group
Moss Zhao - IBME Quantitative Biomedical Inference (QuBIc) Group
Copyright (C) 2015 University of Oxford */
/* CCOPYRIGHT */
#if !defined(ReadOptions_h)
#define ReadOptions_h
#include <fstream>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include "utils/log.h"
#include "utils/options.h"
namespace OXASL
{
class ReadOptions
{
public:
static ReadOptions &getInstance();
~ReadOptions() { delete ropt; }
Utilities::Option<bool> help;
Utilities::Option<bool> version;
Utilities::Option<std::string> datafile;
Utilities::Option<std::string> maskfile;
Utilities::Option<int> ntis;
Utilities::Option<std::string> inblockform;
Utilities::Option<std::string> inaslform;
Utilities::Option<std::string> rpts;
Utilities::Option<bool> ispairs;
Utilities::Option<bool> splitpairs;
Utilities::Option<bool> tcdiff;
Utilities::Option<bool> surrtcdiff;
Utilities::Option<std::string> outblockform;
Utilities::Option<std::string> out;
Utilities::Option<std::string> meanout;
Utilities::Option<std::string> splitout;
Utilities::Option<std::string> epochout;
Utilities::Option<int> epochlen;
Utilities::Option<int> epochover;
Utilities::Option<std::string> epochunit;
Utilities::Option<std::string> deconvout;
Utilities::Option<std::string> aif;
// Extrapolate the edge of the brain to fix the artefact on the edge of the brain
// Assumes an eroded brain
Utilities::Option<bool> extrapolate_option;
Utilities::Option<int> neighbour;
// Partial volume correction (linear regression method) parameters
Utilities::Option<std::string> pv_gm_file;
Utilities::Option<std::string> pv_wm_file;
Utilities::Option<int> kernel;
bool parse_command_line(int argc, char **argv);
private:
ReadOptions();
const ReadOptions &operator=(ReadOptions &);
ReadOptions(ReadOptions &);
Utilities::OptionParser options;
static ReadOptions *ropt;
};
inline ReadOptions &ReadOptions::getInstance()
{
if (ropt == NULL)
ropt = new ReadOptions();
return *ropt;
}
inline ReadOptions::ReadOptions()
:
help(std::string("-h,--help"), false,
std::string("display this message"),
false, Utilities::no_argument)
,
version(std::string("-v,--version"), false,
std::string("display version identification"),
false, Utilities::no_argument)
,
//input files
datafile(std::string("--data,--datafile"), std::string("ASL datafile"),
std::string("data file"),
true, Utilities::requires_argument)
, maskfile(std::string("--mask"), std::string("maskfile\n"),
std::string("mask"),
false, Utilities::requires_argument)
,
//input file information
ntis(std::string("--ntis"), 0,
std::string("Number of TIs in file"),
true, Utilities::requires_argument)
, inblockform(std::string("--ibf,--inblockform"), std::string("rpt"),
std::string("Input block format:\n rpt - blocks of measurements that include all TIs\n tis - blocks of repeated measurements at a single TI"),
false, Utilities::requires_argument)
, inaslform(std::string("--iaf,--inaslform"), std::string("diff"),
std::string("ASL data form:\n diff - differenced data {default}\n tc - Tag-Control pairs\n ct - Control-Tag pairs\n tcb - Tag-Control pairs, tags and controls grouped together within block\n ctb - Control-Tag pairs, tags and controls grouped together within block"),
false, Utilities::requires_argument)
, rpts(std::string("--rpts"), std::string("NULL"),
std::string("Number of repeats at each TI as comma separated list, not required if the number of repeats is same for all TIs (only for use with --ibf=tis)"),
false, Utilities::requires_argument)
,
ispairs(std::string("--pairs,--inpairs"), false,
std::string("Data contains adjacent pairs of measuremnts (e.g. Tag, Control) DEPRECEATED used --iaf instead\n"),
false, Utilities::no_argument)
,
//asaq(std::string("--asaq"),false,
// std::string("Data is as aquired: same as --blocked --pairs"),
// false,Utilities::no_argument),
// manipulation options
splitpairs(std::string("--spairs"), false,
std::string("Split the pairs within the data, e.g. to separate tag and control images in output"),
false, Utilities::no_argument)
, tcdiff(std::string("--diff"), false,
std::string("Take the difference between the pairs, i.e. Tag control difference"),
false, Utilities::no_argument)
, surrtcdiff(std::string("--surrdiff"), false,
std::string("Do surround subtraction on the pairs\n"),
false, Utilities::no_argument)
,
//basic output
outblockform(std::string("--obf,--outblockform"), std::string("notset"),
std::string("Output block format (for --out=):\n rpt - blocks of measurements that include all TIs\n tis - blocks of repeated measurements at a single TI\n Default is same as input block format (--ibf)"),
false, Utilities::requires_argument)
, out(std::string("--out"), std::string("Out filename"),
std::string("Output data file"),
false, Utilities::requires_argument)
,
// other output options
meanout(std::string("--mean"), std::string(""),
std::string("Output ASL data having taken mean at each TI to file"),
false, Utilities::requires_argument)
, splitout(std::string("--split"), std::string(""),
std::string("Split data into separate files each each TI, specify filename root\n"),
false, Utilities::requires_argument)
,
epochout(std::string("--epoch"), std::string(""),
std::string("Output epochs of ASL data (takes mean at each TI within the epoch)"),
false, Utilities::requires_argument)
, epochlen(std::string("--elen,--epochlen"), 1,
std::string("Length of epochs in number of repeats"),
false, Utilities::requires_argument)
, epochover(std::string("--eol,--epochol"), 0,
std::string("Ammount of overlap between epochs in number of repeats"),
false, Utilities::requires_argument)
, epochunit(std::string("--eunit,--epochunit"), std::string("rpt"),
std::string("Epochs to be determined over:\n rpt - repeats in the data {default}\n tis - TIs in the data\n"),
false, Utilities::requires_argument)
,
deconvout(std::string("--deconv"), std::string(""),
std::string("Deconvolution of data with arterial input functions"),
false, Utilities::requires_argument)
, aif(std::string("--aif"), std::string(""),
std::string("Arterial input functions for deconvolution (4D volume, one aif for each voxel within mask)\n"),
false, Utilities::requires_argument)
,
// Extrapolate the edge of the brain to fix the artefact on the edge of the brain
// Assumes an eroded brain
extrapolate_option(std::string("--extrapolate"), false,
std::string("Option to extrapolate the edge of the brain to fix the artefact on the edge of the brain"),
false, Utilities::no_argument)
, neighbour(std::string("--neighbour"), 5, std::string("Neighbour size for extrapolation, must be an odd number between 3 and 9. Default: 5\n"),
false, Utilities::requires_argument)
,
// Partial volume (linear regression) options
pv_gm_file(std::string("--pvgm"), std::string(""), std::string("GM partial volume map"),
false, Utilities::requires_argument)
, pv_wm_file(std::string("--pvwm"), std::string(""), std::string("WM partial volume map"),
false, Utilities::requires_argument)
, kernel(std::string("--kernel"), 5, std::string("Kernel size (in voxels) of partial volume correction, must be an odd number between 3 and 9. Default: 5\n"),
false, Utilities::requires_argument)
,
options("asl_file", "asl_file --data=<asldata> --ibf=rpt --iaf=tc --diff --out=<diffdata>\n")
{
try
{
options.add(help);
options.add(version);
options.add(datafile);
options.add(maskfile);
options.add(ntis);
options.add(inblockform);
options.add(inaslform);
options.add(rpts);
options.add(ispairs);
options.add(splitpairs);
options.add(tcdiff);
options.add(surrtcdiff);
options.add(extrapolate_option);
options.add(neighbour);
options.add(pv_gm_file);
options.add(pv_wm_file);
options.add(kernel);
options.add(out);
options.add(outblockform);
options.add(meanout);
options.add(splitout);
options.add(epochout);
options.add(epochlen);
options.add(epochover);
options.add(epochunit);
options.add(deconvout);
options.add(aif);
}
catch (Utilities::X_OptionError &e)
{
options.usage();
std::cerr << std::endl
<< e.what() << std::endl;
}
catch (std::exception &e)
{
std::cerr << e.what() << std::endl;
}
}
}
#endif