v2.0.0
Loading...
Searching...
No Matches
inv_dipole_fit_settings.cpp
Go to the documentation of this file.
1//=============================================================================================================
18
19//=============================================================================================================
20// INCLUDES
21//=============================================================================================================
22
24
25//=============================================================================================================
26// USED NAMESPACES
27//=============================================================================================================
28
29using namespace Eigen;
30using namespace INVLIB;
31
32//=============================================================================================================
33// DEFINE MEMBER METHODS
34//=============================================================================================================
35
40
41//=============================================================================================================
42
44{
45 initMembers();
46
47 if (!check_args(argc,argv))
48 return;
49
51}
52
53//=============================================================================================================
54
58
59//=============================================================================================================
60
61void InvDipoleFitSettings::initMembers()
62{
63 // Init origin
64 r0 << 0.0f,0.0f,0.04f;
65
66 filter.filter_on = true;
67 filter.size = 4096;
68 filter.taper_size = 2048;
69 filter.highpass = 0.0;
71 filter.lowpass = 40.0;
73 filter.eog_highpass = 0.0;
75 filter.eog_lowpass = 40.0;
77
78 accurate = false;
79
80 guess_rad = 0.080f;
81 guess_mindist = 0.010f;
82 guess_exclude = 0.020f;
83 guess_grid = 0.010f;
84
85 grad_std = 5e-13f;
86 mag_std = 20e-15f;
87 eeg_std = 0.2e-6f;
88 diagnoise = false;
89
90 is_raw = false;
91 include_meg = false;
92 include_eeg = false;
93 tmin = -2*BIG_TIME;
94 tmax = 2*BIG_TIME;
95 tstep = -1.0;
96 integ = 0.0;
97 bmin = BIG_TIME;
98 bmax = BIG_TIME;
99 do_baseline = false;
100 setno = 1;
101 verbose = false;
102 omit_data_proj = false;
103
104
105 eeg_sphere_rad = 0.09f;
106 scale_eeg_pos = false;
107 mag_reg = 0.1f;
108 fit_mag_dipoles = false;
109
110 grad_reg = 0.1f;
111 eeg_reg = 0.1f;
112
113 gui = false;
114}
115
116//=============================================================================================================
117
119{
121
122 if (measname.isEmpty()) {
123 qCritical ("Data file name missing. Please specify one using the --meas option.");
124 return;
125 }
126 if (dipname.isEmpty() && bdipname.isEmpty()) {
127 qCritical ("Output file name missing. Please use the --dip or --bdip options to do this.");
128 return;
129 }
130 if (guessname.isEmpty()) {
131 if (bemname.isEmpty() && !guess_surfname.isEmpty() && mriname.isEmpty()) {
132 qCritical ("Please specify the MRI/head coordinate transformation with the --mri option");
133 return;
134 }
135 }
136 if (!include_meg && !include_eeg) {
137 qCritical ("Specify one or both of the --eeg and --meg options");
138 return;
139 }
140 if (!omit_data_proj)
141 projnames.prepend(measname);
142
143 if (!bemname.isEmpty())
144 qInfo("BEM : %s",bemname.toUtf8().data());
145 else {
146 qInfo("Sphere model : origin at (% 7.2f % 7.2f % 7.2f) mm",
147 1000*r0[0],1000*r0[1],1000*r0[2]);
148 }
149 qInfo("Using %s MEG coil definitions.",accurate ? "accurate" : "standard");
150 if (!mriname.isEmpty())
151 qInfo("MRI transform : %s",mriname.toUtf8().data());
152 if (!guessname.isEmpty())
153 qInfo("Guesses : %s",guessname.toUtf8().data());
154 else {
155 if (!guess_surfname.isEmpty())
156 qInfo("Guess space bounded by %s",guess_surfname.toUtf8().data());
157 else
158 qInfo("Spherical guess space, rad = %.1f mm",1000*guess_rad);
159 qInfo("Guess grid : %6.1f mm",1000*guess_grid);
160 if (guess_mindist > 0.0)
161 qInfo("Guess mindist : %6.1f mm",1000*guess_mindist);
162 if (guess_exclude > 0)
163 qInfo("Guess exclude : %6.1f mm",1000*guess_exclude);
164 }
165 qInfo("Data : %s",measname.toUtf8().data());
166 if (projnames.size() > 0) {
167 qInfo("SSP sources :");
168 for (int k = 0; k < projnames.size(); k++)
169 qInfo("\t%s",projnames[k].toUtf8().data());
170 }
171 if (!badname.isEmpty())
172 qInfo("Bad channels : %s",badname.toUtf8().data());
173 if (do_baseline)
174 qInfo("Baseline : %10.2f ... %10.2f ms", 1000*bmin,1000*bmax);
175 if (!noisename.isEmpty()) {
176 qInfo("Noise covariance : %s",noisename.toUtf8().data());
177 if (include_meg) {
178 if (mag_reg > 0.0)
179 qInfo("\tNoise-covariance regularization (mag) : %-5.2f",mag_reg);
180 if (grad_reg > 0.0)
181 qInfo("\tNoise-covariance regularization (grad) : %-5.2f",grad_reg);
182 }
183 if (include_eeg && eeg_reg > 0.0)
184 qInfo("\tNoise-covariance regularization (EEG) : %-5.2f",eeg_reg);
185 }
186 if (fit_mag_dipoles)
187 qInfo("Fit data with magnetic dipoles");
188 if (!dipname.isEmpty())
189 qInfo("dip output : %s",dipname.toUtf8().data());
190 if (!bdipname.isEmpty())
191 qInfo("bdip output : %s",bdipname.toUtf8().data());
192}
193
194//=============================================================================================================
195
196void InvDipoleFitSettings::usage(const char *name)
197{
198 qInfo("usage: %s [options]",name);
199 qInfo("This is a program for sequential single dipole fitting.");
200 qInfo("\nInput data:\n");
201 qInfo("\t--meas name specify an evoked-response data file");
202 qInfo("\t--set no evoked data set number to use (default: 1)");
203 qInfo("\t--bad name take bad channel list from here");
204
205 qInfo("\nModality selection:\n");
206 qInfo("\t--meg employ MEG data in fitting");
207 qInfo("\t--eeg employ EEG data in fitting");
208
209 qInfo("\nTime scale selection:\n");
210 qInfo("\t--tmin time/ms specify the starting analysis time");
211 qInfo("\t--tmax time/ms specify the ending analysis time");
212 qInfo("\t--tstep time/ms specify the time step between frames (default 1/(sampling frequency))");
213 qInfo("\t--integ time/ms specify the time integration for each frame (default 0)");
214
215 qInfo("\nPreprocessing:\n");
216 qInfo("\t--bmin time/ms specify the baseline starting time (evoked data only)");
217 qInfo("\t--bmax time/ms specify the baseline ending time (evoked data only)");
218 qInfo("\t--proj name Load the linear projection from here");
219 qInfo("\t Multiple projections can be specified.");
220 qInfo("\t The data file will be automatically included, unless --noproj is present.");
221 qInfo("\t--noproj Do not load the projection from the data file, just those given with the --proj option.");
222 qInfo("\n\tFiltering (raw data only):\n");
223 qInfo("\t--filtersize size desired filter length (default = %d)",filter.size);
224 qInfo("\t--highpass val/Hz highpass corner (default = %6.1f Hz)",filter.highpass);
225 qInfo("\t--lowpass val/Hz lowpass corner (default = %6.1f Hz)",filter.lowpass);
226 qInfo("\t--lowpassw val/Hz lowpass transition width (default = %6.1f Hz)",filter.lowpass_width);
227 qInfo("\t--filteroff do not filter the data");
228
229 qInfo("\nNoise specification:\n");
230 qInfo("\t--noise name take the noise-covariance matrix from here");
231 qInfo("\t--gradnoise val specify a gradiometer noise value in fT/cm");
232 qInfo("\t--magnoise val specify a magnetometer noise value in fT");
233 qInfo("\t--eegnoise val specify an EEG value in uV");
234 qInfo("\t NOTE: The above will be used only if --noise is missing");
235 qInfo("\t--diagnoise omit off-diagonal terms from the noise-covariance matrix");
236 qInfo("\t--reg amount Apply regularization to the noise-covariance matrix (same fraction for all channels).");
237 qInfo("\t--gradreg amount Apply regularization to the MEG noise-covariance matrix (planar gradiometers, default = %6.2f).",grad_reg);
238 qInfo("\t--magreg amount Apply regularization to the MEG noise-covariance matrix (axial gradiometers and magnetometers, default = %6.2f).",mag_reg);
239 qInfo("\t--eegreg amount Apply regularization to the EEG noise-covariance matrix (default = %6.2f).",eeg_reg);
240
241 qInfo("\nForward model:\n");
242 qInfo("\t--mri name take head/MRI coordinate transform from here (Neuromag MRI description file)");
243 qInfo("\t--bem name BEM model name");
244 qInfo("\t--origin x:y:z/mm use a sphere model with this origin (head coordinates/mm)");
245 qInfo("\t--eegscalp scale the electrode locations to the surface of the scalp when using a sphere model");
246 qInfo("\t--eegmodels name read EEG sphere model specifications from here.");
247 qInfo("\t--eegmodel name name of the EEG sphere model to use (default : Default)");
248 qInfo("\t--eegrad val radius of the scalp surface to use in EEG sphere model (default : %7.1f mm)",1000*eeg_sphere_rad);
249 qInfo("\t--accurate use accurate coil definitions in MEG forward computation");
250
251 qInfo("\nFitting parameters:\n");
252 qInfo("\t--guess name The source space of initial guesses.");
253 qInfo("\t If not present, the values below are used to generate the guess grid.");
254 qInfo("\t--guesssurf name Read the inner skull surface from this fif file to generate the guesses.");
255 qInfo("\t--guessrad value Radius of a spherical guess volume if neither of the above is present (default : %.1f mm)",1000*guess_rad);
256 qInfo("\t--exclude dist/mm Exclude points which are closer than this distance from the CM of the inner skull surface (default = %6.1f mm).",1000*guess_exclude);
257 qInfo("\t--mindist dist/mm Exclude points which are closer than this distance from the inner skull surface (default = %6.1f mm).",1000*guess_mindist);
258 qInfo("\t--grid dist/mm Source space grid size (default = %6.1f mm).",1000*guess_grid);
259 qInfo("\t--magdip Fit magnetic dipoles instead of current dipoles.");
260 qInfo("\nOutput:\n");
261 qInfo("\t--dip name xfit dip format output file name");
262 qInfo("\t--bdip name xfit bdip format output file name");
263 qInfo("\nGeneral:\n");
264 qInfo("\t--gui Enables the gui.");
265 qInfo("\t--help print this info.");
266 qInfo("\t--version print version info.");
267}
268
269//=============================================================================================================
270
271bool InvDipoleFitSettings::check_unrecognized_args(int argc, char **argv)
272{
273 if ( argc > 1 ) {
274 QString args;
275 for (int k = 1; k < argc; k++)
276 args += QString(argv[k]) + " ";
277 qCritical("Unrecognized arguments : %s", args.trimmed().toUtf8().data());
278 return false;
279 }
280 return true;
281}
282
283//=============================================================================================================
284
285bool InvDipoleFitSettings::check_args (int *argc,char **argv)
286{
287 int found;
288 float fval;
289 int ival,filter_size;
290
291 for (int k = 0; k < *argc; k++) {
292 found = 0;
293 if (strcmp(argv[k],"--gui") == 0) {
294 found = 1;
295 gui = true;
296 }
297 else if (strcmp(argv[k],"--version") == 0) {
298 qInfo("%s compiled at %s %s",
299 argv[0],__DATE__,__TIME__);
300 exit(0);
301 }
302 else if (strcmp(argv[k],"--help") == 0) {
303 usage(argv[0]);
304 exit(1);
305 }
306 else if (strcmp(argv[k],"--guess") == 0) {
307 found = 2;
308 if (k == *argc - 1) {
309 qCritical ("--guess: argument required.");
310 return false;
311 }
312 guessname = QString(argv[k+1]);
313 }
314 else if (strcmp(argv[k],"--gsurf") == 0) {
315 found = 2;
316 if (k == *argc - 1) {
317 qCritical ("--gsurf: argument required.");
318 return false;
319 }
320 guess_surfname = QString(argv[k+1]);
321 }
322 else if (strcmp(argv[k],"--guesssurf") == 0) {
323 found = 2;
324 if (k == *argc - 1) {
325 qCritical ("--guesssurf: argument required.");
326 return false;
327 }
328 guess_surfname = QString(argv[k+1]);
329 }
330 else if (strcmp(argv[k],"--guessrad") == 0) {
331 found = 2;
332 if (k == *argc - 1) {
333 qCritical ("--guessrad: argument required.");
334 return false;
335 }
336 if (sscanf(argv[k+1],"%f",&fval) != 1) {
337 qCritical ("Could not interpret the radius.");
338 return false;
339 }
340 if (fval <= 0.0) {
341 qCritical ("Radius should be positive");
342 return false;
343 }
344 guess_rad = fval/1000.0;
345 }
346 else if (strcmp(argv[k],"--mindist") == 0) {
347 found = 2;
348 if (k == *argc - 1) {
349 qCritical ("--mindist: argument required.");
350 return false;
351 }
352 if (sscanf(argv[k+1],"%f",&fval) != 1) {
353 qCritical ("Could not interpret the distance.");
354 return false;
355 }
356 guess_mindist = fval/1000.0;
357 if (guess_mindist <= 0.0)
358 guess_mindist = 0.0;
359 }
360 else if (strcmp(argv[k],"--exclude") == 0) {
361 found = 2;
362 if (k == *argc - 1) {
363 qCritical ("--exclude: argument required.");
364 return false;
365 }
366 if (sscanf(argv[k+1],"%f",&fval) != 1) {
367 qCritical ("Could not interpret the distance.");
368 return false;
369 }
370 guess_exclude = fval/1000.0;
371 if (guess_exclude <= 0.0)
372 guess_exclude = 0.0;
373 }
374 else if (strcmp(argv[k],"--grid") == 0) {
375 found = 2;
376 if (k == *argc - 1) {
377 qCritical ("--grid: argument required.");
378 return false;
379 }
380 if (sscanf(argv[k+1],"%f",&fval) != 1) {
381 qCritical ("Could not interpret the distance.");
382 return false;
383 }
384 if (fval <= 0.0) {
385 qCritical ("Grid spacing should be positive");
386 return false;
387 }
388 guess_grid = guess_grid/1000.0;
389 }
390 else if (strcmp(argv[k],"--mri") == 0) {
391 found = 2;
392 if (k == *argc - 1) {
393 qCritical ("--mri: argument required.");
394 return false;
395 }
396 mriname = QString(argv[k+1]);
397 }
398 else if (strcmp(argv[k],"--bem") == 0) {
399 found = 2;
400 if (k == *argc - 1) {
401 qCritical ("--bem: argument required.");
402 return false;
403 }
404 bemname = QString(argv[k+1]);
405 }
406 else if (strcmp(argv[k],"--accurate") == 0) {
407 found = 1;
408 accurate = true;
409 }
410 else if (strcmp(argv[k],"--meg") == 0) {
411 found = 1;
412 include_meg = true;
413 }
414 else if (strcmp(argv[k],"--eeg") == 0) {
415 found = 1;
416 include_eeg = true;
417 }
418 else if (strcmp(argv[k],"--origin") == 0) {
419 found = 2;
420 if (k == *argc - 1) {
421 qCritical ("--origin: argument required.");
422 return false;
423 }
424 if (sscanf(argv[k+1],"%f:%f:%f",&r0[0],&r0[1],&r0[2]) != 3) {
425 qCritical ("Could not interpret the origin.");
426 return false;
427 }
428 r0[0] = r0[0]/1000.0f;
429 r0[1] = r0[1]/1000.0f;
430 r0[2] = r0[2]/1000.0f;
431 }
432 else if (strcmp(argv[k],"--eegrad") == 0) {
433 found = 2;
434 if (k == *argc - 1) {
435 qCritical ("--eegrad: argument required.");
436 return false;
437 }
438 if (sscanf(argv[k+1],"%g",&eeg_sphere_rad) != 1) {
439 qCritical () << "Incomprehensible radius:" << argv[k+1];
440 return false;
441 }
442 if (eeg_sphere_rad <= 0) {
443 qCritical ("Radius must be positive");
444 return false;
445 }
447 }
448 else if (strcmp(argv[k],"--eegmodels") == 0) {
449 found = 2;
450 if (k == *argc - 1) {
451 qCritical ("--eegmodels: argument required.");
452 return false;
453 }
454 eeg_model_file = QString(argv[k+1]);
455 }
456 else if (strcmp(argv[k],"--eegmodel") == 0) {
457 found = 2;
458 if (k == *argc - 1) {
459 qCritical ("--eegmodel: argument required.");
460 return false;
461 }
462 eeg_model_name = QString(argv[k+1]);
463 }
464 else if (strcmp(argv[k],"--eegscalp") == 0) {
465 found = 1;
466 scale_eeg_pos = true;
467 }
468 else if (strcmp(argv[k],"--meas") == 0) {
469 found = 2;
470 if (k == *argc - 1) {
471 qCritical ("--meas: argument required.");
472 return false;
473 }
474 measname = QString(argv[k+1]);
475 is_raw = false;
476 }
477 else if (strcmp(argv[k],"--raw") == 0) {
478 found = 2;
479 if (k == *argc - 1) {
480 qCritical ("--raw: argument required.");
481 return false;
482 }
483 measname = QString(argv[k+1]);
484 is_raw = true;
485 }
486 else if (strcmp(argv[k],"--proj") == 0) {
487 found = 2;
488 if (k == *argc - 1) {
489 qCritical ("--proj: argument required.");
490 return false;
491 }
492 projnames.append(QString(argv[k+1]));
493 }
494 else if (strcmp(argv[k],"--noproj") == 0) {
495 found = 1;
496 omit_data_proj = true;
497 }
498 else if (strcmp(argv[k],"--bad") == 0) {
499 found = 2;
500 if (k == *argc - 1) {
501 qCritical ("--bad: argument required.");
502 return false;
503 }
504 badname = QString(argv[k+1]);
505 }
506 else if (strcmp(argv[k],"--noise") == 0) {
507 found = 2;
508 if (k == *argc - 1) {
509 qCritical ("--noise: argument required.");
510 return false;
511 }
512 noisename = QString(argv[k+1]);
513 }
514 else if (strcmp(argv[k],"--gradnoise") == 0) {
515 found = 2;
516 if (k == *argc - 1) {
517 qCritical ("--gradnoise: argument required.");
518 return false;
519 }
520 if (sscanf(argv[k+1],"%g",&fval) != 1) {
521 qCritical() << "Incomprehensible value:" << argv[k+1];
522 return false;
523 }
524 if (fval < 0.0) {
525 qCritical ("Value should be positive");
526 return false;
527 }
528 grad_std = 1e-13*fval;
529 }
530 else if (strcmp(argv[k],"--magnoise") == 0) {
531 found = 2;
532 if (k == *argc - 1) {
533 qCritical ("--magnoise: argument required.");
534 return false;
535 }
536 if (sscanf(argv[k+1],"%g",&fval) != 1) {
537 qCritical() << "Incomprehensible value:" << argv[k+1];
538 return false;
539 }
540 if (fval < 0.0) {
541 qCritical ("Value should be positive");
542 return false;
543 }
544 mag_std = 1e-15*fval;
545 }
546 else if (strcmp(argv[k],"--eegnoise") == 0) {
547 found = 2;
548 if (k == *argc - 1) {
549 qCritical ("--eegnoise: argument required.");
550 return false;
551 }
552 if (sscanf(argv[k+1],"%g",&fval) != 1) {
553 qCritical () << "Incomprehensible value:" << argv[k+1];
554 return false;
555 }
556 if (fval < 0.0) {
557 qCritical ("Value should be positive");
558 return false;
559 }
560 eeg_std = 1e-6*fval;
561 }
562 else if (strcmp(argv[k],"--diagnoise") == 0) {
563 found = 1;
564 diagnoise = true;
565 }
566 else if (strcmp(argv[k],"--eegreg") == 0) {
567 found = 2;
568 if (k == *argc - 1) {
569 qCritical ("--eegreg: argument required.");
570 return false;
571 }
572 if (sscanf(argv[k+1],"%g",&fval) != 1) {
573 qCritical () << "Incomprehensible value:" << argv[k+1];
574 return false;
575 }
576 if (fval < 0 || fval > 1) {
577 qCritical ("Regularization value should be positive and smaller than one.");
578 return false;
579 }
580 eeg_reg = fval;
581 }
582 else if (strcmp(argv[k],"--magreg") == 0) {
583 found = 2;
584 if (k == *argc - 1) {
585 qCritical ("--magreg: argument required.");
586 return false;
587 }
588 if (sscanf(argv[k+1],"%g",&fval) != 1) {
589 qCritical () << "Incomprehensible value:" << argv[k+1];
590 return false;
591 }
592 if (fval < 0 || fval > 1) {
593 qCritical ("Regularization value should be positive and smaller than one.");
594 return false;
595 }
596 mag_reg = fval;
597 }
598 else if (strcmp(argv[k],"--gradreg") == 0) {
599 found = 2;
600 if (k == *argc - 1) {
601 qCritical ("--gradreg: argument required.");
602 return false;
603 }
604 if (sscanf(argv[k+1],"%g",&fval) != 1) {
605 qCritical () << "Incomprehensible value:" << argv[k+1] ;
606 return false;
607 }
608 if (fval < 0 || fval > 1) {
609 qCritical ("Regularization value should be positive and smaller than one.");
610 return false;
611 }
612 grad_reg = fval;
613 }
614 else if (strcmp(argv[k],"--reg") == 0) {
615 found = 2;
616 if (k == *argc - 1) {
617 qCritical ("--reg: argument required.");
618 return false;
619 }
620 if (sscanf(argv[k+1],"%g",&fval) != 1) {
621 qCritical () << "Incomprehensible value:" << argv[k+1];
622 return false;
623 }
624 if (fval < 0 || fval > 1) {
625 qCritical ("Regularization value should be positive and smaller than one.");
626 return false;
627 }
628 grad_reg = fval;
629 mag_reg = fval;
630 eeg_reg = fval;
631 }
632 else if (strcmp(argv[k],"--tstep") == 0) {
633 found = 2;
634 if (k == *argc - 1) {
635 qCritical ("--tstep: argument required.");
636 return false;
637 }
638 if (sscanf(argv[k+1],"%g",&fval) != 1) {
639 qCritical() << "Incomprehensible tstep:" << argv[k+1];
640 return false;
641 }
642 if (fval < 0.0) {
643 qCritical ("Time step should be positive");
644 return false;
645 }
646 tstep = fval/1000.0;
647 }
648 else if (strcmp(argv[k],"--integ") == 0) {
649 found = 2;
650 if (k == *argc - 1) {
651 qCritical ("--integ: argument required.");
652 return false;
653 }
654 if (sscanf(argv[k+1],"%g",&fval) != 1) {
655 qCritical() << "Incomprehensible integration time:" << argv[k+1];
656 return false;
657 }
658 if (fval <= 0.0) {
659 qCritical ("Integration time should be positive.");
660 return false;
661 }
662 integ = fval/1000.0f;
663 }
664 else if (strcmp(argv[k],"--tmin") == 0) {
665 found = 2;
666 if (k == *argc - 1) {
667 qCritical ("--tmin: argument required.");
668 return false;
669 }
670 if (sscanf(argv[k+1],"%g",&fval) != 1) {
671 qCritical() << "Incomprehensible tmin:" << argv[k+1];
672 return false;
673 }
674 tmin = fval/1000.0f;
675 }
676 else if (strcmp(argv[k],"--tmax") == 0) {
677 found = 2;
678 if (k == *argc - 1) {
679 qCritical ("--tmax: argument required.");
680 return false;
681 }
682 if (sscanf(argv[k+1],"%g",&fval) != 1) {
683 qCritical() << "Incomprehensible tmax:" << argv[k+1];
684 return false;
685 }
686 tmax = fval/1000.0;
687 }
688 else if (strcmp(argv[k],"--bmin") == 0) {
689 found = 2;
690 if (k == *argc - 1) {
691 qCritical ("--bmin: argument required.");
692 return false;
693 }
694 if (sscanf(argv[k+1],"%g",&fval) != 1) {
695 qCritical() << "Incomprehensible bmin:" << argv[k+1];
696 return false;
697 }
698 bmin = fval/1000.0f;
699 }
700 else if (strcmp(argv[k],"--bmax") == 0) {
701 found = 2;
702 if (k == *argc - 1) {
703 qCritical ("--bmax: argument required.");
704 return false;
705 }
706 if (sscanf(argv[k+1],"%g",&fval) != 1) {
707 qCritical() << "Incomprehensible bmax:" << argv[k+1];
708 return false;
709 }
710 bmax = fval/1000.0f;
711 }
712 else if (strcmp(argv[k],"--set") == 0) {
713 found = 2;
714 if (k == *argc - 1) {
715 qCritical ("--set: argument required.");
716 return false;
717 }
718 if (sscanf(argv[k+1],"%d",&setno) != 1) {
719 qCritical() << "Incomprehensible data set number:" << argv[k+1];
720 return false;
721 }
722 if (setno <= 0) {
723 qCritical ("Data set number must be > 0");
724 return false;
725 }
726 }
727 else if (strcmp(argv[k],"--filteroff") == 0) {
728 found = 1;
729 filter.filter_on = false;
730 }
731 else if (strcmp(argv[k],"--lowpass") == 0) {
732 found = 2;
733 if (k == *argc - 1) {
734 qCritical ("--lowpass: argument required.");
735 return false;
736 }
737 if (sscanf(argv[k+1],"%g",&fval) != 1) {
738 qCritical() << "Illegal number:" << argv[k+1];
739 return false;
740 }
741 if (fval <= 0) {
742 qCritical ("Lowpass corner must be positive");
743 return false;
744 }
745 filter.lowpass = fval;
746 }
747 else if (strcmp(argv[k],"--lowpassw") == 0) {
748 found = 2;
749 if (k == *argc - 1) {
750 qCritical ("--lowpassw: argument required.");
751 return false;
752 }
753 if (sscanf(argv[k+1],"%g",&fval) != 1) {
754 qCritical() << "Illegal number:" << argv[k+1];
755 return false;
756 }
757 if (fval <= 0) {
758 qCritical ("Lowpass width must be positive");
759 return false;
760 }
761 filter.lowpass_width = fval;
762 }
763 else if (strcmp(argv[k],"--highpass") == 0) {
764 found = 2;
765 if (k == *argc - 1) {
766 qCritical ("--highpass: argument required.");
767 return false;
768 }
769 if (sscanf(argv[k+1],"%g",&fval) != 1) {
770 qCritical() << "Illegal number:" << argv[k+1];
771 return false;
772 }
773 if (fval <= 0) {
774 qCritical ("Highpass corner must be positive");
775 return false;
776 }
777 filter.highpass = fval;
778 }
779 else if (strcmp(argv[k],"--filtersize") == 0) {
780 found = 2;
781 if (k == *argc - 1) {
782 qCritical ("--filtersize: argument required.");
783 return false;
784 }
785 if (sscanf(argv[k+1],"%d",&ival) != 1) {
786 qCritical() << "Illegal number:" << argv[k+1];
787 return false;
788 }
789 if (ival < 1024) {
790 qCritical ("Filtersize should be at least 1024.");
791 return false;
792 }
793 for (filter_size = 1024; filter_size < ival; filter_size = 2*filter_size)
794 ;
795 filter.size = filter_size;
796 filter.taper_size = filter_size/2;
797 }
798 else if (strcmp(argv[k],"--magdip") == 0) {
799 found = 1;
800 fit_mag_dipoles = true;
801 }
802 else if (strcmp(argv[k],"--dip") == 0) {
803 found = 2;
804 if (k == *argc - 1) {
805 qCritical ("--dip: argument required.");
806 return false;
807 }
808 dipname = QString(argv[k+1]);
809 }
810 else if (strcmp(argv[k],"--bdip") == 0) {
811 found = 2;
812 if (k == *argc - 1) {
813 qCritical ("--bdip: argument required.");
814 return false;
815 }
816 bdipname = QString(argv[k+1]);
817 }
818 else if (strcmp(argv[k],"--verbose") == 0) {
819 found = 1;
820 verbose = true;
821 }
822 if (found) {
823 for (int p = k; p < *argc-found; p++)
824 argv[p] = argv[p+found];
825 *argc = *argc - found;
826 k = k - found;
827 }
828 }
829 return check_unrecognized_args(*argc,argv);
830}
Command-line and programmatic settings struct for the mne_dipole_fit driver.
Inverse source estimation (MNE, dSPM, sLORETA, dipole fitting).
constexpr double BIG_TIME