8 using namespace FWDLIB;
14 #ifndef PROGRAM_VERSION
15 #define PROGRAM_VERSION "2.10"
26 ComputeFwdSettings::ComputeFwdSettings()
33 ComputeFwdSettings::ComputeFwdSettings(
int *argc,
char **argv)
37 if (!check_args(argc,argv))
41 printf(
"%s version %s compiled at %s %s\n",argv[0],PROGRAM_VERSION,__DATE__,__TIME__);
48 ComputeFwdSettings::~ComputeFwdSettings()
55 void ComputeFwdSettings::checkIntegrity()
57 if (srcname.isEmpty()) {
58 qCritical(
"Source space name is missing. Use the --src option to specify it.");
61 if (!mri_head_ident) {
62 if (mriname.isEmpty() && transname.isEmpty()) {
63 qCritical(
"MRI <-> head coordinate transformation is missing. Use the --mri or --trans option to specify it.");
67 if (measname.isEmpty()) {
68 qCritical(
"Source of coil and electrode locations is missing. Use the --meas option to specify it.");
71 if (solname.isEmpty()) {
72 qCritical(
"Solution name is missing. Use the --fwd option to specify it.");
75 if (! (include_meg || include_eeg)) {
76 qCritical(
"Employ the --meg and --eeg options to select MEG and/or EEG");
83 void ComputeFwdSettings::initMembers()
86 r0 << 0.0f,0.0f,0.04f;
95 coord_frame = FIFFV_COORD_HEAD;
99 eeg_sphere_rad = 0.09f;
100 scale_eeg_pos =
false;
101 use_equiv_eeg =
true;
104 pFiffInfo = Q_NULLPTR;
105 meg_head_t = Q_NULLPTR;
110 void ComputeFwdSettings::usage(
char *name)
112 printf(
"usage : %s [options]\n",name);
113 printf(
"\t--meg to compute the MEG forward solution\n");
114 printf(
"\t--eeg to compute the EEG forward solution\n");
115 printf(
"\t--grad compute the gradient of the field with respect to the dipole coordinates as well\n");
116 printf(
"\t--fixed to calculate only for the source orientation given by the surface normals\n");
117 printf(
"\t--mricoord do calculations in MRI coordinates instead of head coordinates\n");
118 printf(
"\t--accurate use more accurate coil definitions in MEG forward computation\n");
119 printf(
"\t--src name specify the source space\n");
120 printf(
"\t--label name label file to select the sources (can have multiple of these)\n");
121 printf(
"\t--mri name take head/MRI coordinate transform from here (Neuromag MRI description file)\n");
122 printf(
"\t--trans name take head/MRI coordinate transform from here (text file)\n");
123 printf(
"\t--notrans head and MRI coordinate systems are identical.\n");
124 printf(
"\t--meas name take MEG sensor and EEG electrode locations from here\n");
125 printf(
"\t--bem name BEM model name\n");
126 printf(
"\t--origin x:y:z/mm use a sphere model with this origin (head coordinates/mm)\n");
127 printf(
"\t--eegscalp scale the electrode locations to the surface of the scalp when using a sphere model\n");
128 printf(
"\t--eegmodels name read EEG sphere model specifications from here.\n");
129 printf(
"\t--eegmodel name name of the EEG sphere model to use (default : Default)\n");
130 printf(
"\t--eegrad rad/mm radius of the scalp surface to use in EEG sphere model (default : %7.1f mm)\n",1000*eeg_sphere_rad);
131 printf(
"\t--mindist dist/mm minimum allowable distance of the sources from the inner skull surface.\n");
132 printf(
"\t--mindistout name Output the omitted source space points here.\n");
133 printf(
"\t--includeall Omit all source space checks\n");
134 printf(
"\t--all calculate forward solution in all nodes instead the selected ones only.\n");
135 printf(
"\t--fwd name save the solution here\n");
136 printf(
"\t--help print this info.\n");
137 printf(
"\t--version print version info.\n\n");
143 QString ComputeFwdSettings::build_command_line(QString old, QString new_item)
145 if (!new_item.isEmpty() && new_item.size() > 0) {
146 if (!old.isEmpty()) {
156 bool ComputeFwdSettings::check_unrecognized_args(
int argc,
char **argv)
161 printf(
"Unrecognized arguments : ");
162 for (
k = 1;
k < argc;
k++)
163 printf(
"%s ",argv[
k]);
165 qCritical(
"Check the command line.");
173 bool ComputeFwdSettings::check_args (
int *argc,
char **argv)
178 if ((last = strrchr(argv[0],
'/')) == NULL)
182 command = build_command_line(command,last);
183 for (
int k = 0;
k < *argc;
k++) {
185 if (strcmp(argv[
k],
"--version") == 0) {
186 printf(
"%s version %s compiled at %s %s\n", argv[0],PROGRAM_VERSION,__DATE__,__TIME__);
189 else if (strcmp(argv[
k],
"--help") == 0) {
193 else if (strcmp(argv[
k],
"--meg") == 0) {
197 else if (strcmp(argv[
k],
"--eeg") == 0) {
201 else if (strcmp(argv[
k],
"--grad") == 0) {
205 else if (strcmp(argv[
k],
"--all") == 0) {
209 else if (strcmp(argv[
k],
"--accurate") == 0) {
213 else if (strcmp(argv[
k],
"--fixed") == 0) {
217 else if (strcmp(argv[
k],
"--src") == 0) {
219 if (
k == *argc - 1) {
220 qCritical(
"--src: argument required.");
223 srcname = QString(argv[
k+1]);
225 else if (strcmp(argv[
k],
"--mri") == 0) {
227 if (
k == *argc - 1) {
228 qCritical(
"--mri: argument required.");
231 mri_head_ident =
false;
232 mriname = QString(argv[
k+1]);
235 else if (strcmp(argv[
k],
"--trans") == 0) {
237 if (
k == *argc - 1) {
238 qCritical(
"--trans: argument required.");
241 mri_head_ident =
false;
242 transname = QString(argv[
k+1]);
245 else if (strcmp(argv[
k],
"--notrans") == 0) {
247 mri_head_ident =
true;
251 else if (strcmp(argv[
k],
"--meas") == 0) {
253 if (
k == *argc - 1) {
254 qCritical(
"--meas: argument required.");
257 measname = QString(argv[
k+1]);
259 else if (strcmp(argv[
k],
"--bem") == 0) {
261 if (
k == *argc - 1) {
262 qCritical(
"--bem: argument required.");
265 bemname = QString(argv[
k+1]);
267 else if (strcmp(argv[
k],
"--origin") == 0) {
269 if (
k == *argc - 1) {
270 qCritical(
"--origin: argument required.");
273 if (sscanf(argv[
k+1],
"%f:%f:%f",r0[X],r0[Y],r0[Z]) != 3) {
274 qCritical(
"Could not interpret the origin.");
277 r0[X] = r0[X]/1000.0f;
278 r0[Y] = r0[Y]/1000.0f;
279 r0[Z] = r0[Z]/1000.0f;
281 else if (strcmp(argv[
k],
"--eegrad") == 0) {
283 if (
k == *argc - 1) {
284 qCritical(
"--eegrad: argument required.");
287 if (sscanf(argv[
k+1],
"%g",&eeg_sphere_rad) != 1) {
288 qCritical(
"Incomprehensible radius : %s",argv[
k+1]);
291 if (eeg_sphere_rad <= 0) {
292 qCritical(
"Radius must be positive");
295 eeg_sphere_rad = eeg_sphere_rad/1000.0f;
297 else if (strcmp(argv[
k],
"--eegmodels") == 0) {
299 if (
k == *argc - 1) {
300 qCritical(
"--eegmodels: argument required.");
303 eeg_model_file = QString(argv[
k+1]);
305 else if (strcmp(argv[
k],
"--eegmodel") == 0) {
307 if (
k == *argc - 1) {
308 qCritical(
"--eegmodel: argument required.");
311 eeg_model_name = QString(argv[
k+1]);
313 else if (strcmp(argv[
k],
"--eegscalp") == 0) {
315 scale_eeg_pos =
true;
317 else if (strcmp(argv[
k],
"--mindist") == 0) {
319 if (
k == *argc - 1) {
320 qCritical(
"--mindist: argument required.");
323 if (sscanf(argv[
k+1],
"%f",&mindist) != 1) {
324 qCritical(
"Could not interpret the distance.");
329 mindist = mindist/1000.0f;
331 else if (strcmp(argv[
k],
"--includeall") == 0) {
333 filter_spaces =
false;
335 else if (strcmp(argv[
k],
"--mindistout") == 0) {
337 if (
k == *argc - 1) {
338 qCritical(
"--mindistout: argument required.");
341 mindistoutname = QString(argv[
k+1]);
343 else if (strcmp(argv[
k],
"--mricoord") == 0) {
345 coord_frame = FIFFV_COORD_MRI;
347 else if (strcmp(argv[
k],
"--fwd") == 0) {
349 if (
k == *argc - 1) {
350 qCritical(
"--fwd: argument required.");
353 solname = QString(argv[
k+1]);
355 else if (strcmp(argv[
k],
"--label") == 0) {
357 if (
k == *argc - 1) {
358 qCritical(
"--label: argument required.");
361 labels.append(QString(argv[
k+1]));
365 for (
int p =
k; p <
k + found; p++)
366 command = build_command_line(command,argv[p]);
367 for (
int p =
k; p < *argc-found; p++)
368 argv[p] = argv[p+found];
369 *argc = *argc - found;
373 return check_unrecognized_args(*argc,argv);