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