23 if (!check_args(argc,argv))
37void InvDipoleFitSettings::initMembers()
40 r0 << 0.0f,0.0f,0.04f;
99 qCritical (
"Data file name missing. Please specify one using the --meas option.");
103 qCritical (
"Output file name missing. Please use the --dip or --bdip options to do this.");
108 qCritical (
"Please specify the MRI/head coordinate transformation with the --mri option");
113 qCritical (
"Specify one or both of the --eeg and --meg options");
120 qInfo(
"BEM : %s",
bemname.toUtf8().data());
122 qInfo(
"Sphere model : origin at (% 7.2f % 7.2f % 7.2f) mm",
123 1000*
r0[0],1000*
r0[1],1000*
r0[2]);
125 qInfo(
"Using %s MEG coil definitions.",
accurate ?
"accurate" :
"standard");
127 qInfo(
"MRI transform : %s",
mriname.toUtf8().data());
129 qInfo(
"Guesses : %s",
guessname.toUtf8().data());
132 qInfo(
"Guess space bounded by %s",
guess_surfname.toUtf8().data());
134 qInfo(
"Spherical guess space, rad = %.1f mm",1000*
guess_rad);
135 qInfo(
"Guess grid : %6.1f mm",1000*
guess_grid);
141 qInfo(
"Data : %s",
measname.toUtf8().data());
143 qInfo(
"SSP sources :");
144 for (
int k = 0; k <
projnames.size(); k++)
145 qInfo(
"\t%s",
projnames[k].toUtf8().data());
148 qInfo(
"Bad channels : %s",
badname.toUtf8().data());
150 qInfo(
"Baseline : %10.2f ... %10.2f ms", 1000*
bmin,1000*
bmax);
152 qInfo(
"Noise covariance : %s",
noisename.toUtf8().data());
155 qInfo(
"\tNoise-covariance regularization (mag) : %-5.2f",
mag_reg);
157 qInfo(
"\tNoise-covariance regularization (grad) : %-5.2f",
grad_reg);
160 qInfo(
"\tNoise-covariance regularization (EEG) : %-5.2f",
eeg_reg);
163 qInfo(
"Fit data with magnetic dipoles");
165 qInfo(
"dip output : %s",
dipname.toUtf8().data());
167 qInfo(
"bdip output : %s",
bdipname.toUtf8().data());
172void InvDipoleFitSettings::usage(
const char *name)
174 qInfo(
"usage: %s [options]",name);
175 qInfo(
"This is a program for sequential single dipole fitting.");
176 qInfo(
"\nInput data:\n");
177 qInfo(
"\t--meas name specify an evoked-response data file");
178 qInfo(
"\t--set no evoked data set number to use (default: 1)");
179 qInfo(
"\t--bad name take bad channel list from here");
181 qInfo(
"\nModality selection:\n");
182 qInfo(
"\t--meg employ MEG data in fitting");
183 qInfo(
"\t--eeg employ EEG data in fitting");
185 qInfo(
"\nTime scale selection:\n");
186 qInfo(
"\t--tmin time/ms specify the starting analysis time");
187 qInfo(
"\t--tmax time/ms specify the ending analysis time");
188 qInfo(
"\t--tstep time/ms specify the time step between frames (default 1/(sampling frequency))");
189 qInfo(
"\t--integ time/ms specify the time integration for each frame (default 0)");
191 qInfo(
"\nPreprocessing:\n");
192 qInfo(
"\t--bmin time/ms specify the baseline starting time (evoked data only)");
193 qInfo(
"\t--bmax time/ms specify the baseline ending time (evoked data only)");
194 qInfo(
"\t--proj name Load the linear projection from here");
195 qInfo(
"\t Multiple projections can be specified.");
196 qInfo(
"\t The data file will be automatically included, unless --noproj is present.");
197 qInfo(
"\t--noproj Do not load the projection from the data file, just those given with the --proj option.");
198 qInfo(
"\n\tFiltering (raw data only):\n");
199 qInfo(
"\t--filtersize size desired filter length (default = %d)",
filter.
size);
200 qInfo(
"\t--highpass val/Hz highpass corner (default = %6.1f Hz)",
filter.
highpass);
201 qInfo(
"\t--lowpass val/Hz lowpass corner (default = %6.1f Hz)",
filter.
lowpass);
202 qInfo(
"\t--lowpassw val/Hz lowpass transition width (default = %6.1f Hz)",
filter.
lowpass_width);
203 qInfo(
"\t--filteroff do not filter the data");
205 qInfo(
"\nNoise specification:\n");
206 qInfo(
"\t--noise name take the noise-covariance matrix from here");
207 qInfo(
"\t--gradnoise val specify a gradiometer noise value in fT/cm");
208 qInfo(
"\t--magnoise val specify a magnetometer noise value in fT");
209 qInfo(
"\t--eegnoise val specify an EEG value in uV");
210 qInfo(
"\t NOTE: The above will be used only if --noise is missing");
211 qInfo(
"\t--diagnoise omit off-diagonal terms from the noise-covariance matrix");
212 qInfo(
"\t--reg amount Apply regularization to the noise-covariance matrix (same fraction for all channels).");
213 qInfo(
"\t--gradreg amount Apply regularization to the MEG noise-covariance matrix (planar gradiometers, default = %6.2f).",
grad_reg);
214 qInfo(
"\t--magreg amount Apply regularization to the MEG noise-covariance matrix (axial gradiometers and magnetometers, default = %6.2f).",
mag_reg);
215 qInfo(
"\t--eegreg amount Apply regularization to the EEG noise-covariance matrix (default = %6.2f).",
eeg_reg);
217 qInfo(
"\nForward model:\n");
218 qInfo(
"\t--mri name take head/MRI coordinate transform from here (Neuromag MRI description file)");
219 qInfo(
"\t--bem name BEM model name");
220 qInfo(
"\t--origin x:y:z/mm use a sphere model with this origin (head coordinates/mm)");
221 qInfo(
"\t--eegscalp scale the electrode locations to the surface of the scalp when using a sphere model");
222 qInfo(
"\t--eegmodels name read EEG sphere model specifications from here.");
223 qInfo(
"\t--eegmodel name name of the EEG sphere model to use (default : Default)");
224 qInfo(
"\t--eegrad val radius of the scalp surface to use in EEG sphere model (default : %7.1f mm)",1000*
eeg_sphere_rad);
225 qInfo(
"\t--accurate use accurate coil definitions in MEG forward computation");
227 qInfo(
"\nFitting parameters:\n");
228 qInfo(
"\t--guess name The source space of initial guesses.");
229 qInfo(
"\t If not present, the values below are used to generate the guess grid.");
230 qInfo(
"\t--guesssurf name Read the inner skull surface from this fif file to generate the guesses.");
231 qInfo(
"\t--guessrad value Radius of a spherical guess volume if neither of the above is present (default : %.1f mm)",1000*
guess_rad);
232 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);
233 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);
234 qInfo(
"\t--grid dist/mm Source space grid size (default = %6.1f mm).",1000*
guess_grid);
235 qInfo(
"\t--magdip Fit magnetic dipoles instead of current dipoles.");
236 qInfo(
"\nOutput:\n");
237 qInfo(
"\t--dip name xfit dip format output file name");
238 qInfo(
"\t--bdip name xfit bdip format output file name");
239 qInfo(
"\nGeneral:\n");
240 qInfo(
"\t--gui Enables the gui.");
241 qInfo(
"\t--help print this info.");
242 qInfo(
"\t--version print version info.");
247bool InvDipoleFitSettings::check_unrecognized_args(
int argc,
char **argv)
251 for (
int k = 1; k < argc; k++)
252 args += QString(argv[k]) +
" ";
253 qCritical(
"Unrecognized arguments : %s", args.trimmed().toUtf8().data());
261bool InvDipoleFitSettings::check_args (
int *argc,
char **argv)
265 int ival,filter_size;
267 for (
int k = 0; k < *argc; k++) {
269 if (strcmp(argv[k],
"--gui") == 0) {
273 else if (strcmp(argv[k],
"--version") == 0) {
274 qInfo(
"%s compiled at %s %s",
275 argv[0],__DATE__,__TIME__);
278 else if (strcmp(argv[k],
"--help") == 0) {
282 else if (strcmp(argv[k],
"--guess") == 0) {
284 if (k == *argc - 1) {
285 qCritical (
"--guess: argument required.");
290 else if (strcmp(argv[k],
"--gsurf") == 0) {
292 if (k == *argc - 1) {
293 qCritical (
"--gsurf: argument required.");
298 else if (strcmp(argv[k],
"--guesssurf") == 0) {
300 if (k == *argc - 1) {
301 qCritical (
"--guesssurf: argument required.");
306 else if (strcmp(argv[k],
"--guessrad") == 0) {
308 if (k == *argc - 1) {
309 qCritical (
"--guessrad: argument required.");
312 if (sscanf(argv[k+1],
"%f",&fval) != 1) {
313 qCritical (
"Could not interpret the radius.");
317 qCritical (
"Radius should be positive");
322 else if (strcmp(argv[k],
"--mindist") == 0) {
324 if (k == *argc - 1) {
325 qCritical (
"--mindist: argument required.");
328 if (sscanf(argv[k+1],
"%f",&fval) != 1) {
329 qCritical (
"Could not interpret the distance.");
336 else if (strcmp(argv[k],
"--exclude") == 0) {
338 if (k == *argc - 1) {
339 qCritical (
"--exclude: argument required.");
342 if (sscanf(argv[k+1],
"%f",&fval) != 1) {
343 qCritical (
"Could not interpret the distance.");
350 else if (strcmp(argv[k],
"--grid") == 0) {
352 if (k == *argc - 1) {
353 qCritical (
"--grid: argument required.");
356 if (sscanf(argv[k+1],
"%f",&fval) != 1) {
357 qCritical (
"Could not interpret the distance.");
361 qCritical (
"Grid spacing should be positive");
366 else if (strcmp(argv[k],
"--mri") == 0) {
368 if (k == *argc - 1) {
369 qCritical (
"--mri: argument required.");
374 else if (strcmp(argv[k],
"--bem") == 0) {
376 if (k == *argc - 1) {
377 qCritical (
"--bem: argument required.");
382 else if (strcmp(argv[k],
"--accurate") == 0) {
386 else if (strcmp(argv[k],
"--meg") == 0) {
390 else if (strcmp(argv[k],
"--eeg") == 0) {
394 else if (strcmp(argv[k],
"--origin") == 0) {
396 if (k == *argc - 1) {
397 qCritical (
"--origin: argument required.");
400 if (sscanf(argv[k+1],
"%f:%f:%f",&
r0[0],&
r0[1],&
r0[2]) != 3) {
401 qCritical (
"Could not interpret the origin.");
404 r0[0] =
r0[0]/1000.0f;
405 r0[1] =
r0[1]/1000.0f;
406 r0[2] =
r0[2]/1000.0f;
408 else if (strcmp(argv[k],
"--eegrad") == 0) {
410 if (k == *argc - 1) {
411 qCritical (
"--eegrad: argument required.");
415 qCritical () <<
"Incomprehensible radius:" << argv[k+1];
419 qCritical (
"Radius must be positive");
424 else if (strcmp(argv[k],
"--eegmodels") == 0) {
426 if (k == *argc - 1) {
427 qCritical (
"--eegmodels: argument required.");
432 else if (strcmp(argv[k],
"--eegmodel") == 0) {
434 if (k == *argc - 1) {
435 qCritical (
"--eegmodel: argument required.");
440 else if (strcmp(argv[k],
"--eegscalp") == 0) {
444 else if (strcmp(argv[k],
"--meas") == 0) {
446 if (k == *argc - 1) {
447 qCritical (
"--meas: argument required.");
453 else if (strcmp(argv[k],
"--raw") == 0) {
455 if (k == *argc - 1) {
456 qCritical (
"--raw: argument required.");
462 else if (strcmp(argv[k],
"--proj") == 0) {
464 if (k == *argc - 1) {
465 qCritical (
"--proj: argument required.");
470 else if (strcmp(argv[k],
"--noproj") == 0) {
474 else if (strcmp(argv[k],
"--bad") == 0) {
476 if (k == *argc - 1) {
477 qCritical (
"--bad: argument required.");
482 else if (strcmp(argv[k],
"--noise") == 0) {
484 if (k == *argc - 1) {
485 qCritical (
"--noise: argument required.");
490 else if (strcmp(argv[k],
"--gradnoise") == 0) {
492 if (k == *argc - 1) {
493 qCritical (
"--gradnoise: argument required.");
496 if (sscanf(argv[k+1],
"%g",&fval) != 1) {
497 qCritical() <<
"Incomprehensible value:" << argv[k+1];
501 qCritical (
"Value should be positive");
506 else if (strcmp(argv[k],
"--magnoise") == 0) {
508 if (k == *argc - 1) {
509 qCritical (
"--magnoise: argument required.");
512 if (sscanf(argv[k+1],
"%g",&fval) != 1) {
513 qCritical() <<
"Incomprehensible value:" << argv[k+1];
517 qCritical (
"Value should be positive");
522 else if (strcmp(argv[k],
"--eegnoise") == 0) {
524 if (k == *argc - 1) {
525 qCritical (
"--eegnoise: argument required.");
528 if (sscanf(argv[k+1],
"%g",&fval) != 1) {
529 qCritical () <<
"Incomprehensible value:" << argv[k+1];
533 qCritical (
"Value should be positive");
538 else if (strcmp(argv[k],
"--diagnoise") == 0) {
542 else if (strcmp(argv[k],
"--eegreg") == 0) {
544 if (k == *argc - 1) {
545 qCritical (
"--eegreg: argument required.");
548 if (sscanf(argv[k+1],
"%g",&fval) != 1) {
549 qCritical () <<
"Incomprehensible value:" << argv[k+1];
552 if (fval < 0 || fval > 1) {
553 qCritical (
"Regularization value should be positive and smaller than one.");
558 else if (strcmp(argv[k],
"--magreg") == 0) {
560 if (k == *argc - 1) {
561 qCritical (
"--magreg: argument required.");
564 if (sscanf(argv[k+1],
"%g",&fval) != 1) {
565 qCritical () <<
"Incomprehensible value:" << argv[k+1];
568 if (fval < 0 || fval > 1) {
569 qCritical (
"Regularization value should be positive and smaller than one.");
574 else if (strcmp(argv[k],
"--gradreg") == 0) {
576 if (k == *argc - 1) {
577 qCritical (
"--gradreg: argument required.");
580 if (sscanf(argv[k+1],
"%g",&fval) != 1) {
581 qCritical () <<
"Incomprehensible value:" << argv[k+1] ;
584 if (fval < 0 || fval > 1) {
585 qCritical (
"Regularization value should be positive and smaller than one.");
590 else if (strcmp(argv[k],
"--reg") == 0) {
592 if (k == *argc - 1) {
593 qCritical (
"--reg: argument required.");
596 if (sscanf(argv[k+1],
"%g",&fval) != 1) {
597 qCritical () <<
"Incomprehensible value:" << argv[k+1];
600 if (fval < 0 || fval > 1) {
601 qCritical (
"Regularization value should be positive and smaller than one.");
608 else if (strcmp(argv[k],
"--tstep") == 0) {
610 if (k == *argc - 1) {
611 qCritical (
"--tstep: argument required.");
614 if (sscanf(argv[k+1],
"%g",&fval) != 1) {
615 qCritical() <<
"Incomprehensible tstep:" << argv[k+1];
619 qCritical (
"Time step should be positive");
624 else if (strcmp(argv[k],
"--integ") == 0) {
626 if (k == *argc - 1) {
627 qCritical (
"--integ: argument required.");
630 if (sscanf(argv[k+1],
"%g",&fval) != 1) {
631 qCritical() <<
"Incomprehensible integration time:" << argv[k+1];
635 qCritical (
"Integration time should be positive.");
638 integ = fval/1000.0f;
640 else if (strcmp(argv[k],
"--tmin") == 0) {
642 if (k == *argc - 1) {
643 qCritical (
"--tmin: argument required.");
646 if (sscanf(argv[k+1],
"%g",&fval) != 1) {
647 qCritical() <<
"Incomprehensible tmin:" << argv[k+1];
652 else if (strcmp(argv[k],
"--tmax") == 0) {
654 if (k == *argc - 1) {
655 qCritical (
"--tmax: argument required.");
658 if (sscanf(argv[k+1],
"%g",&fval) != 1) {
659 qCritical() <<
"Incomprehensible tmax:" << argv[k+1];
664 else if (strcmp(argv[k],
"--bmin") == 0) {
666 if (k == *argc - 1) {
667 qCritical (
"--bmin: argument required.");
670 if (sscanf(argv[k+1],
"%g",&fval) != 1) {
671 qCritical() <<
"Incomprehensible bmin:" << argv[k+1];
676 else if (strcmp(argv[k],
"--bmax") == 0) {
678 if (k == *argc - 1) {
679 qCritical (
"--bmax: argument required.");
682 if (sscanf(argv[k+1],
"%g",&fval) != 1) {
683 qCritical() <<
"Incomprehensible bmax:" << argv[k+1];
688 else if (strcmp(argv[k],
"--set") == 0) {
690 if (k == *argc - 1) {
691 qCritical (
"--set: argument required.");
694 if (sscanf(argv[k+1],
"%d",&
setno) != 1) {
695 qCritical() <<
"Incomprehensible data set number:" << argv[k+1];
699 qCritical (
"Data set number must be > 0");
703 else if (strcmp(argv[k],
"--filteroff") == 0) {
707 else if (strcmp(argv[k],
"--lowpass") == 0) {
709 if (k == *argc - 1) {
710 qCritical (
"--lowpass: argument required.");
713 if (sscanf(argv[k+1],
"%g",&fval) != 1) {
714 qCritical() <<
"Illegal number:" << argv[k+1];
718 qCritical (
"Lowpass corner must be positive");
723 else if (strcmp(argv[k],
"--lowpassw") == 0) {
725 if (k == *argc - 1) {
726 qCritical (
"--lowpassw: argument required.");
729 if (sscanf(argv[k+1],
"%g",&fval) != 1) {
730 qCritical() <<
"Illegal number:" << argv[k+1];
734 qCritical (
"Lowpass width must be positive");
737 filter.lowpass_width = fval;
739 else if (strcmp(argv[k],
"--highpass") == 0) {
741 if (k == *argc - 1) {
742 qCritical (
"--highpass: argument required.");
745 if (sscanf(argv[k+1],
"%g",&fval) != 1) {
746 qCritical() <<
"Illegal number:" << argv[k+1];
750 qCritical (
"Highpass corner must be positive");
755 else if (strcmp(argv[k],
"--filtersize") == 0) {
757 if (k == *argc - 1) {
758 qCritical (
"--filtersize: argument required.");
761 if (sscanf(argv[k+1],
"%d",&ival) != 1) {
762 qCritical() <<
"Illegal number:" << argv[k+1];
766 qCritical (
"Filtersize should be at least 1024.");
769 for (filter_size = 1024; filter_size < ival; filter_size = 2*filter_size)
771 filter.size = filter_size;
772 filter.taper_size = filter_size/2;
774 else if (strcmp(argv[k],
"--magdip") == 0) {
778 else if (strcmp(argv[k],
"--dip") == 0) {
780 if (k == *argc - 1) {
781 qCritical (
"--dip: argument required.");
786 else if (strcmp(argv[k],
"--bdip") == 0) {
788 if (k == *argc - 1) {
789 qCritical (
"--bdip: argument required.");
794 else if (strcmp(argv[k],
"--verbose") == 0) {
799 for (
int p = k; p < *argc-found; p++)
800 argv[p] = argv[p+found];
801 *argc = *argc - found;
805 return check_unrecognized_args(*argc,argv);
Dipole Fit Setting class declaration.
Inverse source estimation (MNE, dSPM, sLORETA, dipole fitting).
MNELIB::MNEFilterDef filter
virtual ~InvDipoleFitSettings()