{"action":"created","comment":{"url":"https://api.github.com/repos/biosustain/OpenMS/pulls/comments/153633975","pull_request_review_id":79669091,"id":153633975,"diff_hunk":"@@ -53,18 +53,99 @@ namespace OpenMS\n   {\n     const double intensity_l = chromatogram.RTBegin(left)->getIntensity();\n     const double intensity_r = (chromatogram.RTEnd(right)-1)->getIntensity();\n-    const double delta_int = intensity_r - intensity_l; // sign will determine line direction\n-    const double delta_input_rt = right - left;\n+    const double delta_int = intensity_r - intensity_l;\n     double background = 0.0;\n-    for (auto it=chromatogram.RTBegin(left); it!=chromatogram.RTEnd(right); ++it)\n+    if (integration_type_ == \"trapezoid\" || integration_type_ == \"simpson\")\n     {\n-      // calculate the background using the formula\n-      // y = mx + b where x = retention time, m = slope, b = left intensity\n-      background += delta_int / delta_input_rt * (it->getRT() - left) + intensity_l;\n+      const double intensity_min = std::min(intensity_r, intensity_l);\n+      const double delta_int_abs = std::fabs(delta_int);\n+      for (auto it=chromatogram.RTBegin(left); it<chromatogram.RTEnd(right)-1; ++it)\n+      {\n+        const double delta_rt = (it+1)->getRT() - it->getRT();\n+        background += intensity_min * delta_rt + 0.5 * delta_int_abs * delta_rt;\n+      }\n+    }\n+    else\n+    {\n+      const double delta_input_rt = right - left;\n+      for (auto it=chromatogram.RTBegin(left); it!=chromatogram.RTEnd(right); ++it)\n+      {\n+        // calculate the background using the formula\n+        // y = mx + b where x = retention time, m = slope, b = left intensity\n+        // sign of delta_int will determine line direction\n+        background += delta_int / delta_input_rt * (it->getRT() - left) + intensity_l;\n+      }\n     }\n     return background;\n   }\n \n+  void PeakIntegrator::integratePeak(\n+    const MSChromatogram& chromatogram,\n+    const double& left,\n+    const double& right,\n+    double& peak_area,\n+    double& peak_height,\n+    double& peak_apex_pos\n+  )\n+  {\n+    peak_area = 0.0;\n+    peak_height = -1.0;\n+    peak_apex_pos = -1.0;\n+    UInt n_points = 0;\n+    for (auto it=chromatogram.RTBegin(left); it!=chromatogram.RTEnd(right); ++it, ++n_points)\n+      ;\n+\n+    if (getIntegrationType() == \"trapezoid\")\n+    {\n+      for (auto it=chromatogram.RTBegin(left); it!=chromatogram.RTEnd(right)-1; ++it)\n+      {\n+        peak_area += ((it+1)->getRT() - it->getRT()) * ((it->getIntensity() + (it+1)->getIntensity()) / 2.0);\n+        if (peak_height < it->getIntensity())\n+        {\n+          peak_height = it->getIntensity();\n+          peak_apex_pos = it->getRT();\n+        }\n+      }\n+    }\n+    else if (getIntegrationType() == \"simpson\")\n+    {\n+      if (n_points < 3 || !(n_points % 2))","path":"src/openms/source/ANALYSIS/OPENSWATH/PeakIntegrator.cpp","position":null,"original_position":66,"commit_id":"ce25fc506d86af55db8fa96ff49969ed5dc9ec9f","original_commit_id":"ce25fc506d86af55db8fa96ff49969ed5dc9ec9f","user":{"login":"dmccloskey","id":5378614,"avatar_url":"https://avatars1.githubusercontent.com/u/5378614?v=4","gravatar_id":"","url":"https://api.github.com/users/dmccloskey","html_url":"https://github.com/dmccloskey","followers_url":"https://api.github.com/users/dmccloskey/followers","following_url":"https://api.github.com/users/dmccloskey/following{/other_user}","gists_url":"https://api.github.com/users/dmccloskey/gists{/gist_id}","starred_url":"https://api.github.com/users/dmccloskey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmccloskey/subscriptions","organizations_url":"https://api.github.com/users/dmccloskey/orgs","repos_url":"https://api.github.com/users/dmccloskey/repos","events_url":"https://api.github.com/users/dmccloskey/events{/privacy}","received_events_url":"https://api.github.com/users/dmccloskey/received_events","type":"User","site_admin":false},"body":"I can see this part of the if clause causing a lot of headache: `!(n_points % 2)`.  Would it be possible for the case that n_points is even to calculate the peak area with 1) 1 additional point on the right and 2) with 1 less point on the right and then 3) take the average to approximate what the area is?","created_at":"2017-11-28T21:50:57Z","updated_at":"2017-11-28T21:50:58Z","html_url":"https://github.com/biosustain/OpenMS/pull/58#discussion_r153633975","pull_request_url":"https://api.github.com/repos/biosustain/OpenMS/pulls/58","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/biosustain/OpenMS/pulls/comments/153633975"},"html":{"href":"https://github.com/biosustain/OpenMS/pull/58#discussion_r153633975"},"pull_request":{"href":"https://api.github.com/repos/biosustain/OpenMS/pulls/58"}}},"pull_request":{"url":"https://api.github.com/repos/biosustain/OpenMS/pulls/58","id":154517482,"html_url":"https://github.com/biosustain/OpenMS/pull/58","diff_url":"https://github.com/biosustain/OpenMS/pull/58.diff","patch_url":"https://github.com/biosustain/OpenMS/pull/58.patch","issue_url":"https://api.github.com/repos/biosustain/OpenMS/issues/58","number":58,"state":"open","locked":false,"title":"feat: implement estimateBackground() 1st version","user":{"login":"pasqoo","id":1009863,"avatar_url":"https://avatars2.githubusercontent.com/u/1009863?v=4","gravatar_id":"","url":"https://api.github.com/users/pasqoo","html_url":"https://github.com/pasqoo","followers_url":"https://api.github.com/users/pasqoo/followers","following_url":"https://api.github.com/users/pasqoo/following{/other_user}","gists_url":"https://api.github.com/users/pasqoo/gists{/gist_id}","starred_url":"https://api.github.com/users/pasqoo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pasqoo/subscriptions","organizations_url":"https://api.github.com/users/pasqoo/orgs","repos_url":"https://api.github.com/users/pasqoo/repos","events_url":"https://api.github.com/users/pasqoo/events{/privacy}","received_events_url":"https://api.github.com/users/pasqoo/received_events","type":"User","site_admin":false},"body":"closes #52 \r\n\r\nNot a final version, but it works. `baseline_type_` feature is missing. Need to talk about it with you to clarify its behaviour.\r\n\r\nI will implement `MSSpectrum` support in all methods at the end, when the three methods are all implemented for `MSChromatogram`s.\r\n\r\n","created_at":"2017-11-24T10:34:33Z","updated_at":"2017-11-28T21:50:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6ffe10fc4f63f73f8c1b3c090958adef07c9ed8d","assignee":{"login":"pasqoo","id":1009863,"avatar_url":"https://avatars2.githubusercontent.com/u/1009863?v=4","gravatar_id":"","url":"https://api.github.com/users/pasqoo","html_url":"https://github.com/pasqoo","followers_url":"https://api.github.com/users/pasqoo/followers","following_url":"https://api.github.com/users/pasqoo/following{/other_user}","gists_url":"https://api.github.com/users/pasqoo/gists{/gist_id}","starred_url":"https://api.github.com/users/pasqoo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pasqoo/subscriptions","organizations_url":"https://api.github.com/users/pasqoo/orgs","repos_url":"https://api.github.com/users/pasqoo/repos","events_url":"https://api.github.com/users/pasqoo/events{/privacy}","received_events_url":"https://api.github.com/users/pasqoo/received_events","type":"User","site_admin":false},"assignees":[{"login":"pasqoo","id":1009863,"avatar_url":"https://avatars2.githubusercontent.com/u/1009863?v=4","gravatar_id":"","url":"https://api.github.com/users/pasqoo","html_url":"https://github.com/pasqoo","followers_url":"https://api.github.com/users/pasqoo/followers","following_url":"https://api.github.com/users/pasqoo/following{/other_user}","gists_url":"https://api.github.com/users/pasqoo/gists{/gist_id}","starred_url":"https://api.github.com/users/pasqoo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pasqoo/subscriptions","organizations_url":"https://api.github.com/users/pasqoo/orgs","repos_url":"https://api.github.com/users/pasqoo/repos","events_url":"https://api.github.com/users/pasqoo/events{/privacy}","received_events_url":"https://api.github.com/users/pasqoo/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/biosustain/OpenMS/pulls/58/commits","review_comments_url":"https://api.github.com/repos/biosustain/OpenMS/pulls/58/comments","review_comment_url":"https://api.github.com/repos/biosustain/OpenMS/pulls/comments{/number}","comments_url":"https://api.github.com/repos/biosustain/OpenMS/issues/58/comments","statuses_url":"https://api.github.com/repos/biosustain/OpenMS/statuses/ce25fc506d86af55db8fa96ff49969ed5dc9ec9f","head":{"label":"biosustain:feature/PeakIntegrator_estimateBackground","ref":"feature/PeakIntegrator_estimateBackground","sha":"ce25fc506d86af55db8fa96ff49969ed5dc9ec9f","user":{"login":"biosustain","id":5499849,"avatar_url":"https://avatars3.githubusercontent.com/u/5499849?v=4","gravatar_id":"","url":"https://api.github.com/users/biosustain","html_url":"https://github.com/biosustain","followers_url":"https://api.github.com/users/biosustain/followers","following_url":"https://api.github.com/users/biosustain/following{/other_user}","gists_url":"https://api.github.com/users/biosustain/gists{/gist_id}","starred_url":"https://api.github.com/users/biosustain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/biosustain/subscriptions","organizations_url":"https://api.github.com/users/biosustain/orgs","repos_url":"https://api.github.com/users/biosustain/repos","events_url":"https://api.github.com/users/biosustain/events{/privacy}","received_events_url":"https://api.github.com/users/biosustain/received_events","type":"Organization","site_admin":false},"repo":{"id":101999003,"name":"OpenMS","full_name":"biosustain/OpenMS","owner":{"login":"biosustain","id":5499849,"avatar_url":"https://avatars3.githubusercontent.com/u/5499849?v=4","gravatar_id":"","url":"https://api.github.com/users/biosustain","html_url":"https://github.com/biosustain","followers_url":"https://api.github.com/users/biosustain/followers","following_url":"https://api.github.com/users/biosustain/following{/other_user}","gists_url":"https://api.github.com/users/biosustain/gists{/gist_id}","starred_url":"https://api.github.com/users/biosustain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/biosustain/subscriptions","organizations_url":"https://api.github.com/users/biosustain/orgs","repos_url":"https://api.github.com/users/biosustain/repos","events_url":"https://api.github.com/users/biosustain/events{/privacy}","received_events_url":"https://api.github.com/users/biosustain/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/biosustain/OpenMS","description":"The codebase of the OpenMS project","fork":true,"url":"https://api.github.com/repos/biosustain/OpenMS","forks_url":"https://api.github.com/repos/biosustain/OpenMS/forks","keys_url":"https://api.github.com/repos/biosustain/OpenMS/keys{/key_id}","collaborators_url":"https://api.github.com/repos/biosustain/OpenMS/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/biosustain/OpenMS/teams","hooks_url":"https://api.github.com/repos/biosustain/OpenMS/hooks","issue_events_url":"https://api.github.com/repos/biosustain/OpenMS/issues/events{/number}","events_url":"https://api.github.com/repos/biosustain/OpenMS/events","assignees_url":"https://api.github.com/repos/biosustain/OpenMS/assignees{/user}","branches_url":"https://api.github.com/repos/biosustain/OpenMS/branches{/branch}","tags_url":"https://api.github.com/repos/biosustain/OpenMS/tags","blobs_url":"https://api.github.com/repos/biosustain/OpenMS/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/biosustain/OpenMS/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/biosustain/OpenMS/git/refs{/sha}","trees_url":"https://api.github.com/repos/biosustain/OpenMS/git/trees{/sha}","statuses_url":"https://api.github.com/repos/biosustain/OpenMS/statuses/{sha}","languages_url":"https://api.github.com/repos/biosustain/OpenMS/languages","stargazers_url":"https://api.github.com/repos/biosustain/OpenMS/stargazers","contributors_url":"https://api.github.com/repos/biosustain/OpenMS/contributors","subscribers_url":"https://api.github.com/repos/biosustain/OpenMS/subscribers","subscription_url":"https://api.github.com/repos/biosustain/OpenMS/subscription","commits_url":"https://api.github.com/repos/biosustain/OpenMS/commits{/sha}","git_commits_url":"https://api.github.com/repos/biosustain/OpenMS/git/commits{/sha}","comments_url":"https://api.github.com/repos/biosustain/OpenMS/comments{/number}","issue_comment_url":"https://api.github.com/repos/biosustain/OpenMS/issues/comments{/number}","contents_url":"https://api.github.com/repos/biosustain/OpenMS/contents/{+path}","compare_url":"https://api.github.com/repos/biosustain/OpenMS/compare/{base}...{head}","merges_url":"https://api.github.com/repos/biosustain/OpenMS/merges","archive_url":"https://api.github.com/repos/biosustain/OpenMS/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/biosustain/OpenMS/downloads","issues_url":"https://api.github.com/repos/biosustain/OpenMS/issues{/number}","pulls_url":"https://api.github.com/repos/biosustain/OpenMS/pulls{/number}","milestones_url":"https://api.github.com/repos/biosustain/OpenMS/milestones{/number}","notifications_url":"https://api.github.com/repos/biosustain/OpenMS/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/biosustain/OpenMS/labels{/name}","releases_url":"https://api.github.com/repos/biosustain/OpenMS/releases{/id}","deployments_url":"https://api.github.com/repos/biosustain/OpenMS/deployments","created_at":"2017-08-31T12:35:49Z","updated_at":"2017-08-31T12:36:21Z","pushed_at":"2017-11-28T19:04:26Z","git_url":"git://github.com/biosustain/OpenMS.git","ssh_url":"git@github.com:biosustain/OpenMS.git","clone_url":"https://github.com/biosustain/OpenMS.git","svn_url":"https://github.com/biosustain/OpenMS","homepage":"https://www.openms.de","size":255883,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":11,"license":null,"forks":0,"open_issues":11,"watchers":0,"default_branch":"develop"}},"base":{"label":"biosustain:feature/PeakIntegrator","ref":"feature/PeakIntegrator","sha":"feade87666583e98215a4f9b3a5e2de94f41d8df","user":{"login":"biosustain","id":5499849,"avatar_url":"https://avatars3.githubusercontent.com/u/5499849?v=4","gravatar_id":"","url":"https://api.github.com/users/biosustain","html_url":"https://github.com/biosustain","followers_url":"https://api.github.com/users/biosustain/followers","following_url":"https://api.github.com/users/biosustain/following{/other_user}","gists_url":"https://api.github.com/users/biosustain/gists{/gist_id}","starred_url":"https://api.github.com/users/biosustain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/biosustain/subscriptions","organizations_url":"https://api.github.com/users/biosustain/orgs","repos_url":"https://api.github.com/users/biosustain/repos","events_url":"https://api.github.com/users/biosustain/events{/privacy}","received_events_url":"https://api.github.com/users/biosustain/received_events","type":"Organization","site_admin":false},"repo":{"id":101999003,"name":"OpenMS","full_name":"biosustain/OpenMS","owner":{"login":"biosustain","id":5499849,"avatar_url":"https://avatars3.githubusercontent.com/u/5499849?v=4","gravatar_id":"","url":"https://api.github.com/users/biosustain","html_url":"https://github.com/biosustain","followers_url":"https://api.github.com/users/biosustain/followers","following_url":"https://api.github.com/users/biosustain/following{/other_user}","gists_url":"https://api.github.com/users/biosustain/gists{/gist_id}","starred_url":"https://api.github.com/users/biosustain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/biosustain/subscriptions","organizations_url":"https://api.github.com/users/biosustain/orgs","repos_url":"https://api.github.com/users/biosustain/repos","events_url":"https://api.github.com/users/biosustain/events{/privacy}","received_events_url":"https://api.github.com/users/biosustain/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/biosustain/OpenMS","description":"The codebase of the OpenMS project","fork":true,"url":"https://api.github.com/repos/biosustain/OpenMS","forks_url":"https://api.github.com/repos/biosustain/OpenMS/forks","keys_url":"https://api.github.com/repos/biosustain/OpenMS/keys{/key_id}","collaborators_url":"https://api.github.com/repos/biosustain/OpenMS/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/biosustain/OpenMS/teams","hooks_url":"https://api.github.com/repos/biosustain/OpenMS/hooks","issue_events_url":"https://api.github.com/repos/biosustain/OpenMS/issues/events{/number}","events_url":"https://api.github.com/repos/biosustain/OpenMS/events","assignees_url":"https://api.github.com/repos/biosustain/OpenMS/assignees{/user}","branches_url":"https://api.github.com/repos/biosustain/OpenMS/branches{/branch}","tags_url":"https://api.github.com/repos/biosustain/OpenMS/tags","blobs_url":"https://api.github.com/repos/biosustain/OpenMS/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/biosustain/OpenMS/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/biosustain/OpenMS/git/refs{/sha}","trees_url":"https://api.github.com/repos/biosustain/OpenMS/git/trees{/sha}","statuses_url":"https://api.github.com/repos/biosustain/OpenMS/statuses/{sha}","languages_url":"https://api.github.com/repos/biosustain/OpenMS/languages","stargazers_url":"https://api.github.com/repos/biosustain/OpenMS/stargazers","contributors_url":"https://api.github.com/repos/biosustain/OpenMS/contributors","subscribers_url":"https://api.github.com/repos/biosustain/OpenMS/subscribers","subscription_url":"https://api.github.com/repos/biosustain/OpenMS/subscription","commits_url":"https://api.github.com/repos/biosustain/OpenMS/commits{/sha}","git_commits_url":"https://api.github.com/repos/biosustain/OpenMS/git/commits{/sha}","comments_url":"https://api.github.com/repos/biosustain/OpenMS/comments{/number}","issue_comment_url":"https://api.github.com/repos/biosustain/OpenMS/issues/comments{/number}","contents_url":"https://api.github.com/repos/biosustain/OpenMS/contents/{+path}","compare_url":"https://api.github.com/repos/biosustain/OpenMS/compare/{base}...{head}","merges_url":"https://api.github.com/repos/biosustain/OpenMS/merges","archive_url":"https://api.github.com/repos/biosustain/OpenMS/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/biosustain/OpenMS/downloads","issues_url":"https://api.github.com/repos/biosustain/OpenMS/issues{/number}","pulls_url":"https://api.github.com/repos/biosustain/OpenMS/pulls{/number}","milestones_url":"https://api.github.com/repos/biosustain/OpenMS/milestones{/number}","notifications_url":"https://api.github.com/repos/biosustain/OpenMS/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/biosustain/OpenMS/labels{/name}","releases_url":"https://api.github.com/repos/biosustain/OpenMS/releases{/id}","deployments_url":"https://api.github.com/repos/biosustain/OpenMS/deployments","created_at":"2017-08-31T12:35:49Z","updated_at":"2017-08-31T12:36:21Z","pushed_at":"2017-11-28T19:04:26Z","git_url":"git://github.com/biosustain/OpenMS.git","ssh_url":"git@github.com:biosustain/OpenMS.git","clone_url":"https://github.com/biosustain/OpenMS.git","svn_url":"https://github.com/biosustain/OpenMS","homepage":"https://www.openms.de","size":255883,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":11,"license":null,"forks":0,"open_issues":11,"watchers":0,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/biosustain/OpenMS/pulls/58"},"html":{"href":"https://github.com/biosustain/OpenMS/pull/58"},"issue":{"href":"https://api.github.com/repos/biosustain/OpenMS/issues/58"},"comments":{"href":"https://api.github.com/repos/biosustain/OpenMS/issues/58/comments"},"review_comments":{"href":"https://api.github.com/repos/biosustain/OpenMS/pulls/58/comments"},"review_comment":{"href":"https://api.github.com/repos/biosustain/OpenMS/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/biosustain/OpenMS/pulls/58/commits"},"statuses":{"href":"https://api.github.com/repos/biosustain/OpenMS/statuses/ce25fc506d86af55db8fa96ff49969ed5dc9ec9f"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"dmccloskey"}}