{"action":"created","comment":{"url":"https://api.github.com/repos/Vages/HAR-Pipeline/pulls/comments/84149414","pull_request_review_id":4945082,"id":84149414,"diff_hunk":"@@ -0,0 +1,287 @@\n+# coding: utf-8\n+from __future__ import division, print_function\n+\n+import glob\n+from time import time\n+\n+import pandas as pd\n+\n+from external_modules.detect_peaks import detect_peaks\n+from tools.pandas_helpers import add_to_column_in_data_frame, subtract_from_column_in_data_frame, \\\n+    write_selected_columns_to_file\n+\n+\n+def create_synchronized_back_and_thigh_file_for_subject(folder, s_id):\n+    import subprocess\n+\n+    omconvert = \"./private_data/conversion_scripts/omconvert/omconvert\"\n+    timesync = \"./private_data/conversion_scripts/timesync/timesync\"\n+\n+    back_cwa = glob.glob(folder + \"/*_BACK_*\" + s_id + \".cwa\")[0]\n+    thigh_cwa = glob.glob(folder + \"/*_THIGH_*\" + s_id + \".cwa\")[0]\n+\n+    back_wav = folder + '/' + s_id + \"_back.wav\"\n+    thigh_wav = folder + '/' + s_id + \"_thigh.wav\"\n+\n+    synchronized_csv = folder + '/' + s_id + \"_thigh.resampled.csv\"\n+\n+    # Create wav and CSV for back sensor\n+    subprocess.call([omconvert, back_cwa, \"-out\", back_wav, \"-csv-file\", folder + '/' + s_id + \"_back.csv\"])\n+\n+    # Create wav for thigh sensor\n+    subprocess.call([omconvert, thigh_cwa, \"-out\", thigh_wav])\n+\n+    # Synchronize them and make them a CSV\n+    subprocess.call([timesync, back_wav, thigh_wav, \"-csv\", synchronized_csv])\n+\n+\n+def find_claps_from_peaks(peak_array, required_claps=3, sampling_frequency=100, min_interval=0.15, max_interval=8.0):\n+    claps = []\n+    start_peak = peak_array[0]\n+    previous_peak = start_peak\n+    clap_count = 1\n+    max_data_points_between_peaks = max_interval * sampling_frequency\n+    min_data_points_between_peaks = min_interval * sampling_frequency\n+\n+    for peak in peak_array:\n+        time_interval = peak - previous_peak\n+\n+        if min_data_points_between_peaks < time_interval <= max_data_points_between_peaks:\n+            clap_count += 1\n+        elif time_interval > max_data_points_between_peaks:\n+            start_peak = peak\n+            clap_count = 1  # Added resetting peak count when time interval too large from last peak. -- Eirik\n+        else:\n+            # Interval is less than minimum interval; still part of an already registered peak.\n+            continue  # Skip to next loop iteration","path":"prepare_labeled_data_from_hunt_prestudy.py","position":56,"original_position":56,"commit_id":"5956eec00bbb5ba871c3ac088fd715232d0cb872","original_commit_id":"5956eec00bbb5ba871c3ac088fd715232d0cb872","user":{"login":"kerstinbach","id":22470440,"avatar_url":"https://avatars.githubusercontent.com/u/22470440?v=3","gravatar_id":"","url":"https://api.github.com/users/kerstinbach","html_url":"https://github.com/kerstinbach","followers_url":"https://api.github.com/users/kerstinbach/followers","following_url":"https://api.github.com/users/kerstinbach/following{/other_user}","gists_url":"https://api.github.com/users/kerstinbach/gists{/gist_id}","starred_url":"https://api.github.com/users/kerstinbach/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kerstinbach/subscriptions","organizations_url":"https://api.github.com/users/kerstinbach/orgs","repos_url":"https://api.github.com/users/kerstinbach/repos","events_url":"https://api.github.com/users/kerstinbach/events{/privacy}","received_events_url":"https://api.github.com/users/kerstinbach/received_events","type":"User","site_admin":false},"body":"I'm not sure how you get there after\r\n`        if min_data_points_between_peaks < time_interval <= max_data_points_between_peaks:\r\n            clap_count += 1`\r\nDoesn't this cover that the interval is less than the minimum? \r\n\r\nMaybe I get it wrong - do you have an example?\r\n","created_at":"2016-10-19T19:34:59Z","updated_at":"2016-10-19T19:34:59Z","html_url":"https://github.com/Vages/HAR-Pipeline/pull/1#discussion_r84149414","pull_request_url":"https://api.github.com/repos/Vages/HAR-Pipeline/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/Vages/HAR-Pipeline/pulls/comments/84149414"},"html":{"href":"https://github.com/Vages/HAR-Pipeline/pull/1#discussion_r84149414"},"pull_request":{"href":"https://api.github.com/repos/Vages/HAR-Pipeline/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/Vages/HAR-Pipeline/pulls/1","id":90009953,"html_url":"https://github.com/Vages/HAR-Pipeline/pull/1","diff_url":"https://github.com/Vages/HAR-Pipeline/pull/1.diff","patch_url":"https://github.com/Vages/HAR-Pipeline/pull/1.patch","issue_url":"https://api.github.com/repos/Vages/HAR-Pipeline/issues/1","number":1,"state":"open","locked":false,"title":"Hunt prestudy prepare labels","user":{"login":"Vages","id":3520744,"avatar_url":"https://avatars.githubusercontent.com/u/3520744?v=3","gravatar_id":"","url":"https://api.github.com/users/Vages","html_url":"https://github.com/Vages","followers_url":"https://api.github.com/users/Vages/followers","following_url":"https://api.github.com/users/Vages/following{/other_user}","gists_url":"https://api.github.com/users/Vages/gists{/gist_id}","starred_url":"https://api.github.com/users/Vages/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Vages/subscriptions","organizations_url":"https://api.github.com/users/Vages/orgs","repos_url":"https://api.github.com/users/Vages/repos","events_url":"https://api.github.com/users/Vages/events{/privacy}","received_events_url":"https://api.github.com/users/Vages/received_events","type":"User","site_admin":false},"body":"A reworking of two files sent by Kerstin. Takes care of everything from raw CWA files to training data.","created_at":"2016-10-19T13:32:44Z","updated_at":"2016-10-19T19:34:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5beb5ba5689c891351f51feee619943e193e7046","assignee":{"login":"fredrigl","id":6745802,"avatar_url":"https://avatars.githubusercontent.com/u/6745802?v=3","gravatar_id":"","url":"https://api.github.com/users/fredrigl","html_url":"https://github.com/fredrigl","followers_url":"https://api.github.com/users/fredrigl/followers","following_url":"https://api.github.com/users/fredrigl/following{/other_user}","gists_url":"https://api.github.com/users/fredrigl/gists{/gist_id}","starred_url":"https://api.github.com/users/fredrigl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fredrigl/subscriptions","organizations_url":"https://api.github.com/users/fredrigl/orgs","repos_url":"https://api.github.com/users/fredrigl/repos","events_url":"https://api.github.com/users/fredrigl/events{/privacy}","received_events_url":"https://api.github.com/users/fredrigl/received_events","type":"User","site_admin":false},"assignees":[{"login":"fredrigl","id":6745802,"avatar_url":"https://avatars.githubusercontent.com/u/6745802?v=3","gravatar_id":"","url":"https://api.github.com/users/fredrigl","html_url":"https://github.com/fredrigl","followers_url":"https://api.github.com/users/fredrigl/followers","following_url":"https://api.github.com/users/fredrigl/following{/other_user}","gists_url":"https://api.github.com/users/fredrigl/gists{/gist_id}","starred_url":"https://api.github.com/users/fredrigl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fredrigl/subscriptions","organizations_url":"https://api.github.com/users/fredrigl/orgs","repos_url":"https://api.github.com/users/fredrigl/repos","events_url":"https://api.github.com/users/fredrigl/events{/privacy}","received_events_url":"https://api.github.com/users/fredrigl/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/Vages/HAR-Pipeline/pulls/1/commits","review_comments_url":"https://api.github.com/repos/Vages/HAR-Pipeline/pulls/1/comments","review_comment_url":"https://api.github.com/repos/Vages/HAR-Pipeline/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Vages/HAR-Pipeline/issues/1/comments","statuses_url":"https://api.github.com/repos/Vages/HAR-Pipeline/statuses/5956eec00bbb5ba871c3ac088fd715232d0cb872","head":{"label":"Vages:hunt-prestudy-prepare-labels","ref":"hunt-prestudy-prepare-labels","sha":"5956eec00bbb5ba871c3ac088fd715232d0cb872","user":{"login":"Vages","id":3520744,"avatar_url":"https://avatars.githubusercontent.com/u/3520744?v=3","gravatar_id":"","url":"https://api.github.com/users/Vages","html_url":"https://github.com/Vages","followers_url":"https://api.github.com/users/Vages/followers","following_url":"https://api.github.com/users/Vages/following{/other_user}","gists_url":"https://api.github.com/users/Vages/gists{/gist_id}","starred_url":"https://api.github.com/users/Vages/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Vages/subscriptions","organizations_url":"https://api.github.com/users/Vages/orgs","repos_url":"https://api.github.com/users/Vages/repos","events_url":"https://api.github.com/users/Vages/events{/privacy}","received_events_url":"https://api.github.com/users/Vages/received_events","type":"User","site_admin":false},"repo":{"id":68314346,"name":"HAR-Pipeline","full_name":"Vages/HAR-Pipeline","owner":{"login":"Vages","id":3520744,"avatar_url":"https://avatars.githubusercontent.com/u/3520744?v=3","gravatar_id":"","url":"https://api.github.com/users/Vages","html_url":"https://github.com/Vages","followers_url":"https://api.github.com/users/Vages/followers","following_url":"https://api.github.com/users/Vages/following{/other_user}","gists_url":"https://api.github.com/users/Vages/gists{/gist_id}","starred_url":"https://api.github.com/users/Vages/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Vages/subscriptions","organizations_url":"https://api.github.com/users/Vages/orgs","repos_url":"https://api.github.com/users/Vages/repos","events_url":"https://api.github.com/users/Vages/events{/privacy}","received_events_url":"https://api.github.com/users/Vages/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Vages/HAR-Pipeline","description":null,"fork":true,"url":"https://api.github.com/repos/Vages/HAR-Pipeline","forks_url":"https://api.github.com/repos/Vages/HAR-Pipeline/forks","keys_url":"https://api.github.com/repos/Vages/HAR-Pipeline/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Vages/HAR-Pipeline/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Vages/HAR-Pipeline/teams","hooks_url":"https://api.github.com/repos/Vages/HAR-Pipeline/hooks","issue_events_url":"https://api.github.com/repos/Vages/HAR-Pipeline/issues/events{/number}","events_url":"https://api.github.com/repos/Vages/HAR-Pipeline/events","assignees_url":"https://api.github.com/repos/Vages/HAR-Pipeline/assignees{/user}","branches_url":"https://api.github.com/repos/Vages/HAR-Pipeline/branches{/branch}","tags_url":"https://api.github.com/repos/Vages/HAR-Pipeline/tags","blobs_url":"https://api.github.com/repos/Vages/HAR-Pipeline/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Vages/HAR-Pipeline/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Vages/HAR-Pipeline/git/refs{/sha}","trees_url":"https://api.github.com/repos/Vages/HAR-Pipeline/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Vages/HAR-Pipeline/statuses/{sha}","languages_url":"https://api.github.com/repos/Vages/HAR-Pipeline/languages","stargazers_url":"https://api.github.com/repos/Vages/HAR-Pipeline/stargazers","contributors_url":"https://api.github.com/repos/Vages/HAR-Pipeline/contributors","subscribers_url":"https://api.github.com/repos/Vages/HAR-Pipeline/subscribers","subscription_url":"https://api.github.com/repos/Vages/HAR-Pipeline/subscription","commits_url":"https://api.github.com/repos/Vages/HAR-Pipeline/commits{/sha}","git_commits_url":"https://api.github.com/repos/Vages/HAR-Pipeline/git/commits{/sha}","comments_url":"https://api.github.com/repos/Vages/HAR-Pipeline/comments{/number}","issue_comment_url":"https://api.github.com/repos/Vages/HAR-Pipeline/issues/comments{/number}","contents_url":"https://api.github.com/repos/Vages/HAR-Pipeline/contents/{+path}","compare_url":"https://api.github.com/repos/Vages/HAR-Pipeline/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Vages/HAR-Pipeline/merges","archive_url":"https://api.github.com/repos/Vages/HAR-Pipeline/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Vages/HAR-Pipeline/downloads","issues_url":"https://api.github.com/repos/Vages/HAR-Pipeline/issues{/number}","pulls_url":"https://api.github.com/repos/Vages/HAR-Pipeline/pulls{/number}","milestones_url":"https://api.github.com/repos/Vages/HAR-Pipeline/milestones{/number}","notifications_url":"https://api.github.com/repos/Vages/HAR-Pipeline/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Vages/HAR-Pipeline/labels{/name}","releases_url":"https://api.github.com/repos/Vages/HAR-Pipeline/releases{/id}","deployments_url":"https://api.github.com/repos/Vages/HAR-Pipeline/deployments","created_at":"2016-09-15T17:10:17Z","updated_at":"2016-09-15T17:10:18Z","pushed_at":"2016-10-19T13:32:44Z","git_url":"git://github.com/Vages/HAR-Pipeline.git","ssh_url":"git@github.com:Vages/HAR-Pipeline.git","clone_url":"https://github.com/Vages/HAR-Pipeline.git","svn_url":"https://github.com/Vages/HAR-Pipeline","homepage":null,"size":80,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"Vages:master","ref":"master","sha":"cc33062659e9ead4ea5f9d33d90038f2a9030ad1","user":{"login":"Vages","id":3520744,"avatar_url":"https://avatars.githubusercontent.com/u/3520744?v=3","gravatar_id":"","url":"https://api.github.com/users/Vages","html_url":"https://github.com/Vages","followers_url":"https://api.github.com/users/Vages/followers","following_url":"https://api.github.com/users/Vages/following{/other_user}","gists_url":"https://api.github.com/users/Vages/gists{/gist_id}","starred_url":"https://api.github.com/users/Vages/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Vages/subscriptions","organizations_url":"https://api.github.com/users/Vages/orgs","repos_url":"https://api.github.com/users/Vages/repos","events_url":"https://api.github.com/users/Vages/events{/privacy}","received_events_url":"https://api.github.com/users/Vages/received_events","type":"User","site_admin":false},"repo":{"id":68314346,"name":"HAR-Pipeline","full_name":"Vages/HAR-Pipeline","owner":{"login":"Vages","id":3520744,"avatar_url":"https://avatars.githubusercontent.com/u/3520744?v=3","gravatar_id":"","url":"https://api.github.com/users/Vages","html_url":"https://github.com/Vages","followers_url":"https://api.github.com/users/Vages/followers","following_url":"https://api.github.com/users/Vages/following{/other_user}","gists_url":"https://api.github.com/users/Vages/gists{/gist_id}","starred_url":"https://api.github.com/users/Vages/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Vages/subscriptions","organizations_url":"https://api.github.com/users/Vages/orgs","repos_url":"https://api.github.com/users/Vages/repos","events_url":"https://api.github.com/users/Vages/events{/privacy}","received_events_url":"https://api.github.com/users/Vages/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Vages/HAR-Pipeline","description":null,"fork":true,"url":"https://api.github.com/repos/Vages/HAR-Pipeline","forks_url":"https://api.github.com/repos/Vages/HAR-Pipeline/forks","keys_url":"https://api.github.com/repos/Vages/HAR-Pipeline/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Vages/HAR-Pipeline/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Vages/HAR-Pipeline/teams","hooks_url":"https://api.github.com/repos/Vages/HAR-Pipeline/hooks","issue_events_url":"https://api.github.com/repos/Vages/HAR-Pipeline/issues/events{/number}","events_url":"https://api.github.com/repos/Vages/HAR-Pipeline/events","assignees_url":"https://api.github.com/repos/Vages/HAR-Pipeline/assignees{/user}","branches_url":"https://api.github.com/repos/Vages/HAR-Pipeline/branches{/branch}","tags_url":"https://api.github.com/repos/Vages/HAR-Pipeline/tags","blobs_url":"https://api.github.com/repos/Vages/HAR-Pipeline/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Vages/HAR-Pipeline/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Vages/HAR-Pipeline/git/refs{/sha}","trees_url":"https://api.github.com/repos/Vages/HAR-Pipeline/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Vages/HAR-Pipeline/statuses/{sha}","languages_url":"https://api.github.com/repos/Vages/HAR-Pipeline/languages","stargazers_url":"https://api.github.com/repos/Vages/HAR-Pipeline/stargazers","contributors_url":"https://api.github.com/repos/Vages/HAR-Pipeline/contributors","subscribers_url":"https://api.github.com/repos/Vages/HAR-Pipeline/subscribers","subscription_url":"https://api.github.com/repos/Vages/HAR-Pipeline/subscription","commits_url":"https://api.github.com/repos/Vages/HAR-Pipeline/commits{/sha}","git_commits_url":"https://api.github.com/repos/Vages/HAR-Pipeline/git/commits{/sha}","comments_url":"https://api.github.com/repos/Vages/HAR-Pipeline/comments{/number}","issue_comment_url":"https://api.github.com/repos/Vages/HAR-Pipeline/issues/comments{/number}","contents_url":"https://api.github.com/repos/Vages/HAR-Pipeline/contents/{+path}","compare_url":"https://api.github.com/repos/Vages/HAR-Pipeline/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Vages/HAR-Pipeline/merges","archive_url":"https://api.github.com/repos/Vages/HAR-Pipeline/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Vages/HAR-Pipeline/downloads","issues_url":"https://api.github.com/repos/Vages/HAR-Pipeline/issues{/number}","pulls_url":"https://api.github.com/repos/Vages/HAR-Pipeline/pulls{/number}","milestones_url":"https://api.github.com/repos/Vages/HAR-Pipeline/milestones{/number}","notifications_url":"https://api.github.com/repos/Vages/HAR-Pipeline/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Vages/HAR-Pipeline/labels{/name}","releases_url":"https://api.github.com/repos/Vages/HAR-Pipeline/releases{/id}","deployments_url":"https://api.github.com/repos/Vages/HAR-Pipeline/deployments","created_at":"2016-09-15T17:10:17Z","updated_at":"2016-09-15T17:10:18Z","pushed_at":"2016-10-19T13:32:44Z","git_url":"git://github.com/Vages/HAR-Pipeline.git","ssh_url":"git@github.com:Vages/HAR-Pipeline.git","clone_url":"https://github.com/Vages/HAR-Pipeline.git","svn_url":"https://github.com/Vages/HAR-Pipeline","homepage":null,"size":80,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Vages/HAR-Pipeline/pulls/1"},"html":{"href":"https://github.com/Vages/HAR-Pipeline/pull/1"},"issue":{"href":"https://api.github.com/repos/Vages/HAR-Pipeline/issues/1"},"comments":{"href":"https://api.github.com/repos/Vages/HAR-Pipeline/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/Vages/HAR-Pipeline/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/Vages/HAR-Pipeline/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Vages/HAR-Pipeline/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/Vages/HAR-Pipeline/statuses/5956eec00bbb5ba871c3ac088fd715232d0cb872"}}}}
{"actor":{"display_login":"kerstinbach"}}