summarylogtreecommitdiffstats
path: root/nonlinear_extended.diff
blob: 49d682558cf8abb2a6badf1eb086388963b39002 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
Description: Add multiple non-linear data fitting functions
 One of the most used features in software for scientific data analysis is
 the ability to perform non linear peak fitting (specifically Lorentzian and
 Gaussian fits). Xmgrace sorely lacks this capability, unless you consider
 adding manually the required formula.
 .
 This implements a substantial library of such functions and documentation
 for their use.
Author: Nicola Ferralis <feranick@hotmail.com>
Bug: http://plasma-gate.weizmann.ac.il/Grace/phpbb/w3todo.php?action=view_report&project_id=1&todo_id=2220
Bug-Debian: http://bugs.debian.org/578435
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/grace/+bug/535459
Last-Update: 2010-05-26
Index: grace-5.1.22/doc/UsersGuide.html
===================================================================
--- grace-5.1.22.orig/doc/UsersGuide.html	2008-05-21 13:52:14.000000000 -0700
+++ grace-5.1.22/doc/UsersGuide.html	2010-07-27 11:01:29.000000000 -0700
@@ -1516,6 +1516,103 @@
 sample range or to produce an evenly spaced set from an irregular
 one.</P>
 
+<P>Under the "Library" menu, several functions are available under the
+categories: "Gaussian Functions", "Lorentzian Functions", "Peak Functions",
+ "Periodic Peak Functions" and "Baseline Functions".</P>
+
+<P><i>Gaussian</i><br>&nbsp y = A0 + (A3*2*sqrt(ln(2)/pi)/A2)*exp(-4*ln(2)*((x-A1)/A2)^2)<br>
+&nbsp where: A0: Baseline offset; A1: Center of the peak; A2: Full width at half
+maximum; A3: Peak area.<br> The center and initial amplitude of the peak can be set from
+ user input (via mouse coordinates). </P>
+
+<br>
+<P><i>Gaussian (Chromatography):</i><br>
+&nbsp y = A0 + (1/sqrt(2*pi))*(A3/A2)*exp(-(x-A1)^2/2*A2^2)
+ A0: Baseline offset; A1: Center of the peak (retention time); A2:
+ Standard deviation of the peak; A3: Peak area. <br> The center and initial amplitude of the peak can be set from
+ user input (via mouse coordinates). </P>
+
+<br>
+<P><i>Lorentzian</i><br>&nbsp y = A0 + (2*A2*A3/pi)/(4*(x-A1)^2 + A2^2)<br>
+&nbsp where: A0: Baseline offset; A1: Center of the peak; A2: Full width at half
+maximum; A3: Peak area. <br> The center and initial amplitude of the peak can be set from
+ user input (via mouse coordinates).</P>
+
+<br>
+<P><i>Peak Functions</i><br>
+<i>Pseudo Voigt 1</i><br>
+&nbsp y = A0 + A3 * (A4*(2/pi)*A2/(4*(x-A1)^2+A2^2) + <br>(1-A4)*exp(-4*ln(2)*(x-A1)^2/A2^2)*(sqrt(4*ln(2))/(A2*sqrt(pi))))<br>
+&nbsp where: Gaussian and Lorentzian have the same width; A0: Baseline offset;
+ A1: Center of the peak; A2: Full width at half maximum; A3: Amplitude;
+ A4: Profile shape factor.<br>
+<i>Pseudo Voigt 2</i><br>
+&nbsp y = A0 + A3 * (A5*(2/pi)*A2/(4*(x-A1)^2+A2^2) + (1-A5)*exp(-4*ln(2)*(x-A1)^2/A4^2)*(sqrt(4*ln(2))/(A2*sqrt(pi))))<br>
+&nbsp where: Gaussian and Lorentzian have different width; A0: Baseline offset;
+ A1: Center of the peak; A2: Full width at half maximum; A3: Amplitude;
+ A4: Profile shape factor.<br>
+<i>Doniach-Sunjic</i><br>
+&nbsp y = A0 + A3*cos((pi*A4/2)+(1-A4)*atan((x-A1)/A2))/(A2^2+(x-A1)^2)^((1-A4)/2)<br>
+&nbsp where:A0: Baseline offset; A1: Center of the peak; A2: Full width at half maximum;<br>
+&nbspA3: Peak area; A4: Asymmetry parameter.<br>
+<i>Asymmetric double Sigmoidal</i><br>
+&nbsp y = A0 + A3*(1/(1+exp(-(x-A1+A2/2)/A4)))*(1-(1/(1+exp(-(x-A1-A2/2)/A5))))<br>
+&nbsp where: A0: Baseline offset; A1: Center of the peak; A2: Width 1;
+ A3: Amplitude; A4: Width 2; A5: Width 5.<br>
+<i>Logarithm Normal:</i> <br>
+&nbsp y = A0 + A3*exp(-((ln(x)-ln(A1))^2)/(2*A2))<br>
+&nbsp where: A0: Baseline offset; A1: Center of the peak; A2: Width <br>
+<i>Gram-Charlier A-Series (GCAS)</i><br>
+&nbsp y = A0 + A3/(A2*sqrt(2*pi))*exp(-0.5*((x-A1)/A2)^2)*(1+(A4/6)*
+ (((x-A1)/A2)^3-3*(x-A1)/A2)+(A5/24)*(((x-A1)/A2)^4-6*((x-A1)/A2)^3+3))<br>
+&nbsp where: A0: Baseline offset; A1: Center of the peak; A2: Standard deviation;
+ A3: Peak Area; A4: Skew; A5: Excess. <br>
+<i>Edgeworth-Cramer Series</i><br>
+&nbsp y = A0 + A3/(A2*sqrt(2*pi))*exp(-0.5*((x-A1)/A2)^2)*(1+(A4/6)*
+ (((x-A1)/A2)^3-3*(x-A1)/A2)+(A5/24)*(((x-A1)/A2)^4-6 *((x-A1)/A2)^3+3)
+ +(A5^2/720)*(((x-A1)/A2)^6-15*((x-A1)/A2)^4+45*((x-A1)/A2)^2-15))<br>
+&nbsp where: A0: Baseline offset; A1: Center of the peak; A2: Standard deviation;
+ A3: Peak Area; A4: Skew; A5: Excess. <br>
+<i>Inverse Polynomial</i><br>
+&nbsp y=A0+A3/(1+ A4*(2*(x-A1)/A2)^2 + A5*(2*(x-A1)/A2)^4 + A6*(2*(x-A1)/A2)^6) <br>
+&nbsp where: A0: Baseline offset; A1: Center of the peak; A2: Standard deviation;
+ A3: Peak Area; A4, A5, A6: Parameters. <br>
+ </P>
+
+<br>
+<P><i>Periodic Peak Functions</i><br>
+<i>Sine:</i> <br>
+&nbspy=A0+A3*sin(pi*(x-A1)/A2)<br>
+&nbspwhere: A0: Baseline offset; A1: Center; A2: Width; A3: Amplitude.<br>
+<i>Sine Square: </i><br>
+&nbspy=A0+A3*sin(pi*(x-A1)/A2)^2<br>
+&nbspwhere: A0: Baseline offset; A1: Center; A2: Width; A3: Amplitude.<br>
+<i>Sine damp: </i><br>
+&nbspy=A0+A3*exp(-x/A4)*sin(pi*(x-A1)/A2)<br>
+&nbspwhere: A0: Baseline offset; A1: Center; A2: Width; A3: Amplitude; A4: Decay time. <br>
+</P>
+
+<br>
+<P><i>Baseline Functions</i><br>
+<i>Exponential Decay 1:</i><br>
+&nbsp;y=A0+A3*exp(-(x-A1)/A2)<br>
+<b>Exponential Decay 2:</b> <br>
+&nbsp;y=A0+A3*exp(-(x-A1)/A2)+A6*exp(-(x-A4)/A5);<br>
+<i>Exponential Growth 1:</i> <br>
+&nbsp;y=A0+A3*exp((x-A1)/A2)<br>
+<i>Exponential Growth 2: </i><br>
+&nbsp;y=A0+A3*exp(-(x-A1)/A2)+A6*exp((x-A4)/A5);<br>
+<i>Hyperbolic:</i><br>
+&nbsp;y=A0+(A1*x)/(A2+x)<br>
+<i>Bradley:</i> <br>
+&nbsp;y=A0*ln(-A1*ln(x))<br>
+<i>Logarithm 3 Parameters: </i><br>
+&nbsp;y=A0-A1*ln(x+A2)<br>
+<i>Weibull Probability Density 2 Parameters: </i><br>
+&nbsp;y=(A0/A1)*((x/A1)^(A0-1))*exp(-(x/A1)^A0)<br>
+<i>Weibull Cumulative Distribution 2 Parameters: </i><br>
+&nbsp;y=1-exp(-(x/A1)^A0)<br>
+</P>
+
 <H3><A NAME="correlation/covariance"></A> Correlation/covariance          </H3>
 
 <P>This popup can be used to compute autocorrelation
Index: grace-5.1.22/src/draw.c
===================================================================
--- grace-5.1.22.orig/src/draw.c	2005-11-19 13:53:24.000000000 -0800
+++ grace-5.1.22/src/draw.c	2010-07-27 10:50:30.000000000 -0700
@@ -258,6 +258,12 @@
     return (vp);
 }
 
+WPoint Vpoint2Wpoint(VPoint vp)
+{
+    WPoint wp;
+    view2world(vp.x, vp.y, &wp.x, &wp.y);
+    return (wp);
+}
 
 void symplus(VPoint vp, double s)
 {
Index: grace-5.1.22/src/draw.h
===================================================================
--- grace-5.1.22.orig/src/draw.h	2004-07-03 13:47:45.000000000 -0700
+++ grace-5.1.22/src/draw.h	2010-07-27 10:50:30.000000000 -0700
@@ -236,6 +236,7 @@
 double xy_xconv(double wx);
 double xy_yconv(double wy);
 VPoint Wpoint2Vpoint(WPoint wp);
+WPoint Vpoint2Wpoint(VPoint vp);
 int world2view(double x, double y, double *xv, double *yv);
 void view2world(double xv, double yv, double *xw, double *yw);
 
Index: grace-5.1.22/src/events.c
===================================================================
--- grace-5.1.22.orig/src/events.c	2008-04-26 12:12:11.000000000 -0700
+++ grace-5.1.22/src/events.c	2010-07-27 10:50:30.000000000 -0700
@@ -111,6 +111,7 @@
     int axisno;
     Datapoint dpoint;
     GLocator locator;
+    static char buf[256];
     
     cg = get_cg();
     get_tracking_props(&track_setno, &move_dir, &add_at);
@@ -487,6 +488,60 @@
                 }
                 select_line(anchor_x, anchor_y, x, y, 0);
 		break;
+	    case PEAK_POS:
+		anchor_point(x, y, vp);
+		sprintf(buf, "Initial peak position, intensity: %f, %f \n", Vpoint2Wpoint(vp).x, Vpoint2Wpoint(vp).y);
+		stufftext(buf);
+		nonl_parms[1].value = Vpoint2Wpoint(vp).x;
+		nonl_parms[3].value = Vpoint2Wpoint(vp).y;
+		set_actioncb(NULL);
+		update_nonl_frame();
+		break;
+	    case PEAK_POS1:
+		anchor_point(x, y, vp);
+		sprintf(buf, "Initial position, intensity peak #1: %f, %f \n", Vpoint2Wpoint(vp).x, Vpoint2Wpoint(vp).y);
+		stufftext(buf);
+		nonl_parms[1].value = Vpoint2Wpoint(vp).x;
+		nonl_parms[3].value = Vpoint2Wpoint(vp).y;
+		set_actioncb((void*) PEAK_POS2);
+		update_nonl_frame();
+		break;
+	    case PEAK_POS2:
+		anchor_point(x, y, vp);
+		sprintf(buf, "Initial position, intensity peak #2: %f, %f \n", Vpoint2Wpoint(vp).x, Vpoint2Wpoint(vp).y);
+		stufftext(buf);
+		nonl_parms[4].value = Vpoint2Wpoint(vp).x;
+		nonl_parms[6].value = Vpoint2Wpoint(vp).y;
+		set_actioncb(NULL);
+		update_nonl_frame();
+		break;
+	    case PEAK_POS1B:
+		anchor_point(x, y, vp);
+		sprintf(buf, "Initial position, intensity peak #1: %f, %f \n", Vpoint2Wpoint(vp).x, Vpoint2Wpoint(vp).y);
+		stufftext(buf);
+		nonl_parms[1].value = Vpoint2Wpoint(vp).x;
+		nonl_parms[3].value = Vpoint2Wpoint(vp).y;
+		set_actioncb((void*) PEAK_POS2B);
+		update_nonl_frame();
+		break;
+	    case PEAK_POS2B:
+		anchor_point(x, y, vp);
+		sprintf(buf, "Initial position, intensity peak #2: %f, %f \n", Vpoint2Wpoint(vp).x, Vpoint2Wpoint(vp).y);
+		stufftext(buf);
+		nonl_parms[4].value = Vpoint2Wpoint(vp).x;
+		nonl_parms[6].value = Vpoint2Wpoint(vp).y;
+		set_actioncb((void*) PEAK_POS3B);
+		update_nonl_frame();
+		break;
+	    case PEAK_POS3B:
+		anchor_point(x, y, vp);
+		sprintf(buf, "Initial position, intensity peak #3: %f, %f \n", Vpoint2Wpoint(vp).x, Vpoint2Wpoint(vp).y);
+		stufftext(buf);
+		nonl_parms[7].value = Vpoint2Wpoint(vp).x;
+		nonl_parms[9].value = Vpoint2Wpoint(vp).y;
+		set_actioncb(NULL);
+		update_nonl_frame();
+		break;
             default:
                 break;
             }
@@ -567,6 +622,7 @@
 void set_action(CanvasAction act)
 {
     int i;
+    static char buf[256];
 /*
  * indicate what's happening with a message in the left footer
  */
@@ -760,6 +816,42 @@
 	set_cursor(0);
 	set_left_footer("Pick ending point");
 	break;
+    case PEAK_POS:
+	set_cursor(0);
+	set_left_footer("Click on the approximate position of the maximum of the peak");
+	sprintf(buf, "Click on the approximate position of the maximum of the peak.\n");
+	stufftext(buf);
+	break;
+    case PEAK_POS1:
+	set_cursor(0);
+	set_left_footer("Click on the approximate position of the maximum of the peak #1");
+	sprintf(buf, "Click on the approximate position of the maximum of the peak #1.\n");
+	stufftext(buf);
+	break;
+    case PEAK_POS2:
+	set_cursor(0);
+	set_left_footer("Click on the approximate position of the maximum of the peak #2");
+	sprintf(buf, "Click on the approximate position of the maximum of the peak #2.\n");
+	stufftext(buf);
+	break;
+    case PEAK_POS1B:
+	set_cursor(0);
+	set_left_footer("Click on the approximate position of the maximum of the peak #1");
+	sprintf(buf, "Click on the approximate position of the maximum of the peak #1.\n");
+	stufftext(buf);
+	break;
+    case PEAK_POS2B:
+	set_cursor(0);
+	set_left_footer("Click on the approximate position of the maximum of the peak #2");
+	sprintf(buf, "Click on the approximate position of the maximum of the peak #2.\n");
+	stufftext(buf);
+	break;
+    case PEAK_POS3B:
+	set_cursor(0);
+	set_left_footer("Click on the approximate position of the maximum of the peak #3");
+	sprintf(buf, "Click on the approximate position of the maximum of the peak #3.\n");
+	stufftext(buf);
+	break;
     }
 
     action_flag = act;
Index: grace-5.1.22/src/events.h
===================================================================
--- grace-5.1.22.orig/src/events.h	2004-07-03 13:47:45.000000000 -0700
+++ grace-5.1.22/src/events.h	2010-07-27 10:50:30.000000000 -0700
@@ -81,7 +81,13 @@
     ZOOMY_1ST,
     ZOOMY_2ND,
     DISLINE1ST,
-    DISLINE2ND
+    DISLINE2ND,
+    PEAK_POS,
+    PEAK_POS1,
+    PEAK_POS2,
+    PEAK_POS1B,
+    PEAK_POS2B,
+    PEAK_POS3B
 } CanvasAction;
 
 /* add points at */
Index: grace-5.1.22/src/nonlwin.c
===================================================================
--- grace-5.1.22.orig/src/nonlwin.c	2010-07-27 10:50:30.000000000 -0700
+++ grace-5.1.22/src/nonlwin.c	2010-07-27 11:01:29.000000000 -0700
@@ -7,6 +7,7 @@
  * Copyright (c) 1996-2000 Grace Development Team
  * 
  * Maintained by Evgeny Stambulchik
+ * Additional non linear fitting functions by Nicola Ferralis
  * 
  * 
  *                           All Rights Reserved
@@ -47,6 +48,7 @@
 #include "parser.h"
 #include "motifinc.h"
 #include "protos.h"
+#include "events.h"
 
 /* nonlprefs.load possible values */
 #define LOAD_VALUES         0
@@ -98,6 +100,34 @@
 static void nonl_wf_cb(int value, void *data);
 static void do_constr_toggle(int onoff, void *data);
 
+static void nonl_Lorentzian_cb(void *data);
+static void nonl_doubleLorentzian_cb(void *data);
+static void nonl_tripleLorentzian_cb(void *data);
+static void nonl_Gaussian_cb(void *data);
+static void nonl_doubleGaussian_cb(void *data);
+static void nonl_tripleGaussian_cb(void *data);
+static void nonl_Gaussian2_cb(void *data);
+static void nonl_PsVoight1_cb(void *data);
+static void nonl_PsVoight2_cb(void *data);
+static void nonl_DS_cb(void *data);
+static void nonl_Asym2Sig_cb(void *data);
+static void nonl_LogNormal_cb(void *data);
+static void nonl_GCAS_cb(void *data);
+static void nonl_ECS_cb(void *data);
+static void nonl_InvPoly_cb(void *data);
+static void nonl_Sine_cb(void *data);
+static void nonl_Sinesq_cb(void *data);
+static void nonl_Sinedamp_cb(void *data);
+static void nonl_ExpDec1_cb(void *data);
+static void nonl_ExpDec2_cb(void *data);
+static void nonl_ExpGrow1_cb(void *data);
+static void nonl_ExpGrow2_cb(void *data);
+static void nonl_Hyperbol_cb(void *data);
+static void nonl_Bradley_cb(void *data);
+static void nonl_Log3_cb(void *data);
+static void nonl_WeibullPD_cb(void *data);
+static void nonl_WeibullCD_cb(void *data);
+
 static void update_nonl_frame_cb(void *data);
 static void reset_nonl_frame_cb(void *data);
 
@@ -118,7 +148,7 @@
     if (nonl_frame == NULL) {
         int i;
         OptionItem np_option_items[MAXPARM + 1], option_items[5];
-        Widget menubar, menupane;
+        Widget menubar, menupane, submenugauss, submenulorentz, submenupeak, submenubaseline, submenuperiodic;
         Widget nonl_tab, nonl_main, nonl_advanced;
         Widget sw, title_fr, fr3, rc1, rc2, rc3, lab;
 
@@ -145,6 +175,54 @@
         CreateMenuSeparator(menupane);
         CreateMenuButton(menupane, "Update", 'U', update_nonl_frame_cb, NULL);
 
+	menupane = CreateMenu(menubar, "Library", 'L', FALSE);
+
+	submenugauss = CreateMenu(menupane, "Gaussian Functions", 'G', FALSE);
+	CreateMenuButton(submenugauss, "Single", 'g', nonl_Gaussian_cb, NULL);
+	CreateMenuButton(submenugauss, "Double", 'D', nonl_doubleGaussian_cb, NULL);
+	CreateMenuButton(submenugauss, "Triple", 'T', nonl_tripleGaussian_cb, NULL);
+	CreateMenuSeparator(submenugauss);
+	CreateMenuButton(submenugauss, "Single (chromatography)", 'c', nonl_Gaussian2_cb, NULL);
+	CreateMenuSeparator(menupane);
+
+	submenulorentz = CreateMenu(menupane, "Lorentzian Functions", 'L', FALSE);
+	CreateMenuButton(submenulorentz, "Single", 'S', nonl_Lorentzian_cb, NULL);
+	CreateMenuButton(submenulorentz, "Double", 'D', nonl_doubleLorentzian_cb, NULL);
+	CreateMenuButton(submenulorentz, "Triple", 'T', nonl_tripleLorentzian_cb, NULL);
+	CreateMenuSeparator(menupane);
+
+	submenupeak = CreateMenu(menupane, "Peak Functions", 'P', FALSE);
+	CreateMenuButton(submenupeak, "Pseudo Voigt 1", 'V', nonl_PsVoight1_cb, NULL);
+	CreateMenuButton(submenupeak, "Pseudo Voigt 2", 'o', nonl_PsVoight2_cb, NULL);
+	CreateMenuButton(submenupeak, "Doniach-Sunjic", 'D', nonl_DS_cb, NULL);
+	CreateMenuButton(submenupeak, "Asymmetric Double Sigmoidal", 'S', nonl_Asym2Sig_cb, NULL);
+	CreateMenuButton(submenupeak, "LogNormal", 'L', nonl_LogNormal_cb, NULL);
+	CreateMenuButton(submenupeak, "Gram-Charlier A-Series", 'C', nonl_GCAS_cb, NULL);
+	CreateMenuButton(submenupeak, "Edgeworth-Cramer Series", 'E', nonl_ECS_cb, NULL);
+	CreateMenuButton(submenupeak, "Inverse Polynomial", 'I', nonl_InvPoly_cb, NULL);
+	CreateMenuSeparator(menupane);
+
+	submenuperiodic = CreateMenu(menupane, "Periodic Peak Functions", 'e', FALSE);
+	CreateMenuButton(submenuperiodic, "Sine", 'S', nonl_Sine_cb, NULL);
+	CreateMenuButton(submenuperiodic, "Sine Square", 'q', nonl_Sinesq_cb, NULL);
+	CreateMenuButton(submenuperiodic, "Sine Damp", 'D', nonl_Sinedamp_cb, NULL);
+	CreateMenuSeparator(menupane);
+
+	submenubaseline = CreateMenu(menupane, "Baseline Functions", 'B', FALSE);
+	CreateMenuButton(submenubaseline, "Exponential Decay 1", 'D', nonl_ExpDec1_cb, NULL);
+	CreateMenuButton(submenubaseline, "Exponential Decay 2", 'e', nonl_ExpDec2_cb, NULL);
+	CreateMenuButton(submenubaseline, "Exponential Growth 1", 'G', nonl_ExpGrow1_cb, NULL);
+	CreateMenuButton(submenubaseline, "Exponential Growth 2", 'r', nonl_ExpGrow2_cb, NULL);
+	CreateMenuButton(submenubaseline, "Hyperbolic Function", 'H', nonl_Hyperbol_cb, NULL);
+	CreateMenuSeparator(submenubaseline);
+	CreateMenuButton(submenubaseline, "Bradley", 'B', nonl_Bradley_cb, NULL);
+	CreateMenuButton(submenubaseline, "Logarithm 3", 'L', nonl_Log3_cb, NULL);
+	CreateMenuSeparator(submenubaseline);
+	CreateMenuButton(submenubaseline, "Weibull Probability Density", 'W', nonl_WeibullPD_cb, NULL);
+	CreateMenuButton(submenubaseline, "Weibull Cumulative", 'w', nonl_WeibullCD_cb, NULL);
+	CreateMenuSeparator(menupane);
+
+	CreateMenuButton(menupane, "Reset fit parameters", 'R', reset_nonl_frame_cb, NULL);
         menupane = CreateMenu(menubar, "Help", 'H', TRUE);
 
         CreateMenuHelpButton(menupane, "On fit", 'f',
@@ -712,3 +790,343 @@
     }
     return TRUE;
 }
+
+
+static void nonl_Lorentzian_cb(void *data)
+{   int i;
+    nonl_opts.title   = copy_string(nonl_opts.title, "Lorentzian function");
+    nonl_opts.formula = copy_string(nonl_opts.formula, "y = A0 + (2*A2*A3/pi)/(4*(x-A1)^2 + A2^2)");
+    nonl_opts.parnum = 4;
+
+    for (i=0; i<nonl_opts.parnum; i++)
+	{nonl_parms[i].value=1;}
+
+    sprintf(buf, "A0: Baseline offset\nA1: Center of the peak\nA2: Full width at half maximum\nA3: Peak area\n\n");
+    stufftext(buf);
+
+    set_actioncb( (void *) PEAK_POS);
+    update_nonl_frame();
+}
+
+static void nonl_doubleLorentzian_cb(void *data)
+{   int i;
+    nonl_opts.title   = copy_string(nonl_opts.title, "Double Lorentzian function");
+    nonl_opts.formula = copy_string(nonl_opts.formula, "y = A0 + (2*A2*A3/pi)/(4*(x-A1)^2 + A2^2) + (2*A5*A6/pi)/(4*(x-A4)^2 + A5^2)");
+    nonl_opts.parnum = 7;
+
+    for (i=0; i<nonl_opts.parnum; i++)
+	{nonl_parms[i].value=1;}
+
+    sprintf(buf, "A0: Baseline offset\nA1, A4: Center of peaks 1, 2\nA2, A5: Full width at half maximum of peaks 1, 2\nA3, A6: Area of peaks 1, 2\n\n");
+    stufftext(buf);
+    set_actioncb( (void *) PEAK_POS1);
+    update_nonl_frame();
+}
+
+static void nonl_tripleLorentzian_cb(void *data)
+{   int i;
+    nonl_opts.title   = copy_string(nonl_opts.title, "Double Lorentzian function");
+    nonl_opts.formula = copy_string(nonl_opts.formula, "y = A0 + (2*A2*A3/pi)/(4*(x-A1)^2 + A2^2) + (2*A5*A6/pi)/(4*(x-A4)^2 + A5^2) + (2*A8*A9/pi)/(4*(x-A7)^2 + A8^2)");
+    nonl_opts.parnum = 10;
+
+    for (i=0; i<nonl_opts.parnum; i++)
+	{nonl_parms[i].value=1;}
+
+    sprintf(buf, "A0: Baseline offset\nA1, A4, A7: Center of peaks 1, 2, 3\nA2, A5, A7: Full width at half maximum of peaks 1, 2, 3\nA3, A6, A9: Area of peaks 1, 2, 3\n\n");
+    stufftext(buf);
+    set_actioncb( (void *) PEAK_POS1B);
+    update_nonl_frame();
+}
+
+static void nonl_Gaussian_cb(void *data)
+{   int i;
+    nonl_opts.title   = copy_string(nonl_opts.title, "Gaussian function");
+    nonl_opts.formula = copy_string(nonl_opts.formula, "y = A0 + (A3*2*sqrt(ln(2)/pi)/A2)*exp(-4*ln(2)*((x-A1)/A2)^2)");
+    nonl_opts.parnum = 4;
+    for (i=0; i<nonl_opts.parnum; i++)
+	{nonl_parms[i].value=1;}
+    sprintf(buf, "A0: Baseline offset\nA1: Center of the peak\nA2: Full width at half maximum\nA3: Peak area\n\n");
+    stufftext(buf);
+    set_actioncb( (void *) PEAK_POS);
+    update_nonl_frame();
+}
+
+static void nonl_doubleGaussian_cb(void *data)
+{   int i;
+    nonl_opts.title   = copy_string(nonl_opts.title, "Double Gaussian function");
+    nonl_opts.formula = copy_string(nonl_opts.formula, "y = A0 + (A3*2*sqrt(ln(2)/pi)/A2)*exp(-4*ln(2)*((x-A1)/A2)^2) + (A6*2*sqrt(ln(2)/pi)/A5)*exp(-4*ln(2)*((x-A4)/A5)^2)");
+    nonl_opts.parnum = 7;
+
+    for (i=0; i<nonl_opts.parnum; i++)
+	{nonl_parms[i].value=1;}
+
+    sprintf(buf, "A0: Baseline offset\nA1, A4: Center of peaks 1, 2\nA2, A5: Full width at half maximum of peaks 1, 2\nA3, A6: Area of peaks 1, 2\n\n");
+    stufftext(buf);
+    set_actioncb( (void *) PEAK_POS1);
+    update_nonl_frame();
+}
+
+static void nonl_tripleGaussian_cb(void *data)
+{   int i;
+    nonl_opts.title   = copy_string(nonl_opts.title, "Double Gaussian function");
+    nonl_opts.formula = copy_string(nonl_opts.formula, "y = A0 + (A3*2*sqrt(ln(2)/pi)/A2)*exp(-4*ln(2)*((x-A1)/A2)^2) + (A6*2*sqrt(ln(2)/pi)/A5)*exp(-4*ln(2)*((x-A4)/A5)^2)+ (A9*2*sqrt(ln(2)/pi)/A8)*exp(-4*ln(2)*((x-A7)/A8)^2)");
+    nonl_opts.parnum = 10;
+
+    for (i=0; i<nonl_opts.parnum; i++)
+	{nonl_parms[i].value=1;}
+
+    sprintf(buf, "A0: Baseline offset\nA1, A4, A7: Center of peaks 1, 2, 3\nA2, A5, A8: Full width at half maximum of peaks 1, 2, 3\nA3, A6, A9: Area of peaks 1, 2, 3\n\n");
+    stufftext(buf);
+    set_actioncb( (void *) PEAK_POS1B);
+    update_nonl_frame();
+}
+
+static void nonl_Gaussian2_cb(void *data)
+{   int i;
+    nonl_opts.title   = copy_string(nonl_opts.title, "Gaussian (chromatography) function");
+    nonl_opts.formula = copy_string(nonl_opts.formula, "y = A0 + (1/sqrt(2*pi))*(A3/A2)*exp(-(x-A1)^2/2*A2^2)");
+    nonl_opts.parnum = 4;
+    for (i=0; i<nonl_opts.parnum; i++)
+	{nonl_parms[i].value=1;}
+    sprintf(buf, "A0: Baseline offset\nA1: Center of the peak (retention time)\nA2: Standard deviation of the peak\nA3: Peak area\n\n");
+    stufftext(buf);
+    set_actioncb( (void *) PEAK_POS);
+    update_nonl_frame();
+}
+
+static void nonl_PsVoight1_cb(void *data)
+{   int i;
+    nonl_opts.title   = copy_string(nonl_opts.title, "Pseudo Voigt 1 function");
+    nonl_opts.formula = copy_string(nonl_opts.formula, "y = A0 + A3 * (A4*(2/pi)*A2/(4*(x-A1)^2+A2^2) + (1-A4)*exp(-4*ln(2)*(x-A1)^2/A2^2)*(sqrt(4*ln(2))/(A2*sqrt(pi))))");
+    nonl_opts.parnum = 5;
+    for (i=0; i<nonl_opts.parnum-1; i++)
+	{nonl_parms[i].value=1;}
+    nonl_parms[4].value=0.5;
+    sprintf(buf, "Gaussian and Lorentzian have the same width\nA0: Baseline offset\nA1: Center of the peak\nA2: Full width at half maximum\nA3: Amplitude\nA4: Profile shape factor \n\n");
+    stufftext(buf);
+    set_actioncb( (void *) PEAK_POS);
+    update_nonl_frame();
+}
+
+static void nonl_PsVoight2_cb(void *data)
+{   int i;
+    nonl_opts.title   = copy_string(nonl_opts.title, "Pseudo Voigt 2 function");
+    nonl_opts.formula = copy_string(nonl_opts.formula, "y = A0 + A3 * (A5*(2/pi)*A2/(4*(x-A1)^2+A2^2) + (1-A5)*exp(-4*ln(2)*(x-A1)^2/A4^2)*(sqrt(4*ln(2))/(A2*sqrt(pi))))");
+    nonl_opts.parnum = 6;
+    for (i=0; i<nonl_opts.parnum-1; i++)
+	{nonl_parms[i].value=1;}
+    nonl_parms[5].value=0.5;
+    sprintf(buf, "Gaussian and Lorentzian have different width\nA0: Baseline offset\nA1: Center of the peak\nA2: Full width at half maximum (Lorentzian)\nA3: Amplitude\nA4: Full width at half maximum (Gaussian) \nA5: Profile shape factor \n\n");
+    stufftext(buf);
+    set_actioncb( (void *) PEAK_POS);
+    update_nonl_frame();
+}
+
+static void nonl_DS_cb(void *data)
+{   nonl_opts.title   = copy_string(nonl_opts.title, "Doniach-Sunjic function");
+    nonl_opts.formula = copy_string(nonl_opts.formula, "y = A0 + A3*cos((pi*A4/2)+(1-A4)*atan((x-A1)/A2))/(A2^2+(x-A1)^2)^((1-A4)/2)");
+    nonl_opts.parnum = 5;
+
+    nonl_parms[0].value=1;
+    nonl_parms[2].value=1;
+    nonl_parms[4].value=0.5;
+
+    sprintf(buf, "A0: Baseline offset\nA1: Center of the peak\nA2: Full width at half maximum\nA3: Peak area\nA4: Asymmetry parameter \n\n");
+    stufftext(buf);
+    set_actioncb( (void *) PEAK_POS);
+    update_nonl_frame();
+}
+
+static void nonl_Asym2Sig_cb(void *data)
+{   int i;
+    nonl_opts.title   = copy_string(nonl_opts.title, "Asymmetric double sigmoidal function");
+    nonl_opts.formula = copy_string(nonl_opts.formula, "y = A0 + A3*(1/(1+exp(-(x-A1+A2/2)/A4)))*(1-(1/(1+exp(-(x-A1-A2/2)/A5))))");
+    nonl_opts.parnum = 6;
+    for (i=0; i<nonl_opts.parnum; i++)
+	{nonl_parms[i].value=1;}
+    sprintf(buf, "A0: Baseline offset\nA1: Center of the peak\nA2: Width 1\nA3: Amplitude\nA4: Width 2\nA5: Width 5 \n\n");
+    stufftext(buf);
+    set_actioncb( (void *) PEAK_POS);
+    update_nonl_frame();
+}
+
+static void nonl_LogNormal_cb(void *data)
+{   int i;
+    nonl_opts.title   = copy_string(nonl_opts.title, "Log Normal Function");
+    nonl_opts.formula = copy_string(nonl_opts.formula, "y = A0 + A3*exp(-((ln(x)-ln(A1))^2)/(2*A2))");
+    nonl_opts.parnum = 4;
+    for (i=0; i<nonl_opts.parnum; i++)
+	{nonl_parms[i].value=1;}
+    sprintf(buf, "A0: Baseline offset\nA1: Center of the peak\nA2: Width\nA3: Amplitude\n\n");
+    stufftext(buf);
+    set_actioncb( (void *) PEAK_POS);
+    update_nonl_frame();
+}
+
+static void nonl_GCAS_cb(void *data)
+{   int i;
+    nonl_opts.title   = copy_string(nonl_opts.title, "Gram-Charlier A-Series");
+    nonl_opts.formula = copy_string(nonl_opts.formula, "y = A0 + A3/(A2*sqrt(2*pi))*exp(-0.5*((x-A1)/A2)^2)*(1+(A4/6)*(((x-A1)/A2)^3-3*(x-A1)/A2)+(A5/24)*(((x-A1)/A2)^4-6*((x-A1)/A2)^3+3))");
+    nonl_opts.parnum = 5;
+    for (i=0; i<nonl_opts.parnum; i++)
+	{nonl_parms[i].value=1;}
+    sprintf(buf, "A0: Baseline offset\nA1: Center of the peak\nA2: Standard deviation\nA3: Peak Area\nA4: Skew\nA5: Excess\n\n");
+    stufftext(buf);
+    set_actioncb( (void *) PEAK_POS);
+    update_nonl_frame();
+}
+
+static void nonl_ECS_cb(void *data)
+{   int i;
+    nonl_opts.title   = copy_string(nonl_opts.title, "Edgeworth-Cramer Series");
+    nonl_opts.formula = copy_string(nonl_opts.formula, "y = A0 + A3/(A2*sqrt(2*pi))*exp(-0.5*((x-A1)/A2)^2)*(1+(A4/6)*(((x-A1)/A2)^3-3*(x-A1)/A2)+(A5/24)*(((x-A1)/A2)^4-6*((x-A1)/A2)^3+3) + (A5^2/720)*(((x-A1)/A2)^6-15*((x-A1)/A2)^4+45*((x-A1)/A2)^2-15))");
+    nonl_opts.parnum = 5;
+    for (i=0; i<nonl_opts.parnum; i++)
+	{nonl_parms[i].value=1;}
+    sprintf(buf, "A0: Baseline offset\nA1: Center of the peak\nA2: Standard deviation\nA3: Peak Area\nA4: Skew\nA5: Excess\n\n");
+    stufftext(buf);
+    set_actioncb( (void *) PEAK_POS);
+    update_nonl_frame();
+}
+
+static void nonl_InvPoly_cb(void *data)
+{   int i;
+    nonl_opts.title   = copy_string(nonl_opts.title, "Inverse Polynomial Function");
+    nonl_opts.formula = copy_string(nonl_opts.formula, "y=A0+A3/(1+ A4*(2*(x-A1)/A2)^2 + A5*(2*(x-A1)/A2)^4 + A6*(2*(x-A1)/A2)^6)");
+    nonl_opts.parnum = 7;
+    for (i=0; i<nonl_opts.parnum; i++)
+	{nonl_parms[i].value=1;}
+    sprintf(buf, "A0: Baseline offset\nA1: Center of the peak\nA2: Standard deviation\nA3: Peak Area\nA4, A5, A6: Parameters\n\n");
+    stufftext(buf);
+    set_actioncb( (void *) PEAK_POS);
+    update_nonl_frame();
+}
+
+static void nonl_Sine_cb(void *data)
+{   int i;
+    nonl_opts.title   = copy_string(nonl_opts.title, "Sine Function");
+    nonl_opts.formula = copy_string(nonl_opts.formula, "y=A0+A3*sin(pi*(x-A1)/A2)");
+    nonl_opts.parnum = 4;
+    for (i=0; i<nonl_opts.parnum; i++)
+	{nonl_parms[i].value=1;}
+    sprintf(buf, "A0: Baseline offset\nA1: Center\nA2: Width\nA3: Amplitude\n\n");
+    stufftext(buf);
+    set_actioncb( (void *) PEAK_POS);
+    update_nonl_frame();
+}
+
+static void nonl_Sinesq_cb(void *data)
+{   int i;
+    nonl_opts.title   = copy_string(nonl_opts.title, "Sine Function");
+    nonl_opts.formula = copy_string(nonl_opts.formula, "y=A0+A3*(sin(pi*(x-A1)/A2))^2");
+    nonl_opts.parnum = 4;
+    for (i=0; i<nonl_opts.parnum; i++)
+	{nonl_parms[i].value=1;}
+    sprintf(buf, "A0: Baseline offset\nA1: Center\nA2: Width\nA3: Amplitude\n\n");
+    stufftext(buf);
+    set_actioncb( (void *) PEAK_POS);
+    update_nonl_frame();
+}
+
+static void nonl_Sinedamp_cb(void *data)
+{   int i;
+    nonl_opts.title   = copy_string(nonl_opts.title, "Sine Function");
+    nonl_opts.formula = copy_string(nonl_opts.formula, "y=A0+A3*exp(-x/A4)*sin(pi*(x-A1)/A2)");
+    nonl_opts.parnum = 5;
+    for (i=0; i<nonl_opts.parnum; i++)
+	{nonl_parms[i].value=1;}
+    sprintf(buf, "A0: Baseline offset\nA1: Center\nA2: Width\nA3: Amplitude\nA4: Decay time\n\n");
+    stufftext(buf);
+    set_actioncb( (void *) PEAK_POS);
+    update_nonl_frame();
+}
+
+static void nonl_ExpDec1_cb(void *data)
+{   int i;
+    nonl_opts.title   = copy_string(nonl_opts.title, "Exponential Decay 1");
+    nonl_opts.formula = copy_string(nonl_opts.formula, "y=A0+A3*exp(-(x-A1)/A2)");
+    nonl_opts.parnum = 4;
+    for (i=0; i<nonl_opts.parnum; i++)
+	{nonl_parms[i].value=1;}
+    update_nonl_frame();
+}
+
+static void nonl_ExpDec2_cb(void *data)
+{   int i;
+    nonl_opts.title   = copy_string(nonl_opts.title, "Exponential Decay 2");
+    nonl_opts.formula = copy_string(nonl_opts.formula, "y=A0+A3*exp(-(x-A1)/A2)+A6*exp(-(x-A4)/A5)");
+    nonl_opts.parnum = 7;
+    for (i=0; i<nonl_opts.parnum; i++)
+	{nonl_parms[i].value=1;}
+    update_nonl_frame();
+}
+
+static void nonl_ExpGrow1_cb(void *data)
+{   int i;
+    nonl_opts.title   = copy_string(nonl_opts.title, "Exponential Growth 1");
+    nonl_opts.formula = copy_string(nonl_opts.formula, "y=A0+A3*exp((x-A1)/A2)");
+    nonl_opts.parnum = 4;
+    for (i=0; i<nonl_opts.parnum; i++)
+	{nonl_parms[i].value=1;}
+    update_nonl_frame();
+}
+
+static void nonl_ExpGrow2_cb(void *data)
+{   int i;
+    nonl_opts.title   = copy_string(nonl_opts.title, "Exponential Growth 2");
+    nonl_opts.formula = copy_string(nonl_opts.formula, "y=A0+A3*exp((x-A1)/A2)+A6*exp((x-A4)/A5)");
+    nonl_opts.parnum = 7;
+    for (i=0; i<nonl_opts.parnum; i++)
+	{nonl_parms[i].value=1;}
+    update_nonl_frame();
+}
+
+static void nonl_Hyperbol_cb(void *data)
+{   int i;
+    nonl_opts.title   = copy_string(nonl_opts.title, "Hyperbolic");
+    nonl_opts.formula = copy_string(nonl_opts.formula, "y=A0+(A1*x)/(A2+x)");
+    nonl_opts.parnum = 3;
+    for (i=0; i<nonl_opts.parnum; i++)
+	{nonl_parms[i].value=1;}
+    update_nonl_frame();
+}
+
+static void nonl_Bradley_cb(void *data)
+{   int i;
+    nonl_opts.title   = copy_string(nonl_opts.title, "Bradley");
+    nonl_opts.formula = copy_string(nonl_opts.formula, "y=A0*ln(-A1*ln(x))");
+    nonl_opts.parnum = 2;
+    for (i=0; i<nonl_opts.parnum; i++)
+	{nonl_parms[i].value=1;}
+    update_nonl_frame();
+}
+
+static void nonl_Log3_cb(void *data)
+{   int i;
+    nonl_opts.title   = copy_string(nonl_opts.title, "Logarithm 3");
+    nonl_opts.formula = copy_string(nonl_opts.formula, "y=A0-A1*ln(x+A2)");
+    nonl_opts.parnum = 3;
+    for (i=0; i<nonl_opts.parnum; i++)
+	{nonl_parms[i].value=1;}
+    update_nonl_frame();
+}
+
+static void nonl_WeibullPD_cb(void *data)
+{   int i;
+    nonl_opts.title   = copy_string(nonl_opts.title, "Weibull Probability Density");
+    nonl_opts.formula = copy_string(nonl_opts.formula, "y=(A0/A1)*((x/A1)^(A0-1))*exp(-(x/A1)^A0)");
+    nonl_opts.parnum = 2;
+    for (i=0; i<nonl_opts.parnum; i++)
+	{nonl_parms[i].value=1;}
+    update_nonl_frame();
+}
+
+static void nonl_WeibullCD_cb(void *data)
+{   int i;
+    nonl_opts.title   = copy_string(nonl_opts.title, "Weibull Cumulative Distribution");
+    nonl_opts.formula = copy_string(nonl_opts.formula, "y=1-exp(-(x/A1)^A0)");
+    nonl_opts.parnum = 2;
+    for (i=0; i<nonl_opts.parnum; i++)
+	{nonl_parms[i].value=1;}
+    update_nonl_frame();
+}