{
  "id": 437261,
  "title": "Z-Angle (Anglez), Euclidean Norm Minus One (Enmo) and Mean Amplitude Deviation (MAD)",
  "url": "/competitions/child-mind-institute-detect-sleep-states/discussion/437261",
  "author_name": "Marília Prata",
  "post_date": "2023-09-06T04:40:57.094000",
  "votes": 56,
  "comment_count": 17,
  "views": 0,
  "content": "<h1>Distribution of Change in Z-Angle</h1>\n<p>Estimating sleep parameters using an accelerometer without sleep diary</p>\n<p>Citation: van Hees, V.T., Sabia, S., Jones, S.E. et al. Estimating sleep parameters using an accelerometer without sleep diary. Sci Rep 8, 12975 (2018). <a href=\"https://doi.org/10.1038/s41598-018-31266-z\" target=\"_blank\">https://doi.org/10.1038/s41598-018-31266-z</a></p>\n<p>\"Wrist worn raw-data accelerometers are used increasingly in large-scale population research. The authors examined whether sleep parameters can be estimated from these data in the absence of sleep diaries. Their heuristic algorithm used the variance in estimated z-axis angle and makes basic assumptions about sleep interruptions.\"</p>\n<p>\"Detected sleep period time window (SPT-window) was compared against sleep diary in 3752 participants (range = 60–82 years) and polysomnography in sleep clinic patients (N = 28) and in healthy good sleepers (N = 22). \"</p>\n<p>\"The SPT-window derived from the algorithm was 10.9 and 2.9 minutes longer compared with sleep diary in men and women, respectively. Mean C-statistic to detect the SPT-window compared to polysomnography was 0.86 and 0.83 in clinic-based and healthy sleepers, respectively. We demonstrated the accuracy of our algorithm to detect the SPT-window. The value of this algorithm lies in studies such as UK Biobank where a sleep diary was not used.\"</p>\n<p><a href=\"https://www.nature.com/articles/s41598-018-31266-z\" target=\"_blank\">https://www.nature.com/articles/s41598-018-31266-z</a></p>\n<h1>Z-Angle presented by Van Hees (2018)</h1>\n<p>\"From the use of accelerometers, it's possible to estimate different variables related to sleep, such as duration and efficiency. For this, The authors have used the Heuristic algorithm, looking at Distribution of Change in z-Angle presented by Van Hees (2018). This algorithm identifies the longest period of inactivity within 24 hours, with the least number of interruptions, classifying as a sleep period.\"</p>\n<p><a href=\"https://eleva.ufsc.br/en/acelerometros/\" target=\"_blank\">https://eleva.ufsc.br/en/acelerometros/</a></p>\n<h1>Euclidean Norm Minus One (Enmo) and Mean Amplitude Deviation (MAD)</h1>\n<p>Intensity Thresholds on Raw Acceleration Data: Euclidean Norm Minus One (ENMO) and Mean Amplitude Deviation (MAD) Approaches</p>\n<p>Citation: Bakrania K, Yates T, Rowlands AV, Esliger DW, Bunnewell S, Sanders J, et al. (2016) Intensity Thresholds on Raw Acceleration Data: Euclidean Norm Minus One (ENMO) and Mean Amplitude Deviation (MAD) Approaches. PLoS ONE 11(10): e0164045. <a href=\"https://doi.org/10.1371/journal.pone.0164045\" target=\"_blank\">https://doi.org/10.1371/journal.pone.0164045</a></p>\n<p>\" To develop and internally-validate Euclidean Norm Minus One (ENMO) and Mean Amplitude Deviation (MAD) thresholds for separating sedentary behaviours from common light-intensity physical activities using raw acceleration data collected from both hip- and wrist-worn tri-axial accelerometers; and to compare and evaluate the performances between the ENMO and MAD metrics.\"</p>\n<h1>Sedentary Behaviours</h1>\n<p>\"Researchers can utilise these robust monitor-specific hip and wrist ENMO and MAD thresholds, in order to accurately separate sedentary behaviours from common motion-based light-intensity physical activities. However, caution should be taken if isolating sedentary behaviours from standing is of particular interest.\"</p>\n<p><a href=\"https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0164045\" target=\"_blank\">https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0164045</a></p>",
  "messages": [
    {
      "id": 2425633,
      "postDate": "2023-09-06T04:40:57.093Z",
      "content": "<h1>Distribution of Change in Z-Angle</h1>\n<p>Estimating sleep parameters using an accelerometer without sleep diary</p>\n<p>Citation: van Hees, V.T., Sabia, S., Jones, S.E. et al. Estimating sleep parameters using an accelerometer without sleep diary. Sci Rep 8, 12975 (2018). <a href=\"https://doi.org/10.1038/s41598-018-31266-z\" target=\"_blank\">https://doi.org/10.1038/s41598-018-31266-z</a></p>\n<p>\"Wrist worn raw-data accelerometers are used increasingly in large-scale population research. The authors examined whether sleep parameters can be estimated from these data in the absence of sleep diaries. Their heuristic algorithm used the variance in estimated z-axis angle and makes basic assumptions about sleep interruptions.\"</p>\n<p>\"Detected sleep period time window (SPT-window) was compared against sleep diary in 3752 participants (range = 60–82 years) and polysomnography in sleep clinic patients (N = 28) and in healthy good sleepers (N = 22). \"</p>\n<p>\"The SPT-window derived from the algorithm was 10.9 and 2.9 minutes longer compared with sleep diary in men and women, respectively. Mean C-statistic to detect the SPT-window compared to polysomnography was 0.86 and 0.83 in clinic-based and healthy sleepers, respectively. We demonstrated the accuracy of our algorithm to detect the SPT-window. The value of this algorithm lies in studies such as UK Biobank where a sleep diary was not used.\"</p>\n<p><a href=\"https://www.nature.com/articles/s41598-018-31266-z\" target=\"_blank\">https://www.nature.com/articles/s41598-018-31266-z</a></p>\n<h1>Z-Angle presented by Van Hees (2018)</h1>\n<p>\"From the use of accelerometers, it's possible to estimate different variables related to sleep, such as duration and efficiency. For this, The authors have used the Heuristic algorithm, looking at Distribution of Change in z-Angle presented by Van Hees (2018). This algorithm identifies the longest period of inactivity within 24 hours, with the least number of interruptions, classifying as a sleep period.\"</p>\n<p><a href=\"https://eleva.ufsc.br/en/acelerometros/\" target=\"_blank\">https://eleva.ufsc.br/en/acelerometros/</a></p>\n<h1>Euclidean Norm Minus One (Enmo) and Mean Amplitude Deviation (MAD)</h1>\n<p>Intensity Thresholds on Raw Acceleration Data: Euclidean Norm Minus One (ENMO) and Mean Amplitude Deviation (MAD) Approaches</p>\n<p>Citation: Bakrania K, Yates T, Rowlands AV, Esliger DW, Bunnewell S, Sanders J, et al. (2016) Intensity Thresholds on Raw Acceleration Data: Euclidean Norm Minus One (ENMO) and Mean Amplitude Deviation (MAD) Approaches. PLoS ONE 11(10): e0164045. <a href=\"https://doi.org/10.1371/journal.pone.0164045\" target=\"_blank\">https://doi.org/10.1371/journal.pone.0164045</a></p>\n<p>\" To develop and internally-validate Euclidean Norm Minus One (ENMO) and Mean Amplitude Deviation (MAD) thresholds for separating sedentary behaviours from common light-intensity physical activities using raw acceleration data collected from both hip- and wrist-worn tri-axial accelerometers; and to compare and evaluate the performances between the ENMO and MAD metrics.\"</p>\n<h1>Sedentary Behaviours</h1>\n<p>\"Researchers can utilise these robust monitor-specific hip and wrist ENMO and MAD thresholds, in order to accurately separate sedentary behaviours from common motion-based light-intensity physical activities. However, caution should be taken if isolating sedentary behaviours from standing is of particular interest.\"</p>\n<p><a href=\"https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0164045\" target=\"_blank\">https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0164045</a></p>",
      "rawMarkdown": "#Distribution of Change in Z-Angle\n\nEstimating sleep parameters using an accelerometer without sleep diary\n\nCitation: van Hees, V.T., Sabia, S., Jones, S.E. et al. Estimating sleep parameters using an accelerometer without sleep diary. Sci Rep 8, 12975 (2018). https://doi.org/10.1038/s41598-018-31266-z\n\n\"Wrist worn raw-data accelerometers are used increasingly in large-scale population research. The authors examined whether sleep parameters can be estimated from these data in the absence of sleep diaries. Their heuristic algorithm used the variance in estimated z-axis angle and makes basic assumptions about sleep interruptions.\"\n\n\"Detected sleep period time window (SPT-window) was compared against sleep diary in 3752 participants (range = 60–82 years) and polysomnography in sleep clinic patients (N = 28) and in healthy good sleepers (N = 22). \"\n\n\"The SPT-window derived from the algorithm was 10.9 and 2.9 minutes longer compared with sleep diary in men and women, respectively. Mean C-statistic to detect the SPT-window compared to polysomnography was 0.86 and 0.83 in clinic-based and healthy sleepers, respectively. We demonstrated the accuracy of our algorithm to detect the SPT-window. The value of this algorithm lies in studies such as UK Biobank where a sleep diary was not used.\"\n\nhttps://www.nature.com/articles/s41598-018-31266-z\n\n#Z-Angle presented by Van Hees (2018)\n\n\"From the use of accelerometers, it's possible to estimate different variables related to sleep, such as duration and efficiency. For this, The authors have used the Heuristic algorithm, looking at Distribution of Change in z-Angle presented by Van Hees (2018). This algorithm identifies the longest period of inactivity within 24 hours, with the least number of interruptions, classifying as a sleep period.\"\n\nhttps://eleva.ufsc.br/en/acelerometros/\n\n#Euclidean Norm Minus One (Enmo) and Mean Amplitude Deviation (MAD)\n\nIntensity Thresholds on Raw Acceleration Data: Euclidean Norm Minus One (ENMO) and Mean Amplitude Deviation (MAD) Approaches\n\nCitation: Bakrania K, Yates T, Rowlands AV, Esliger DW, Bunnewell S, Sanders J, et al. (2016) Intensity Thresholds on Raw Acceleration Data: Euclidean Norm Minus One (ENMO) and Mean Amplitude Deviation (MAD) Approaches. PLoS ONE 11(10): e0164045. https://doi.org/10.1371/journal.pone.0164045\n\n\" To develop and internally-validate Euclidean Norm Minus One (ENMO) and Mean Amplitude Deviation (MAD) thresholds for separating sedentary behaviours from common light-intensity physical activities using raw acceleration data collected from both hip- and wrist-worn tri-axial accelerometers; and to compare and evaluate the performances between the ENMO and MAD metrics.\"\n\n#Sedentary Behaviours\n\n\"Researchers can utilise these robust monitor-specific hip and wrist ENMO and MAD thresholds, in order to accurately separate sedentary behaviours from common motion-based light-intensity physical activities. However, caution should be taken if isolating sedentary behaviours from standing is of particular interest.\"\n\nhttps://journals.plos.org/plosone/article?id=10.1371/journal.pone.0164045",
      "votes": 55
    },
    {
      "id": 2440136,
      "postDate": "2023-09-15T09:45:17.710Z",
      "content": "<p>I spent some time wrapping my head around what \"z-angle\" really means in geospatial jargon. Basically, it's a metric pulled from individual accelerometer readings expressed in quartenions, and it tells you how your arm's angled compared to your body's vertical axis.</p>\n<p>I even went the extra mile and used Blender to mimic how your arm rotates. But if you want to see it in action and make things crystal clear, check out this <a href=\"https://youtu.be/KGpMEk3TSYs\" target=\"_blank\">video</a>. It'll make things click!</p>\n<p>y-angle for yellow-line, x-angle for red-line and z-angle for blue-line</p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F7260255%2F4e1bcf36a14ce590de7093d41b1e1883%2FOpera%20Snapshot_2023-09-15_104707_www.youtube.com.png?generation=1694771259527993&amp;alt=media\" alt=\"\"></p>",
      "rawMarkdown": "I spent some time wrapping my head around what \"z-angle\" really means in geospatial jargon. Basically, it's a metric pulled from individual accelerometer readings expressed in quartenions, and it tells you how your arm's angled compared to your body's vertical axis.\n\nI even went the extra mile and used Blender to mimic how your arm rotates. But if you want to see it in action and make things crystal clear, check out this [video](https://youtu.be/KGpMEk3TSYs). It'll make things click!\n\ny-angle for yellow-line, x-angle for red-line and z-angle for blue-line\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F7260255%2F4e1bcf36a14ce590de7093d41b1e1883%2FOpera%20Snapshot_2023-09-15_104707_www.youtube.com.png?generation=1694771259527993&alt=media)\n",
      "votes": 8,
      "replies": [
        {
          "id": 2440464,
          "postDate": "2023-09-15T14:26:14.333Z",
          "content": "<p>Awesome video. I loved it Paulo!</p>\n<p>Do we have an W angle? (Rotation is showing a W)</p>",
          "rawMarkdown": "Awesome video. I loved it Paulo!\n\nDo we have an W angle? (Rotation is showing a W)",
          "votes": 1,
          "replies": [
            {
              "id": 2440728,
              "postDate": "2023-09-15T17:31:13.503Z",
              "content": "<p>Hi Marilia!  w,x,y and z parameters do not directly correspond to the x, y, and z components in Euler angles. In the case of quaternions, each of these parameters is a normalized floating-point value ranging from 0 to 1. So there is no direct representation in the X,Y and Z dimensions.<br>\nBtw, I mentioned your notebook in my <a href=\"https://www.kaggle.com/code/pauloyuncha/eda-which-makes-sense-beta\" target=\"_blank\">EDA notebook</a> and i explained a little bit about w value :)</p>",
              "rawMarkdown": "Hi Marilia!  w,x,y and z parameters do not directly correspond to the x, y, and z components in Euler angles. In the case of quaternions, each of these parameters is a normalized floating-point value ranging from 0 to 1. So there is no direct representation in the X,Y and Z dimensions.\nBtw, I mentioned your notebook in my [EDA notebook](https://www.kaggle.com/code/pauloyuncha/eda-which-makes-sense-beta) and i explained a little bit about w value :)",
              "votes": 3
            },
            {
              "id": 2440730,
              "postDate": "2023-09-15T17:34:34.783Z",
              "content": "<p>I added your video to a new Notebook. </p>",
              "rawMarkdown": "I added your video to a new Notebook. ",
              "votes": 1
            }
          ]
        },
        {
          "id": 2442297,
          "postDate": "2023-09-16T21:53:20.460Z",
          "rawMarkdown": "",
          "votes": 3,
          "isDeleted": true,
          "replies": [
            {
              "id": 2442300,
              "postDate": "2023-09-16T22:01:52.577Z",
              "content": "<p>Hi Simon,</p>\n<p>Instead of lambs we can count quartenions. Even to pronounce it is hard. It's good to sell watches. Which is weird to sleep with any kind of them too.</p>",
              "rawMarkdown": "Hi Simon,\n\nInstead of lambs we can count quartenions. Even to pronounce it is hard. It's good to sell watches. Which is weird to sleep with any kind of them too.",
              "votes": 1
            }
          ]
        },
        {
          "id": 2444526,
          "postDate": "2023-09-18T10:11:40.263Z",
          "content": "<p>I appreciate your efforts of trying to visualize and explain the angle-z feature, BUT I strongly believe your understanding/visualization of it is WRONG. I don't want to come about as rude, I kust want to share my understanding of it and help clear up the confusion.<br>\nAs I've a lot of experience working with angle measurements from accelerometer data in the robotic field and have worked with wrist worn accelerometer data before, I hope I can clear up the confusion.<br>\nImagine wearing a wristwatch. This watch has an integrated accelerometer (as most smart watches do). The Z-Axis of this accelerometer is pointing upwards by convention. Thus, if you war the watch and look at the time, the Z-Axis is directly pointing into your face. If you leave your arms hanging, the Z-Axis of the watch is facing away from your body in the horizontal plane. Using accelerometer data, one can only measure/calculate the angle relative to the horizontal plane (because we basicslly measure the downwards direction relative to the device based on gravitational force). The angle described in your video (around the bodies vertical axis) however, can only be measured by a magnetometer (basically an electrical compass).<br>\nBased on this information, an angle-z of 0 degrees corresponds to a position, where you have your arms hanging down ans the watch is facing away from your body (in the horizontal plane). Looking at ypur watch (pointing it straight into the sky) would result in the maxium possible angle (90°, if the signal would be perfect). Contrary, looking at your palms (pointing the watch downwards into the ground) would result in -90°. (I am not 100% certain about the sign of the signal, whether up or down is negative, but it should not matter too much).</p>\n<p>Let me know what you think about this interpretation.</p>",
          "rawMarkdown": "I appreciate your efforts of trying to visualize and explain the angle-z feature, BUT I strongly believe your understanding/visualization of it is WRONG. I don't want to come about as rude, I kust want to share my understanding of it and help clear up the confusion.\nAs I've a lot of experience working with angle measurements from accelerometer data in the robotic field and have worked with wrist worn accelerometer data before, I hope I can clear up the confusion.\nImagine wearing a wristwatch. This watch has an integrated accelerometer (as most smart watches do). The Z-Axis of this accelerometer is pointing upwards by convention. Thus, if you war the watch and look at the time, the Z-Axis is directly pointing into your face. If you leave your arms hanging, the Z-Axis of the watch is facing away from your body in the horizontal plane. Using accelerometer data, one can only measure/calculate the angle relative to the horizontal plane (because we basicslly measure the downwards direction relative to the device based on gravitational force). The angle described in your video (around the bodies vertical axis) however, can only be measured by a magnetometer (basically an electrical compass).\nBased on this information, an angle-z of 0 degrees corresponds to a position, where you have your arms hanging down ans the watch is facing away from your body (in the horizontal plane). Looking at ypur watch (pointing it straight into the sky) would result in the maxium possible angle (90°, if the signal would be perfect). Contrary, looking at your palms (pointing the watch downwards into the ground) would result in -90°. (I am not 100% certain about the sign of the signal, whether up or down is negative, but it should not matter too much).\n\nLet me know what you think about this interpretation.",
          "votes": 3,
          "replies": [
            {
              "id": 2444808,
              "postDate": "2023-09-18T13:45:27.190Z",
              "content": "<p>Hi Patrick AI for Fun,</p>\n<p>I think downwards is negative angle (like xy axis on graphs).</p>\n<p>The 1st dataset I published on Kaggle was: \"Recording data with a swim log\".<br>\nWhere I uploaded my open water swim activity data.  Since I'm not a swimmer pro, each time I change the strokes and consequently ARM position/height. Whenever we perform Breaststyle or butterfly, the arm remains under the water/sea.  So the the GPS loses signal with the satellite.  And stop to record distance properly.  </p>\n<p>Many users blame the watch (my GarMin or any other brand), however it's the arm position that should be out of water to work as expected to record the correct distance. </p>\n<p>The same occurs while we are sleeping, since the arm (with the wrist watch) doesn't remain in the same position.  By the way, sleeping with a watch in your arm is a \"pain in the ass\". That disturbs my sleep. Avoid wearing watchs while you're sleeping. </p>\n<p>The innovative, stunning video made by Paulo shows someone standing up. <br>\nMaybe it's a sleepwalker/somnambulist?😓</p>\n<p>You mentioned: \" If you leave your arms hanging, the Z-Axis of the watch is facing away from your body in the horizontal plane.\"  In that case, even the size of the bed will affect the measurements, cause to any arm hangs and face away body in the horizontal plane, it seems that the bed is narrow (or the person is near the bed's boarder) for the arm to hang.   That's what I understood from your explanation/interpretation.</p>\n<h1>In other words, ARM position changes everything (at least for open water swimming).</h1>\n<p>Below, are the words that I wrote on my dataset, 4 years ago:</p>\n<p>\"Here, I collected data wearing a smart watch. Synchronizing GPS requires longitude, latitude and altitude above sea level information. Several times, we practice breastyle or even butterflystyle. In those kind of strokes, GPS loses signal and stops collecting distance’s data. Therefore, altitude above sea level is fundamental. It's easy to fix this: just raise the arm (wearing the watch) above the water. Signal will return enabling to update your distance score. Such tools are built thinking about better results. However, most part of customers disregard the altitude factor.\"  (And blame the watch for malfunction : )</p>\n<p>Thank you for the embracing explanation Patrick.</p>\n<p>Kind regards,<br>\nMarília.</p>",
              "rawMarkdown": "Hi Patrick AI for Fun,\n\nI think downwards is negative angle (like xy axis on graphs).\n\nThe 1st dataset I published on Kaggle was: \"Recording data with a swim log\".\nWhere I uploaded my open water swim activity data.  Since I'm not a swimmer pro, each time I change the strokes and consequently ARM position/height. Whenever we perform Breaststyle or butterfly, the arm remains under the water/sea.  So the the GPS loses signal with the satellite.  And stop to record distance properly.  \n\nMany users blame the watch (my GarMin or any other brand), however it's the arm position that should be out of water to work as expected to record the correct distance. \n\nThe same occurs while we are sleeping, since the arm (with the wrist watch) doesn't remain in the same position.  By the way, sleeping with a watch in your arm is a \"pain in the ass\". That disturbs my sleep. Avoid wearing watchs while you're sleeping. \n\nThe innovative, stunning video made by Paulo shows someone standing up. \nMaybe it's a sleepwalker/somnambulist?😓\n\nYou mentioned: \" If you leave your arms hanging, the Z-Axis of the watch is facing away from your body in the horizontal plane.\"  In that case, even the size of the bed will affect the measurements, cause to any arm hangs and face away body in the horizontal plane, it seems that the bed is narrow (or the person is near the bed's boarder) for the arm to hang.   That's what I understood from your explanation/interpretation.\n\n#In other words, ARM position changes everything (at least for open water swimming).\n\nBelow, are the words that I wrote on my dataset, 4 years ago:\n\n\"Here, I collected data wearing a smart watch. Synchronizing GPS requires longitude, latitude and altitude above sea level information. Several times, we practice breastyle or even butterflystyle. In those kind of strokes, GPS loses signal and stops collecting distance’s data. Therefore, altitude above sea level is fundamental. It's easy to fix this: just raise the arm (wearing the watch) above the water. Signal will return enabling to update your distance score. Such tools are built thinking about better results. However, most part of customers disregard the altitude factor.\"  (And blame the watch for malfunction : )\n\nThank you for the embracing explanation Patrick.\n\nKind regards,\nMarília.",
              "votes": 2
            },
            {
              "id": 2446398,
              "postDate": "2023-09-19T12:16:08.027Z",
              "content": "<p>Hi <a href=\"https://www.kaggle.com/PatrickAIForFun\" target=\"_blank\">@PatrickAIForFun</a>! Thanks for sharing!! Very clear for beginner as me. By the way, have you experienced building iot devices such as wemos mini d1r1 and mpu 6050 or similiars for body tracking? </p>",
              "rawMarkdown": "Hi @PatrickAIForFun! Thanks for sharing!! Very clear for beginner as me. By the way, have you experienced building iot devices such as wemos mini d1r1 and mpu 6050 or similiars for body tracking? ",
              "votes": 2
            },
            {
              "id": 2446437,
              "postDate": "2023-09-19T12:40:39.330Z",
              "content": "<p>I do have experience using the MPU6050 (6DOF) and the BNO055 (9DOF) mainly in the robotics field (in combination with ARM based microcontrollers)</p>",
              "rawMarkdown": "I do have experience using the MPU6050 (6DOF) and the BNO055 (9DOF) mainly in the robotics field (in combination with ARM based microcontrollers)",
              "votes": 2
            },
            {
              "id": 2456712,
              "postDate": "2023-09-26T11:22:31.307Z",
              "content": "<p>great, may i ask you something <a href=\"https://www.kaggle.com/patrickaiforfun\" target=\"_blank\">@patrickaiforfun</a>? i got quartenions from a parent bone and a child bone. What is the topic should i search to be able to update the child bone according to the parent bone? Plus, i want to represent the quartenions in a 2d plot x,y, is this possible? </p>\n<p>Kind regards, </p>",
              "rawMarkdown": "great, may i ask you something @patrickaiforfun? i got quartenions from a parent bone and a child bone. What is the topic should i search to be able to update the child bone according to the parent bone? Plus, i want to represent the quartenions in a 2d plot x,y, is this possible? \n\nKind regards, ",
              "votes": 2
            },
            {
              "id": 2456768,
              "postDate": "2023-09-26T11:50:36.717Z",
              "content": "<p><a href=\"https://www.kaggle.com/pauloyuncha\" target=\"_blank\">@pauloyuncha</a> Depending on your mathematical knowledge, the fundamentals in linear algebra are very useful for this kind of stuff. 3Blue1Brown made two good videos explaining quaternions intuetivley (<a href=\"https://www.youtube.com/watch?v=zjMuIxRvygQ\" target=\"_blank\">Quaternions and 3d rotation, explained interactively</a>; <a href=\"https://www.youtube.com/watch?v=d4EgbgTm0Bg\" target=\"_blank\">Visualizing quaternions (4d numbers) with stereographic projection</a>).<br>\nWorking with quaternions has its benefits: For example having a parent bone with an absolute rotation given as a quaternion and a child bone with quaternions given as the relative angle, you can simple multiply these quaternions to obtain the absolute angle of the child bone.<br>\nA 2d plot will not work, because we are dealing with angles in 3d space (3 degrees of freedom), no matter how we encode these angles (quaternions, axis-angle, euer angles) you simply can not plot them with only 2 degrees of freedom. If you do have constraints on your angles (for example, the elbow can not rotate in any arbitrary direction, thus you do loose a degree of freedom), you might be able to transform these values to plot them in 2d. Regarding this, I would research Inverse Kinematics.<br>\nHowever, I suspect there are solutions already existing out there for your problem if it is not highly specialized (in which case a thorough understanding of linear algebra, quaternions, angle transformations, … are needed).</p>\n<p>Hope this helps!</p>",
              "rawMarkdown": "@pauloyuncha Depending on your mathematical knowledge, the fundamentals in linear algebra are very useful for this kind of stuff. 3Blue1Brown made two good videos explaining quaternions intuetivley ([Quaternions and 3d rotation, explained interactively](https://www.youtube.com/watch?v=zjMuIxRvygQ); [Visualizing quaternions (4d numbers) with stereographic projection](https://www.youtube.com/watch?v=d4EgbgTm0Bg)).\nWorking with quaternions has its benefits: For example having a parent bone with an absolute rotation given as a quaternion and a child bone with quaternions given as the relative angle, you can simple multiply these quaternions to obtain the absolute angle of the child bone.\nA 2d plot will not work, because we are dealing with angles in 3d space (3 degrees of freedom), no matter how we encode these angles (quaternions, axis-angle, euer angles) you simply can not plot them with only 2 degrees of freedom. If you do have constraints on your angles (for example, the elbow can not rotate in any arbitrary direction, thus you do loose a degree of freedom), you might be able to transform these values to plot them in 2d. Regarding this, I would research Inverse Kinematics.\nHowever, I suspect there are solutions already existing out there for your problem if it is not highly specialized (in which case a thorough understanding of linear algebra, quaternions, angle transformations, ... are needed).\n\nHope this helps!",
              "votes": 2
            }
          ]
        }
      ]
    },
    {
      "id": 2443442,
      "postDate": "2023-09-17T18:00:35.853Z",
      "content": "<p>I am kind of confused that MAD actually could stand for Mean Amplitude Deviation or Median Absolute Deviation (as <a href=\"https://www.nature.com/articles/s41598-020-79217-x\" target=\"_blank\">described here</a>).</p>\n<p>I am currently using the later one, thanks to your discussion I will try to add the first MAD.</p>",
      "rawMarkdown": "I am kind of confused that MAD actually could stand for Mean Amplitude Deviation or Median Absolute Deviation (as [described here](https://www.nature.com/articles/s41598-020-79217-x)).\n\nI am currently using the later one, thanks to your discussion I will try to add the first MAD.",
      "votes": 1,
      "replies": [
        {
          "id": 2443499,
          "postDate": "2023-09-17T18:24:10.993Z",
          "content": "<p>I've just transcribed what I've found about MAD on the article. I don't have the capacity to apply that MAD metric.</p>",
          "rawMarkdown": "I've just transcribed what I've found about MAD on the article. I don't have the capacity to apply that MAD metric.",
          "votes": 1,
          "replies": [
            {
              "id": 2444280,
              "postDate": "2023-09-18T08:37:11.097Z",
              "content": "<p>Great, no worries Marilia. You just ignited a discussion which some person might find very helpful.</p>",
              "rawMarkdown": "Great, no worries Marilia. You just ignited a discussion which some person might find very helpful.",
              "votes": 1
            },
            {
              "id": 2444731,
              "postDate": "2023-09-18T12:51:49.373Z",
              "content": "<p>You're a DS professional. For me everything is new, every single day reading stuff that I've never read before.</p>",
              "rawMarkdown": "You're a DS professional. For me everything is new, every single day reading stuff that I've never read before."
            },
            {
              "id": 2444857,
              "postDate": "2023-09-18T14:14:08.667Z",
              "content": "<p>No I am not, I am just a junior in DS trying to figure out things. At this point, we and everyone here are learning continuously from this competition. Thank you for your humbleness.</p>",
              "rawMarkdown": "No I am not, I am just a junior in DS trying to figure out things. At this point, we and everyone here are learning continuously from this competition. Thank you for your humbleness.",
              "votes": 1
            }
          ]
        }
      ]
    }
  ],
  "comments": [
    {
      "id": 2440136,
      "author_name": "pauloyuncha",
      "author_url": "",
      "post_date": "2023-09-15T09:45:17.710000",
      "content": "<p>I spent some time wrapping my head around what \"z-angle\" really means in geospatial jargon. Basically, it's a metric pulled from individual accelerometer readings expressed in quartenions, and it tells you how your arm's angled compared to your body's vertical axis.</p>\n<p>I even went the extra mile and used Blender to mimic how your arm rotates. But if you want to see it in action and make things crystal clear, check out this <a href=\"https://youtu.be/KGpMEk3TSYs\" target=\"_blank\">video</a>. It'll make things click!</p>\n<p>y-angle for yellow-line, x-angle for red-line and z-angle for blue-line</p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F7260255%2F4e1bcf36a14ce590de7093d41b1e1883%2FOpera%20Snapshot_2023-09-15_104707_www.youtube.com.png?generation=1694771259527993&amp;alt=media\" alt=\"\"></p>",
      "votes": 8,
      "replies": [
        {
          "id": 2440464,
          "author_name": "Marília Prata",
          "author_url": "",
          "post_date": "2023-09-15T14:26:14.333000",
          "content": "<p>Awesome video. I loved it Paulo!</p>\n<p>Do we have an W angle? (Rotation is showing a W)</p>",
          "votes": 1,
          "replies": [
            {
              "id": 2440728,
              "author_name": "pauloyuncha",
              "author_url": "",
              "post_date": "2023-09-15T17:31:13.503000",
              "content": "<p>Hi Marilia!  w,x,y and z parameters do not directly correspond to the x, y, and z components in Euler angles. In the case of quaternions, each of these parameters is a normalized floating-point value ranging from 0 to 1. So there is no direct representation in the X,Y and Z dimensions.<br>\nBtw, I mentioned your notebook in my <a href=\"https://www.kaggle.com/code/pauloyuncha/eda-which-makes-sense-beta\" target=\"_blank\">EDA notebook</a> and i explained a little bit about w value :)</p>",
              "votes": 3,
              "replies": []
            },
            {
              "id": 2440730,
              "author_name": "Marília Prata",
              "author_url": "",
              "post_date": "2023-09-15T17:34:34.783000",
              "content": "<p>I added your video to a new Notebook. </p>",
              "votes": 1,
              "replies": []
            }
          ]
        },
        {
          "id": 2442297,
          "author_name": "",
          "author_url": "",
          "post_date": "2023-09-16T21:53:20.460000",
          "content": "",
          "votes": 3,
          "replies": [
            {
              "id": 2442300,
              "author_name": "Marília Prata",
              "author_url": "",
              "post_date": "2023-09-16T22:01:52.577000",
              "content": "<p>Hi Simon,</p>\n<p>Instead of lambs we can count quartenions. Even to pronounce it is hard. It's good to sell watches. Which is weird to sleep with any kind of them too.</p>",
              "votes": 1,
              "replies": []
            }
          ]
        },
        {
          "id": 2444526,
          "author_name": "PatrickAIForFun",
          "author_url": "",
          "post_date": "2023-09-18T10:11:40.263000",
          "content": "<p>I appreciate your efforts of trying to visualize and explain the angle-z feature, BUT I strongly believe your understanding/visualization of it is WRONG. I don't want to come about as rude, I kust want to share my understanding of it and help clear up the confusion.<br>\nAs I've a lot of experience working with angle measurements from accelerometer data in the robotic field and have worked with wrist worn accelerometer data before, I hope I can clear up the confusion.<br>\nImagine wearing a wristwatch. This watch has an integrated accelerometer (as most smart watches do). The Z-Axis of this accelerometer is pointing upwards by convention. Thus, if you war the watch and look at the time, the Z-Axis is directly pointing into your face. If you leave your arms hanging, the Z-Axis of the watch is facing away from your body in the horizontal plane. Using accelerometer data, one can only measure/calculate the angle relative to the horizontal plane (because we basicslly measure the downwards direction relative to the device based on gravitational force). The angle described in your video (around the bodies vertical axis) however, can only be measured by a magnetometer (basically an electrical compass).<br>\nBased on this information, an angle-z of 0 degrees corresponds to a position, where you have your arms hanging down ans the watch is facing away from your body (in the horizontal plane). Looking at ypur watch (pointing it straight into the sky) would result in the maxium possible angle (90°, if the signal would be perfect). Contrary, looking at your palms (pointing the watch downwards into the ground) would result in -90°. (I am not 100% certain about the sign of the signal, whether up or down is negative, but it should not matter too much).</p>\n<p>Let me know what you think about this interpretation.</p>",
          "votes": 3,
          "replies": [
            {
              "id": 2444808,
              "author_name": "Marília Prata",
              "author_url": "",
              "post_date": "2023-09-18T13:45:27.190000",
              "content": "<p>Hi Patrick AI for Fun,</p>\n<p>I think downwards is negative angle (like xy axis on graphs).</p>\n<p>The 1st dataset I published on Kaggle was: \"Recording data with a swim log\".<br>\nWhere I uploaded my open water swim activity data.  Since I'm not a swimmer pro, each time I change the strokes and consequently ARM position/height. Whenever we perform Breaststyle or butterfly, the arm remains under the water/sea.  So the the GPS loses signal with the satellite.  And stop to record distance properly.  </p>\n<p>Many users blame the watch (my GarMin or any other brand), however it's the arm position that should be out of water to work as expected to record the correct distance. </p>\n<p>The same occurs while we are sleeping, since the arm (with the wrist watch) doesn't remain in the same position.  By the way, sleeping with a watch in your arm is a \"pain in the ass\". That disturbs my sleep. Avoid wearing watchs while you're sleeping. </p>\n<p>The innovative, stunning video made by Paulo shows someone standing up. <br>\nMaybe it's a sleepwalker/somnambulist?😓</p>\n<p>You mentioned: \" If you leave your arms hanging, the Z-Axis of the watch is facing away from your body in the horizontal plane.\"  In that case, even the size of the bed will affect the measurements, cause to any arm hangs and face away body in the horizontal plane, it seems that the bed is narrow (or the person is near the bed's boarder) for the arm to hang.   That's what I understood from your explanation/interpretation.</p>\n<h1>In other words, ARM position changes everything (at least for open water swimming).</h1>\n<p>Below, are the words that I wrote on my dataset, 4 years ago:</p>\n<p>\"Here, I collected data wearing a smart watch. Synchronizing GPS requires longitude, latitude and altitude above sea level information. Several times, we practice breastyle or even butterflystyle. In those kind of strokes, GPS loses signal and stops collecting distance’s data. Therefore, altitude above sea level is fundamental. It's easy to fix this: just raise the arm (wearing the watch) above the water. Signal will return enabling to update your distance score. Such tools are built thinking about better results. However, most part of customers disregard the altitude factor.\"  (And blame the watch for malfunction : )</p>\n<p>Thank you for the embracing explanation Patrick.</p>\n<p>Kind regards,<br>\nMarília.</p>",
              "votes": 2,
              "replies": []
            },
            {
              "id": 2446398,
              "author_name": "pauloyuncha",
              "author_url": "",
              "post_date": "2023-09-19T12:16:08.027000",
              "content": "<p>Hi <a href=\"https://www.kaggle.com/PatrickAIForFun\" target=\"_blank\">@PatrickAIForFun</a>! Thanks for sharing!! Very clear for beginner as me. By the way, have you experienced building iot devices such as wemos mini d1r1 and mpu 6050 or similiars for body tracking? </p>",
              "votes": 2,
              "replies": []
            },
            {
              "id": 2446437,
              "author_name": "PatrickAIForFun",
              "author_url": "",
              "post_date": "2023-09-19T12:40:39.330000",
              "content": "<p>I do have experience using the MPU6050 (6DOF) and the BNO055 (9DOF) mainly in the robotics field (in combination with ARM based microcontrollers)</p>",
              "votes": 2,
              "replies": []
            },
            {
              "id": 2456712,
              "author_name": "pauloyuncha",
              "author_url": "",
              "post_date": "2023-09-26T11:22:31.307000",
              "content": "<p>great, may i ask you something <a href=\"https://www.kaggle.com/patrickaiforfun\" target=\"_blank\">@patrickaiforfun</a>? i got quartenions from a parent bone and a child bone. What is the topic should i search to be able to update the child bone according to the parent bone? Plus, i want to represent the quartenions in a 2d plot x,y, is this possible? </p>\n<p>Kind regards, </p>",
              "votes": 2,
              "replies": []
            },
            {
              "id": 2456768,
              "author_name": "PatrickAIForFun",
              "author_url": "",
              "post_date": "2023-09-26T11:50:36.717000",
              "content": "<p><a href=\"https://www.kaggle.com/pauloyuncha\" target=\"_blank\">@pauloyuncha</a> Depending on your mathematical knowledge, the fundamentals in linear algebra are very useful for this kind of stuff. 3Blue1Brown made two good videos explaining quaternions intuetivley (<a href=\"https://www.youtube.com/watch?v=zjMuIxRvygQ\" target=\"_blank\">Quaternions and 3d rotation, explained interactively</a>; <a href=\"https://www.youtube.com/watch?v=d4EgbgTm0Bg\" target=\"_blank\">Visualizing quaternions (4d numbers) with stereographic projection</a>).<br>\nWorking with quaternions has its benefits: For example having a parent bone with an absolute rotation given as a quaternion and a child bone with quaternions given as the relative angle, you can simple multiply these quaternions to obtain the absolute angle of the child bone.<br>\nA 2d plot will not work, because we are dealing with angles in 3d space (3 degrees of freedom), no matter how we encode these angles (quaternions, axis-angle, euer angles) you simply can not plot them with only 2 degrees of freedom. If you do have constraints on your angles (for example, the elbow can not rotate in any arbitrary direction, thus you do loose a degree of freedom), you might be able to transform these values to plot them in 2d. Regarding this, I would research Inverse Kinematics.<br>\nHowever, I suspect there are solutions already existing out there for your problem if it is not highly specialized (in which case a thorough understanding of linear algebra, quaternions, angle transformations, … are needed).</p>\n<p>Hope this helps!</p>",
              "votes": 2,
              "replies": []
            }
          ]
        }
      ]
    },
    {
      "id": 2443442,
      "author_name": "Rimba Erlangga",
      "author_url": "",
      "post_date": "2023-09-17T18:00:35.853000",
      "content": "<p>I am kind of confused that MAD actually could stand for Mean Amplitude Deviation or Median Absolute Deviation (as <a href=\"https://www.nature.com/articles/s41598-020-79217-x\" target=\"_blank\">described here</a>).</p>\n<p>I am currently using the later one, thanks to your discussion I will try to add the first MAD.</p>",
      "votes": 1,
      "replies": [
        {
          "id": 2443499,
          "author_name": "Marília Prata",
          "author_url": "",
          "post_date": "2023-09-17T18:24:10.993000",
          "content": "<p>I've just transcribed what I've found about MAD on the article. I don't have the capacity to apply that MAD metric.</p>",
          "votes": 1,
          "replies": [
            {
              "id": 2444280,
              "author_name": "Rimba Erlangga",
              "author_url": "",
              "post_date": "2023-09-18T08:37:11.097000",
              "content": "<p>Great, no worries Marilia. You just ignited a discussion which some person might find very helpful.</p>",
              "votes": 1,
              "replies": []
            },
            {
              "id": 2444731,
              "author_name": "Marília Prata",
              "author_url": "",
              "post_date": "2023-09-18T12:51:49.373000",
              "content": "<p>You're a DS professional. For me everything is new, every single day reading stuff that I've never read before.</p>",
              "votes": 0,
              "replies": []
            },
            {
              "id": 2444857,
              "author_name": "Rimba Erlangga",
              "author_url": "",
              "post_date": "2023-09-18T14:14:08.667000",
              "content": "<p>No I am not, I am just a junior in DS trying to figure out things. At this point, we and everyone here are learning continuously from this competition. Thank you for your humbleness.</p>",
              "votes": 1,
              "replies": []
            }
          ]
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "2425633": "#Distribution of Change in Z-Angle\n\nEstimating sleep parameters using an accelerometer without sleep diary\n\nCitation: van Hees, V.T., Sabia, S., Jones, S.E. et al. Estimating sleep parameters using an accelerometer without sleep diary. Sci Rep 8, 12975 (2018). https://doi.org/10.1038/s41598-018-31266-z\n\n\"Wrist worn raw-data accelerometers are used increasingly in large-scale population research. The authors examined whether sleep parameters can be estimated from these data in the absence of sleep diaries. Their heuristic algorithm used the variance in estimated z-axis angle and makes basic assumptions about sleep interruptions.\"\n\n\"Detected sleep period time window (SPT-window) was compared against sleep diary in 3752 participants (range = 60–82 years) and polysomnography in sleep clinic patients (N = 28) and in healthy good sleepers (N = 22). \"\n\n\"The SPT-window derived from the algorithm was 10.9 and 2.9 minutes longer compared with sleep diary in men and women, respectively. Mean C-statistic to detect the SPT-window compared to polysomnography was 0.86 and 0.83 in clinic-based and healthy sleepers, respectively. We demonstrated the accuracy of our algorithm to detect the SPT-window. The value of this algorithm lies in studies such as UK Biobank where a sleep diary was not used.\"\n\nhttps://www.nature.com/articles/s41598-018-31266-z\n\n#Z-Angle presented by Van Hees (2018)\n\n\"From the use of accelerometers, it's possible to estimate different variables related to sleep, such as duration and efficiency. For this, The authors have used the Heuristic algorithm, looking at Distribution of Change in z-Angle presented by Van Hees (2018). This algorithm identifies the longest period of inactivity within 24 hours, with the least number of interruptions, classifying as a sleep period.\"\n\nhttps://eleva.ufsc.br/en/acelerometros/\n\n#Euclidean Norm Minus One (Enmo) and Mean Amplitude Deviation (MAD)\n\nIntensity Thresholds on Raw Acceleration Data: Euclidean Norm Minus One (ENMO) and Mean Amplitude Deviation (MAD) Approaches\n\nCitation: Bakrania K, Yates T, Rowlands AV, Esliger DW, Bunnewell S, Sanders J, et al. (2016) Intensity Thresholds on Raw Acceleration Data: Euclidean Norm Minus One (ENMO) and Mean Amplitude Deviation (MAD) Approaches. PLoS ONE 11(10): e0164045. https://doi.org/10.1371/journal.pone.0164045\n\n\" To develop and internally-validate Euclidean Norm Minus One (ENMO) and Mean Amplitude Deviation (MAD) thresholds for separating sedentary behaviours from common light-intensity physical activities using raw acceleration data collected from both hip- and wrist-worn tri-axial accelerometers; and to compare and evaluate the performances between the ENMO and MAD metrics.\"\n\n#Sedentary Behaviours\n\n\"Researchers can utilise these robust monitor-specific hip and wrist ENMO and MAD thresholds, in order to accurately separate sedentary behaviours from common motion-based light-intensity physical activities. However, caution should be taken if isolating sedentary behaviours from standing is of particular interest.\"\n\nhttps://journals.plos.org/plosone/article?id=10.1371/journal.pone.0164045",
    "2440136": "I spent some time wrapping my head around what \"z-angle\" really means in geospatial jargon. Basically, it's a metric pulled from individual accelerometer readings expressed in quartenions, and it tells you how your arm's angled compared to your body's vertical axis.\n\nI even went the extra mile and used Blender to mimic how your arm rotates. But if you want to see it in action and make things crystal clear, check out this [video](https://youtu.be/KGpMEk3TSYs). It'll make things click!\n\ny-angle for yellow-line, x-angle for red-line and z-angle for blue-line\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F7260255%2F4e1bcf36a14ce590de7093d41b1e1883%2FOpera%20Snapshot_2023-09-15_104707_www.youtube.com.png?generation=1694771259527993&alt=media)\n",
    "2443442": "I am kind of confused that MAD actually could stand for Mean Amplitude Deviation or Median Absolute Deviation (as [described here](https://www.nature.com/articles/s41598-020-79217-x)).\n\nI am currently using the later one, thanks to your discussion I will try to add the first MAD."
  }
}