{"id":2856,"date":"2015-05-18T12:03:33","date_gmt":"2015-05-18T16:03:33","guid":{"rendered":"http:\/\/blog.originlab.com\/?p=2856"},"modified":"2018-12-05T03:41:27","modified_gmt":"2018-12-05T08:41:27","slug":"how-to-define-a-peak-function-for-peak-fitting","status":"publish","type":"post","link":"https:\/\/blog.originlab.com\/ja\/how-to-define-a-peak-function-for-peak-fitting","title":{"rendered":"Define a Peak Function for Peak Fitting"},"content":{"rendered":"<p>In Origin, defining a peak function is very similar to defining\u00a0an user-defined fitting function, but with two additional requirements to be met:<\/p>\n<p>1. The defined peak function should be placed into\u00a0<strong>PFW\u00a0<\/strong>category and the\u00a0<strong>Peak Function\u00a0<\/strong>check box on <a href=\"http:\/\/www.originlab.com\/doc\/Origin-Help\/FitFuncBuilder-Var-Para\">The Variable and Parameter Page<\/a>\u00a0\u00a0should be checked.<\/p>\n<p>2. There should be at least four parameters in the defined peak function, that correspond to different peak characteristics, and assigned as attributes\u00a0<strong>Offset\/Baseline<\/strong>, <b>Amplitude\/Area<\/b>,\u00a0<strong>X Width<\/strong>,\u00a0<strong>X Center<\/strong>. And the first parameter must be named <strong>y0<\/strong>\u00a0(Offset).<\/p>\n<p><a href=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/05\/User_Defined_Peak_Function_Feature_Image.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2875\" src=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/05\/User_Defined_Peak_Function_Feature_Image.png\" alt=\"User_Defined_Peak_Function_Feature_Image\" width=\"583\" height=\"449\" srcset=\"https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/05\/User_Defined_Peak_Function_Feature_Image.png 583w, https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/05\/User_Defined_Peak_Function_Feature_Image-300x231.png 300w\" sizes=\"auto, (max-width: 583px) 100vw, 583px\" \/><\/a><\/p>\n<p>We have put together an Origin Project (OPJ)\u00a0<a href=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/05\/User_Defined_Peak_Function.zip\">User_Defined_Peak_Function<\/a>.zip\u00a0(5.8KB), you can download this OPJ file to learn how to defined a peak function and fit with\u00a0it.<\/p>\n<p>In this blog post we will discuss how to:<\/p>\n<ul>\n<li>Define a peak function<\/li>\n<li>Use defined peak function to fit peaks in\u00a0<strong>Peak Analyzer<\/strong><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h4><span style=\"color: #0000ff;\">Define a Peak Function<\/span><\/h4>\n<p>The peak function to be defined is expressed as below:<\/p>\n<p><em>y = y0 \u00a0+ \u00a0A * exp(w\/xc-w\/x-(x\/xc)^2*exp(-(w\/x-w\/xc)));<\/em><\/p>\n<p>where\u00a0<strong><em>x\u00a0<\/em><\/strong>is independent variable, <em><strong>y<\/strong><\/em> is dependent variable and parameters are as following:<\/p>\n<p><strong><em>y0<\/em><\/strong>: Offset\/Baseline<\/p>\n<p><em><strong>A<\/strong><\/em>: Peak Amplitude<\/p>\n<p><em><strong>w<\/strong><\/em>: Peak Width<\/p>\n<p><em><strong>xc<\/strong><\/em>: Peak Center<\/p>\n<p>&nbsp;<\/p>\n<p>There are general 6 steps in defining a peak function:<\/p>\n<p>1. Hit\u00a0<strong>F8<\/strong>\u00a0key or go to menu\u00a0<strong>Tools: Fitting Function Builder\u00a0<\/strong>to open\u00a0<a href=\"http:\/\/www.originlab.com\/doc\/Origin-Help\/FitFunc-Builder\">Fitting Function Builder<\/a>.<\/p>\n<p>2. Click\u00a0<strong>Next\u00a0<\/strong>to go to\u00a0<strong>Name and Type\u00a0<\/strong>page, select\u00a0<span style=\"color: #008000;\"><strong>PFW<\/strong><\/span>\u00a0category from\u00a0<strong>Select or create a Category\u00a0<\/strong>drop-down list, input <i>MyPeakFunc\u00a0as\u00a0<strong>Function name.<\/strong><\/i><\/p>\n<p>3. Click\u00a0<strong>Next\u00a0<\/strong>to go to\u00a0<strong>Variables and Parameters\u00a0<\/strong>page, input\u00a0variables and parameters as shown below and check<span style=\"color: #008000;\">\u00a0<\/span><strong><span style=\"color: #008000;\">Peak Function<\/span>\u00a0<\/strong>check box:<\/p>\n<p><a href=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/05\/User_Defined_Peak_Function_02.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2865\" src=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/05\/User_Defined_Peak_Function_02.png\" alt=\"User_Defined_Peak_Function_02\" width=\"788\" height=\"464\" srcset=\"https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/05\/User_Defined_Peak_Function_02.png 788w, https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/05\/User_Defined_Peak_Function_02-300x177.png 300w\" sizes=\"auto, (max-width: 788px) 100vw, 788px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>4. Click\u00a0<strong>Next\u00a0<\/strong>to go to\u00a0<strong>Expression Function\u00a0<\/strong>page. Click on each cell in <strong>Peak Attribute<\/strong> column to set\u00a0peak attributes for each parameter. Enter initial parameter values. Enter function expression in\u00a0<strong>Function Body\u00a0<\/strong>edit box and do a quick check at\u00a0<em>x = 100 <\/em>to make sure the expression is written correctly as shown below:<\/p>\n<p><a href=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/05\/User_Defined_Peak_Function_03.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2866\" src=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/05\/User_Defined_Peak_Function_03.png\" alt=\"User_Defined_Peak_Function_03\" width=\"788\" height=\"464\" srcset=\"https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/05\/User_Defined_Peak_Function_03.png 788w, https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/05\/User_Defined_Peak_Function_03-300x177.png 300w\" sizes=\"auto, (max-width: 788px) 100vw, 788px\" \/><\/a><\/p>\n<p>5. Click\u00a0<strong>Next\u00a0<\/strong>button twice to go to\u00a0<strong>Bounds and General Linear Constraints\u00a0<\/strong>page. Double click in cells in <strong>&lt; or &lt;=<\/strong> column(s) to toggle operators and then enter lower and upper bounds. Setting\u00a0bounds for each parameter will confine the fitted results in sensible range as show below:<\/p>\n<p><a href=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/05\/User_Defined_Peak_Function_04.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2867\" src=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/05\/User_Defined_Peak_Function_04.png\" alt=\"User_Defined_Peak_Function_04\" width=\"788\" height=\"464\" srcset=\"https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/05\/User_Defined_Peak_Function_04.png 788w, https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/05\/User_Defined_Peak_Function_04-300x177.png 300w\" sizes=\"auto, (max-width: 788px) 100vw, 788px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>6. Click <strong>Finish <\/strong>button and the peak function is created and placed in\u00a0<strong>PFW <\/strong>category.<\/p>\n<p>&nbsp;<\/p>\n<p><strong><span style=\"color: #008000;\">Tip:\u00a0<\/span><\/strong><span style=\"color: #008000;\"><span style=\"color: #000000;\">If you want to make existing fitting functions available for peak fitting, choose <strong>Tools: Fitting Function Organizer<\/strong>. Right click the function and choose\u00a0<strong>Move to\u00a0<\/strong>or\u00a0<strong>Share to\u00a0<\/strong>and select <b>PFW\u00a0<\/b>as the drop-down list option in appeared dialog.<\/span><\/span><\/p>\n<p>&nbsp;<\/p>\n<h4><span style=\"color: #0000ff;\">Use Defined Peak Function to Fit Peaks in Peak Analyzer<\/span><\/h4>\n<p>Once you have defined your peak function and it is placed in\u00a0<strong>PFW\u00a0<\/strong>fitting function category, it is ready to be used for peak fitting. Now open User_Defined_Peak_Function.opj in zip file mentioned earlier, highlight column <em>Amplitude\u00a0<\/em>\u00a0(<strong>Long Name\u00a0<\/strong>) and go to menu\u00a0<strong>Analysis: Peaks and Baseline: Peak Analyzer\u00a0<\/strong>to open the wizard.<\/p>\n<p>To fit peaks using\u00a0<strong>Peak Analyzer<\/strong>, it generally involves 5 steps below:<\/p>\n<p>1. Select\u00a0<strong>Fit Peaks(Pro)\u00a0<\/strong>as\u00a0<strong>Goal<\/strong> and click\u00a0<strong>Next\u00a0<\/strong>button 3 times to go to\u00a0<strong>Find Peaks\u00a0<\/strong>page.<\/p>\n<p>2. Click\u00a0<strong>Find\u00a0<\/strong>button and three peaks are found. We need to remove\u00a0<em>x=120\u00a0<\/em>peak since it is redundant. To do it uncheck <strong>Enable Auto Find <\/strong>checkbox and click\u00a0<strong>Modify\/Del\u00a0<\/strong>button and hit\u00a0<strong>Delete\u00a0<\/strong>key in keyboard to remove that\u00a0<em>x=120\u00a0<\/em>peak. Then click\u00a0<strong>Done\u00a0<\/strong>to close dialog.<\/p>\n<p>3. Click\u00a0<strong>Next\u00a0<\/strong>button and you will find the peaks are automatically fitted (using Gaussian function by default), so we have to switch to our newly created peak function. To do so, click\u00a0<strong>Fit Control\u00a0<\/strong>button to bring up\u00a0<strong>Peak Fit Parameters\u00a0<\/strong>dialog.<\/p>\n<p>4. Select <b>MyPeakFunc (User)\u00a0<\/b>from the drop-down list in middle left and the\u00a0<strong>Peak Type\u00a0<\/strong>in upper panel will automatically switch accordingly. Now click\u00a0<strong>Fit Till Converge\u00a0<\/strong>button to make the fitting and click\u00a0<strong>OK\u00a0<\/strong>to close the dialog. <span style=\"color: #ff0000;\">Note<\/span>: To change peak function for a single peak, you can also click the corresponding function in <strong>Peak Type<\/strong> column and change it.<\/p>\n<p><a href=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/05\/User_Defined_Peak_Function_05.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2870\" src=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/05\/User_Defined_Peak_Function_05.png\" alt=\"User_Defined_Peak_Function_05\" width=\"712\" height=\"696\" srcset=\"https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/05\/User_Defined_Peak_Function_05.png 712w, https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/05\/User_Defined_Peak_Function_05-300x293.png 300w\" sizes=\"auto, (max-width: 712px) 100vw, 712px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>5. Click\u00a0<strong>Finish\u00a0<\/strong>button will output fitted results into a report.<\/p>\n<p>&nbsp;<\/p>","protected":false},"excerpt":{"rendered":"<p>In Origin, defining a peak function is very similar to &hellip; <\/p>","protected":false},"author":24,"featured_media":2875,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[4],"tags":[],"class_list":["post-2856","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-data-analysis"],"jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p7DvU2-K4","jetpack_likes_enabled":true,"jetpack_featured_media_url":"https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/05\/User_Defined_Peak_Function_Feature_Image.png","post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/posts\/2856","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/users\/24"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/comments?post=2856"}],"version-history":[{"count":23,"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/posts\/2856\/revisions"}],"predecessor-version":[{"id":10158,"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/posts\/2856\/revisions\/10158"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/media\/2875"}],"wp:attachment":[{"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/media?parent=2856"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/categories?post=2856"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/tags?post=2856"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}