66 if (!check_args(argc,argv))
80void InvDipoleFitSettings::initMembers()
83 r0 << 0.0f,0.0f,0.04f;
142 qCritical (
"Data file name missing. Please specify one using the --meas option.");
146 qCritical (
"Output file name missing. Please use the --dip or --bdip options to do this.");
151 qCritical (
"Please specify the MRI/head coordinate transformation with the --mri option");
156 qCritical (
"Specify one or both of the --eeg and --meg options");
163 qInfo(
"BEM : %s",
bemname.toUtf8().data());
165 qInfo(
"Sphere model : origin at (% 7.2f % 7.2f % 7.2f) mm",
166 1000*
r0[0],1000*
r0[1],1000*
r0[2]);
168 qInfo(
"Using %s MEG coil definitions.",
accurate ?
"accurate" :
"standard");
170 qInfo(
"MRI transform : %s",
mriname.toUtf8().data());
172 qInfo(
"Guesses : %s",
guessname.toUtf8().data());
175 qInfo(
"Guess space bounded by %s",
guess_surfname.toUtf8().data());
177 qInfo(
"Spherical guess space, rad = %.1f mm",1000*
guess_rad);
178 qInfo(
"Guess grid : %6.1f mm",1000*
guess_grid);
184 qInfo(
"Data : %s",
measname.toUtf8().data());
186 qInfo(
"SSP sources :");
187 for (
int k = 0; k <
projnames.size(); k++)
188 qInfo(
"\t%s",
projnames[k].toUtf8().data());
191 qInfo(
"Bad channels : %s",
badname.toUtf8().data());
193 qInfo(
"Baseline : %10.2f ... %10.2f ms", 1000*
bmin,1000*
bmax);
195 qInfo(
"Noise covariance : %s",
noisename.toUtf8().data());
198 qInfo(
"\tNoise-covariance regularization (mag) : %-5.2f",
mag_reg);
200 qInfo(
"\tNoise-covariance regularization (grad) : %-5.2f",
grad_reg);
203 qInfo(
"\tNoise-covariance regularization (EEG) : %-5.2f",
eeg_reg);
206 qInfo(
"Fit data with magnetic dipoles");
208 qInfo(
"dip output : %s",
dipname.toUtf8().data());
210 qInfo(
"bdip output : %s",
bdipname.toUtf8().data());
215void InvDipoleFitSettings::usage(
const char *name)
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");
224 qInfo(
"\nModality selection:\n");
225 qInfo(
"\t--meg employ MEG data in fitting");
226 qInfo(
"\t--eeg employ EEG data in fitting");
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)");
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");
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);
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");
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.");
290bool InvDipoleFitSettings::check_unrecognized_args(
int argc,
char **argv)
294 for (
int k = 1; k < argc; k++)
295 args += QString(argv[k]) +
" ";
296 qCritical(
"Unrecognized arguments : %s", args.trimmed().toUtf8().data());
304bool InvDipoleFitSettings::check_args (
int *argc,
char **argv)
308 int ival,filter_size;
310 for (
int k = 0; k < *argc; k++) {
312 if (strcmp(argv[k],
"--gui") == 0) {
316 else if (strcmp(argv[k],
"--version") == 0) {
317 qInfo(
"%s compiled at %s %s",
318 argv[0],__DATE__,__TIME__);
321 else if (strcmp(argv[k],
"--help") == 0) {
325 else if (strcmp(argv[k],
"--guess") == 0) {
327 if (k == *argc - 1) {
328 qCritical (
"--guess: argument required.");
333 else if (strcmp(argv[k],
"--gsurf") == 0) {
335 if (k == *argc - 1) {
336 qCritical (
"--gsurf: argument required.");
341 else if (strcmp(argv[k],
"--guesssurf") == 0) {
343 if (k == *argc - 1) {
344 qCritical (
"--guesssurf: argument required.");
349 else if (strcmp(argv[k],
"--guessrad") == 0) {
351 if (k == *argc - 1) {
352 qCritical (
"--guessrad: argument required.");
355 if (sscanf(argv[k+1],
"%f",&fval) != 1) {
356 qCritical (
"Could not interpret the radius.");
360 qCritical (
"Radius should be positive");
365 else if (strcmp(argv[k],
"--mindist") == 0) {
367 if (k == *argc - 1) {
368 qCritical (
"--mindist: argument required.");
371 if (sscanf(argv[k+1],
"%f",&fval) != 1) {
372 qCritical (
"Could not interpret the distance.");
379 else if (strcmp(argv[k],
"--exclude") == 0) {
381 if (k == *argc - 1) {
382 qCritical (
"--exclude: argument required.");
385 if (sscanf(argv[k+1],
"%f",&fval) != 1) {
386 qCritical (
"Could not interpret the distance.");
393 else if (strcmp(argv[k],
"--grid") == 0) {
395 if (k == *argc - 1) {
396 qCritical (
"--grid: argument required.");
399 if (sscanf(argv[k+1],
"%f",&fval) != 1) {
400 qCritical (
"Could not interpret the distance.");
404 qCritical (
"Grid spacing should be positive");
409 else if (strcmp(argv[k],
"--mri") == 0) {
411 if (k == *argc - 1) {
412 qCritical (
"--mri: argument required.");
417 else if (strcmp(argv[k],
"--bem") == 0) {
419 if (k == *argc - 1) {
420 qCritical (
"--bem: argument required.");
425 else if (strcmp(argv[k],
"--accurate") == 0) {
429 else if (strcmp(argv[k],
"--meg") == 0) {
433 else if (strcmp(argv[k],
"--eeg") == 0) {
437 else if (strcmp(argv[k],
"--origin") == 0) {
439 if (k == *argc - 1) {
440 qCritical (
"--origin: argument required.");
443 if (sscanf(argv[k+1],
"%f:%f:%f",&
r0[0],&
r0[1],&
r0[2]) != 3) {
444 qCritical (
"Could not interpret the origin.");
447 r0[0] =
r0[0]/1000.0f;
448 r0[1] =
r0[1]/1000.0f;
449 r0[2] =
r0[2]/1000.0f;
451 else if (strcmp(argv[k],
"--eegrad") == 0) {
453 if (k == *argc - 1) {
454 qCritical (
"--eegrad: argument required.");
458 qCritical () <<
"Incomprehensible radius:" << argv[k+1];
462 qCritical (
"Radius must be positive");
467 else if (strcmp(argv[k],
"--eegmodels") == 0) {
469 if (k == *argc - 1) {
470 qCritical (
"--eegmodels: argument required.");
475 else if (strcmp(argv[k],
"--eegmodel") == 0) {
477 if (k == *argc - 1) {
478 qCritical (
"--eegmodel: argument required.");
483 else if (strcmp(argv[k],
"--eegscalp") == 0) {
487 else if (strcmp(argv[k],
"--meas") == 0) {
489 if (k == *argc - 1) {
490 qCritical (
"--meas: argument required.");
496 else if (strcmp(argv[k],
"--raw") == 0) {
498 if (k == *argc - 1) {
499 qCritical (
"--raw: argument required.");
505 else if (strcmp(argv[k],
"--proj") == 0) {
507 if (k == *argc - 1) {
508 qCritical (
"--proj: argument required.");
513 else if (strcmp(argv[k],
"--noproj") == 0) {
517 else if (strcmp(argv[k],
"--bad") == 0) {
519 if (k == *argc - 1) {
520 qCritical (
"--bad: argument required.");
525 else if (strcmp(argv[k],
"--noise") == 0) {
527 if (k == *argc - 1) {
528 qCritical (
"--noise: argument required.");
533 else if (strcmp(argv[k],
"--gradnoise") == 0) {
535 if (k == *argc - 1) {
536 qCritical (
"--gradnoise: argument required.");
539 if (sscanf(argv[k+1],
"%g",&fval) != 1) {
540 qCritical() <<
"Incomprehensible value:" << argv[k+1];
544 qCritical (
"Value should be positive");
549 else if (strcmp(argv[k],
"--magnoise") == 0) {
551 if (k == *argc - 1) {
552 qCritical (
"--magnoise: argument required.");
555 if (sscanf(argv[k+1],
"%g",&fval) != 1) {
556 qCritical() <<
"Incomprehensible value:" << argv[k+1];
560 qCritical (
"Value should be positive");
565 else if (strcmp(argv[k],
"--eegnoise") == 0) {
567 if (k == *argc - 1) {
568 qCritical (
"--eegnoise: argument required.");
571 if (sscanf(argv[k+1],
"%g",&fval) != 1) {
572 qCritical () <<
"Incomprehensible value:" << argv[k+1];
576 qCritical (
"Value should be positive");
581 else if (strcmp(argv[k],
"--diagnoise") == 0) {
585 else if (strcmp(argv[k],
"--eegreg") == 0) {
587 if (k == *argc - 1) {
588 qCritical (
"--eegreg: argument required.");
591 if (sscanf(argv[k+1],
"%g",&fval) != 1) {
592 qCritical () <<
"Incomprehensible value:" << argv[k+1];
595 if (fval < 0 || fval > 1) {
596 qCritical (
"Regularization value should be positive and smaller than one.");
601 else if (strcmp(argv[k],
"--magreg") == 0) {
603 if (k == *argc - 1) {
604 qCritical (
"--magreg: argument required.");
607 if (sscanf(argv[k+1],
"%g",&fval) != 1) {
608 qCritical () <<
"Incomprehensible value:" << argv[k+1];
611 if (fval < 0 || fval > 1) {
612 qCritical (
"Regularization value should be positive and smaller than one.");
617 else if (strcmp(argv[k],
"--gradreg") == 0) {
619 if (k == *argc - 1) {
620 qCritical (
"--gradreg: argument required.");
623 if (sscanf(argv[k+1],
"%g",&fval) != 1) {
624 qCritical () <<
"Incomprehensible value:" << argv[k+1] ;
627 if (fval < 0 || fval > 1) {
628 qCritical (
"Regularization value should be positive and smaller than one.");
633 else if (strcmp(argv[k],
"--reg") == 0) {
635 if (k == *argc - 1) {
636 qCritical (
"--reg: argument required.");
639 if (sscanf(argv[k+1],
"%g",&fval) != 1) {
640 qCritical () <<
"Incomprehensible value:" << argv[k+1];
643 if (fval < 0 || fval > 1) {
644 qCritical (
"Regularization value should be positive and smaller than one.");
651 else if (strcmp(argv[k],
"--tstep") == 0) {
653 if (k == *argc - 1) {
654 qCritical (
"--tstep: argument required.");
657 if (sscanf(argv[k+1],
"%g",&fval) != 1) {
658 qCritical() <<
"Incomprehensible tstep:" << argv[k+1];
662 qCritical (
"Time step should be positive");
667 else if (strcmp(argv[k],
"--integ") == 0) {
669 if (k == *argc - 1) {
670 qCritical (
"--integ: argument required.");
673 if (sscanf(argv[k+1],
"%g",&fval) != 1) {
674 qCritical() <<
"Incomprehensible integration time:" << argv[k+1];
678 qCritical (
"Integration time should be positive.");
681 integ = fval/1000.0f;
683 else if (strcmp(argv[k],
"--tmin") == 0) {
685 if (k == *argc - 1) {
686 qCritical (
"--tmin: argument required.");
689 if (sscanf(argv[k+1],
"%g",&fval) != 1) {
690 qCritical() <<
"Incomprehensible tmin:" << argv[k+1];
695 else if (strcmp(argv[k],
"--tmax") == 0) {
697 if (k == *argc - 1) {
698 qCritical (
"--tmax: argument required.");
701 if (sscanf(argv[k+1],
"%g",&fval) != 1) {
702 qCritical() <<
"Incomprehensible tmax:" << argv[k+1];
707 else if (strcmp(argv[k],
"--bmin") == 0) {
709 if (k == *argc - 1) {
710 qCritical (
"--bmin: argument required.");
713 if (sscanf(argv[k+1],
"%g",&fval) != 1) {
714 qCritical() <<
"Incomprehensible bmin:" << argv[k+1];
719 else if (strcmp(argv[k],
"--bmax") == 0) {
721 if (k == *argc - 1) {
722 qCritical (
"--bmax: argument required.");
725 if (sscanf(argv[k+1],
"%g",&fval) != 1) {
726 qCritical() <<
"Incomprehensible bmax:" << argv[k+1];
731 else if (strcmp(argv[k],
"--set") == 0) {
733 if (k == *argc - 1) {
734 qCritical (
"--set: argument required.");
737 if (sscanf(argv[k+1],
"%d",&
setno) != 1) {
738 qCritical() <<
"Incomprehensible data set number:" << argv[k+1];
742 qCritical (
"Data set number must be > 0");
746 else if (strcmp(argv[k],
"--filteroff") == 0) {
750 else if (strcmp(argv[k],
"--lowpass") == 0) {
752 if (k == *argc - 1) {
753 qCritical (
"--lowpass: argument required.");
756 if (sscanf(argv[k+1],
"%g",&fval) != 1) {
757 qCritical() <<
"Illegal number:" << argv[k+1];
761 qCritical (
"Lowpass corner must be positive");
766 else if (strcmp(argv[k],
"--lowpassw") == 0) {
768 if (k == *argc - 1) {
769 qCritical (
"--lowpassw: argument required.");
772 if (sscanf(argv[k+1],
"%g",&fval) != 1) {
773 qCritical() <<
"Illegal number:" << argv[k+1];
777 qCritical (
"Lowpass width must be positive");
780 filter.lowpass_width = fval;
782 else if (strcmp(argv[k],
"--highpass") == 0) {
784 if (k == *argc - 1) {
785 qCritical (
"--highpass: argument required.");
788 if (sscanf(argv[k+1],
"%g",&fval) != 1) {
789 qCritical() <<
"Illegal number:" << argv[k+1];
793 qCritical (
"Highpass corner must be positive");
798 else if (strcmp(argv[k],
"--filtersize") == 0) {
800 if (k == *argc - 1) {
801 qCritical (
"--filtersize: argument required.");
804 if (sscanf(argv[k+1],
"%d",&ival) != 1) {
805 qCritical() <<
"Illegal number:" << argv[k+1];
809 qCritical (
"Filtersize should be at least 1024.");
812 for (filter_size = 1024; filter_size < ival; filter_size = 2*filter_size)
814 filter.size = filter_size;
815 filter.taper_size = filter_size/2;
817 else if (strcmp(argv[k],
"--magdip") == 0) {
821 else if (strcmp(argv[k],
"--dip") == 0) {
823 if (k == *argc - 1) {
824 qCritical (
"--dip: argument required.");
829 else if (strcmp(argv[k],
"--bdip") == 0) {
831 if (k == *argc - 1) {
832 qCritical (
"--bdip: argument required.");
837 else if (strcmp(argv[k],
"--verbose") == 0) {
842 for (
int p = k; p < *argc-found; p++)
843 argv[p] = argv[p+found];
844 *argc = *argc - found;
848 return check_unrecognized_args(*argc,argv);
Dipole Fit Setting class declaration.
Inverse source estimation (MNE, dSPM, sLORETA, dipole fitting).
constexpr double BIG_TIME
MNELIB::MNEFilterDef filter
virtual ~InvDipoleFitSettings()