47 if (!check_args(argc,argv))
61void InvDipoleFitSettings::initMembers()
64 r0 << 0.0f,0.0f,0.04f;
123 qCritical (
"Data file name missing. Please specify one using the --meas option.");
127 qCritical (
"Output file name missing. Please use the --dip or --bdip options to do this.");
132 qCritical (
"Please specify the MRI/head coordinate transformation with the --mri option");
137 qCritical (
"Specify one or both of the --eeg and --meg options");
144 qInfo(
"BEM : %s",
bemname.toUtf8().data());
146 qInfo(
"Sphere model : origin at (% 7.2f % 7.2f % 7.2f) mm",
147 1000*
r0[0],1000*
r0[1],1000*
r0[2]);
149 qInfo(
"Using %s MEG coil definitions.",
accurate ?
"accurate" :
"standard");
151 qInfo(
"MRI transform : %s",
mriname.toUtf8().data());
153 qInfo(
"Guesses : %s",
guessname.toUtf8().data());
156 qInfo(
"Guess space bounded by %s",
guess_surfname.toUtf8().data());
158 qInfo(
"Spherical guess space, rad = %.1f mm",1000*
guess_rad);
159 qInfo(
"Guess grid : %6.1f mm",1000*
guess_grid);
165 qInfo(
"Data : %s",
measname.toUtf8().data());
167 qInfo(
"SSP sources :");
168 for (
int k = 0; k <
projnames.size(); k++)
169 qInfo(
"\t%s",
projnames[k].toUtf8().data());
172 qInfo(
"Bad channels : %s",
badname.toUtf8().data());
174 qInfo(
"Baseline : %10.2f ... %10.2f ms", 1000*
bmin,1000*
bmax);
176 qInfo(
"Noise covariance : %s",
noisename.toUtf8().data());
179 qInfo(
"\tNoise-covariance regularization (mag) : %-5.2f",
mag_reg);
181 qInfo(
"\tNoise-covariance regularization (grad) : %-5.2f",
grad_reg);
184 qInfo(
"\tNoise-covariance regularization (EEG) : %-5.2f",
eeg_reg);
187 qInfo(
"Fit data with magnetic dipoles");
189 qInfo(
"dip output : %s",
dipname.toUtf8().data());
191 qInfo(
"bdip output : %s",
bdipname.toUtf8().data());
196void InvDipoleFitSettings::usage(
const char *name)
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");
205 qInfo(
"\nModality selection:\n");
206 qInfo(
"\t--meg employ MEG data in fitting");
207 qInfo(
"\t--eeg employ EEG data in fitting");
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)");
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");
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);
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");
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.");
271bool InvDipoleFitSettings::check_unrecognized_args(
int argc,
char **argv)
275 for (
int k = 1; k < argc; k++)
276 args += QString(argv[k]) +
" ";
277 qCritical(
"Unrecognized arguments : %s", args.trimmed().toUtf8().data());
285bool InvDipoleFitSettings::check_args (
int *argc,
char **argv)
289 int ival,filter_size;
291 for (
int k = 0; k < *argc; k++) {
293 if (strcmp(argv[k],
"--gui") == 0) {
297 else if (strcmp(argv[k],
"--version") == 0) {
298 qInfo(
"%s compiled at %s %s",
299 argv[0],__DATE__,__TIME__);
302 else if (strcmp(argv[k],
"--help") == 0) {
306 else if (strcmp(argv[k],
"--guess") == 0) {
308 if (k == *argc - 1) {
309 qCritical (
"--guess: argument required.");
314 else if (strcmp(argv[k],
"--gsurf") == 0) {
316 if (k == *argc - 1) {
317 qCritical (
"--gsurf: argument required.");
322 else if (strcmp(argv[k],
"--guesssurf") == 0) {
324 if (k == *argc - 1) {
325 qCritical (
"--guesssurf: argument required.");
330 else if (strcmp(argv[k],
"--guessrad") == 0) {
332 if (k == *argc - 1) {
333 qCritical (
"--guessrad: argument required.");
336 if (sscanf(argv[k+1],
"%f",&fval) != 1) {
337 qCritical (
"Could not interpret the radius.");
341 qCritical (
"Radius should be positive");
346 else if (strcmp(argv[k],
"--mindist") == 0) {
348 if (k == *argc - 1) {
349 qCritical (
"--mindist: argument required.");
352 if (sscanf(argv[k+1],
"%f",&fval) != 1) {
353 qCritical (
"Could not interpret the distance.");
360 else if (strcmp(argv[k],
"--exclude") == 0) {
362 if (k == *argc - 1) {
363 qCritical (
"--exclude: argument required.");
366 if (sscanf(argv[k+1],
"%f",&fval) != 1) {
367 qCritical (
"Could not interpret the distance.");
374 else if (strcmp(argv[k],
"--grid") == 0) {
376 if (k == *argc - 1) {
377 qCritical (
"--grid: argument required.");
380 if (sscanf(argv[k+1],
"%f",&fval) != 1) {
381 qCritical (
"Could not interpret the distance.");
385 qCritical (
"Grid spacing should be positive");
390 else if (strcmp(argv[k],
"--mri") == 0) {
392 if (k == *argc - 1) {
393 qCritical (
"--mri: argument required.");
398 else if (strcmp(argv[k],
"--bem") == 0) {
400 if (k == *argc - 1) {
401 qCritical (
"--bem: argument required.");
406 else if (strcmp(argv[k],
"--accurate") == 0) {
410 else if (strcmp(argv[k],
"--meg") == 0) {
414 else if (strcmp(argv[k],
"--eeg") == 0) {
418 else if (strcmp(argv[k],
"--origin") == 0) {
420 if (k == *argc - 1) {
421 qCritical (
"--origin: argument required.");
424 if (sscanf(argv[k+1],
"%f:%f:%f",&
r0[0],&
r0[1],&
r0[2]) != 3) {
425 qCritical (
"Could not interpret the origin.");
428 r0[0] =
r0[0]/1000.0f;
429 r0[1] =
r0[1]/1000.0f;
430 r0[2] =
r0[2]/1000.0f;
432 else if (strcmp(argv[k],
"--eegrad") == 0) {
434 if (k == *argc - 1) {
435 qCritical (
"--eegrad: argument required.");
439 qCritical () <<
"Incomprehensible radius:" << argv[k+1];
443 qCritical (
"Radius must be positive");
448 else if (strcmp(argv[k],
"--eegmodels") == 0) {
450 if (k == *argc - 1) {
451 qCritical (
"--eegmodels: argument required.");
456 else if (strcmp(argv[k],
"--eegmodel") == 0) {
458 if (k == *argc - 1) {
459 qCritical (
"--eegmodel: argument required.");
464 else if (strcmp(argv[k],
"--eegscalp") == 0) {
468 else if (strcmp(argv[k],
"--meas") == 0) {
470 if (k == *argc - 1) {
471 qCritical (
"--meas: argument required.");
477 else if (strcmp(argv[k],
"--raw") == 0) {
479 if (k == *argc - 1) {
480 qCritical (
"--raw: argument required.");
486 else if (strcmp(argv[k],
"--proj") == 0) {
488 if (k == *argc - 1) {
489 qCritical (
"--proj: argument required.");
494 else if (strcmp(argv[k],
"--noproj") == 0) {
498 else if (strcmp(argv[k],
"--bad") == 0) {
500 if (k == *argc - 1) {
501 qCritical (
"--bad: argument required.");
506 else if (strcmp(argv[k],
"--noise") == 0) {
508 if (k == *argc - 1) {
509 qCritical (
"--noise: argument required.");
514 else if (strcmp(argv[k],
"--gradnoise") == 0) {
516 if (k == *argc - 1) {
517 qCritical (
"--gradnoise: argument required.");
520 if (sscanf(argv[k+1],
"%g",&fval) != 1) {
521 qCritical() <<
"Incomprehensible value:" << argv[k+1];
525 qCritical (
"Value should be positive");
530 else if (strcmp(argv[k],
"--magnoise") == 0) {
532 if (k == *argc - 1) {
533 qCritical (
"--magnoise: argument required.");
536 if (sscanf(argv[k+1],
"%g",&fval) != 1) {
537 qCritical() <<
"Incomprehensible value:" << argv[k+1];
541 qCritical (
"Value should be positive");
546 else if (strcmp(argv[k],
"--eegnoise") == 0) {
548 if (k == *argc - 1) {
549 qCritical (
"--eegnoise: argument required.");
552 if (sscanf(argv[k+1],
"%g",&fval) != 1) {
553 qCritical () <<
"Incomprehensible value:" << argv[k+1];
557 qCritical (
"Value should be positive");
562 else if (strcmp(argv[k],
"--diagnoise") == 0) {
566 else if (strcmp(argv[k],
"--eegreg") == 0) {
568 if (k == *argc - 1) {
569 qCritical (
"--eegreg: argument required.");
572 if (sscanf(argv[k+1],
"%g",&fval) != 1) {
573 qCritical () <<
"Incomprehensible value:" << argv[k+1];
576 if (fval < 0 || fval > 1) {
577 qCritical (
"Regularization value should be positive and smaller than one.");
582 else if (strcmp(argv[k],
"--magreg") == 0) {
584 if (k == *argc - 1) {
585 qCritical (
"--magreg: argument required.");
588 if (sscanf(argv[k+1],
"%g",&fval) != 1) {
589 qCritical () <<
"Incomprehensible value:" << argv[k+1];
592 if (fval < 0 || fval > 1) {
593 qCritical (
"Regularization value should be positive and smaller than one.");
598 else if (strcmp(argv[k],
"--gradreg") == 0) {
600 if (k == *argc - 1) {
601 qCritical (
"--gradreg: argument required.");
604 if (sscanf(argv[k+1],
"%g",&fval) != 1) {
605 qCritical () <<
"Incomprehensible value:" << argv[k+1] ;
608 if (fval < 0 || fval > 1) {
609 qCritical (
"Regularization value should be positive and smaller than one.");
614 else if (strcmp(argv[k],
"--reg") == 0) {
616 if (k == *argc - 1) {
617 qCritical (
"--reg: argument required.");
620 if (sscanf(argv[k+1],
"%g",&fval) != 1) {
621 qCritical () <<
"Incomprehensible value:" << argv[k+1];
624 if (fval < 0 || fval > 1) {
625 qCritical (
"Regularization value should be positive and smaller than one.");
632 else if (strcmp(argv[k],
"--tstep") == 0) {
634 if (k == *argc - 1) {
635 qCritical (
"--tstep: argument required.");
638 if (sscanf(argv[k+1],
"%g",&fval) != 1) {
639 qCritical() <<
"Incomprehensible tstep:" << argv[k+1];
643 qCritical (
"Time step should be positive");
648 else if (strcmp(argv[k],
"--integ") == 0) {
650 if (k == *argc - 1) {
651 qCritical (
"--integ: argument required.");
654 if (sscanf(argv[k+1],
"%g",&fval) != 1) {
655 qCritical() <<
"Incomprehensible integration time:" << argv[k+1];
659 qCritical (
"Integration time should be positive.");
662 integ = fval/1000.0f;
664 else if (strcmp(argv[k],
"--tmin") == 0) {
666 if (k == *argc - 1) {
667 qCritical (
"--tmin: argument required.");
670 if (sscanf(argv[k+1],
"%g",&fval) != 1) {
671 qCritical() <<
"Incomprehensible tmin:" << argv[k+1];
676 else if (strcmp(argv[k],
"--tmax") == 0) {
678 if (k == *argc - 1) {
679 qCritical (
"--tmax: argument required.");
682 if (sscanf(argv[k+1],
"%g",&fval) != 1) {
683 qCritical() <<
"Incomprehensible tmax:" << argv[k+1];
688 else if (strcmp(argv[k],
"--bmin") == 0) {
690 if (k == *argc - 1) {
691 qCritical (
"--bmin: argument required.");
694 if (sscanf(argv[k+1],
"%g",&fval) != 1) {
695 qCritical() <<
"Incomprehensible bmin:" << argv[k+1];
700 else if (strcmp(argv[k],
"--bmax") == 0) {
702 if (k == *argc - 1) {
703 qCritical (
"--bmax: argument required.");
706 if (sscanf(argv[k+1],
"%g",&fval) != 1) {
707 qCritical() <<
"Incomprehensible bmax:" << argv[k+1];
712 else if (strcmp(argv[k],
"--set") == 0) {
714 if (k == *argc - 1) {
715 qCritical (
"--set: argument required.");
718 if (sscanf(argv[k+1],
"%d",&
setno) != 1) {
719 qCritical() <<
"Incomprehensible data set number:" << argv[k+1];
723 qCritical (
"Data set number must be > 0");
727 else if (strcmp(argv[k],
"--filteroff") == 0) {
731 else if (strcmp(argv[k],
"--lowpass") == 0) {
733 if (k == *argc - 1) {
734 qCritical (
"--lowpass: argument required.");
737 if (sscanf(argv[k+1],
"%g",&fval) != 1) {
738 qCritical() <<
"Illegal number:" << argv[k+1];
742 qCritical (
"Lowpass corner must be positive");
747 else if (strcmp(argv[k],
"--lowpassw") == 0) {
749 if (k == *argc - 1) {
750 qCritical (
"--lowpassw: argument required.");
753 if (sscanf(argv[k+1],
"%g",&fval) != 1) {
754 qCritical() <<
"Illegal number:" << argv[k+1];
758 qCritical (
"Lowpass width must be positive");
761 filter.lowpass_width = fval;
763 else if (strcmp(argv[k],
"--highpass") == 0) {
765 if (k == *argc - 1) {
766 qCritical (
"--highpass: argument required.");
769 if (sscanf(argv[k+1],
"%g",&fval) != 1) {
770 qCritical() <<
"Illegal number:" << argv[k+1];
774 qCritical (
"Highpass corner must be positive");
779 else if (strcmp(argv[k],
"--filtersize") == 0) {
781 if (k == *argc - 1) {
782 qCritical (
"--filtersize: argument required.");
785 if (sscanf(argv[k+1],
"%d",&ival) != 1) {
786 qCritical() <<
"Illegal number:" << argv[k+1];
790 qCritical (
"Filtersize should be at least 1024.");
793 for (filter_size = 1024; filter_size < ival; filter_size = 2*filter_size)
795 filter.size = filter_size;
796 filter.taper_size = filter_size/2;
798 else if (strcmp(argv[k],
"--magdip") == 0) {
802 else if (strcmp(argv[k],
"--dip") == 0) {
804 if (k == *argc - 1) {
805 qCritical (
"--dip: argument required.");
810 else if (strcmp(argv[k],
"--bdip") == 0) {
812 if (k == *argc - 1) {
813 qCritical (
"--bdip: argument required.");
818 else if (strcmp(argv[k],
"--verbose") == 0) {
823 for (
int p = k; p < *argc-found; p++)
824 argv[p] = argv[p+found];
825 *argc = *argc - found;
829 return check_unrecognized_args(*argc,argv);
Command-line and programmatic settings struct for the mne_dipole_fit driver.
Inverse source estimation (MNE, dSPM, sLORETA, dipole fitting).
constexpr double BIG_TIME
MNELIB::MNEFilterDef filter
virtual ~InvDipoleFitSettings()