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