{"id":909,"date":"2017-11-08T11:03:04","date_gmt":"2017-11-08T16:03:04","guid":{"rendered":"http:\/\/haleyai.com\/wordpress\/?p=909"},"modified":"2018-07-14T17:18:00","modified_gmt":"2018-07-14T22:18:00","slug":"artificially-intelligent-physical-therapy","status":"publish","type":"post","link":"http:\/\/haleyai.com\/wordpress\/2017\/11\/08\/artificially-intelligent-physical-therapy\/","title":{"rendered":"Artificially Intelligent Physical Therapy"},"content":{"rendered":"<p>Over the last 25 years we have developed two generations of AI systems for physical therapy.\u00a0 The first was before the emergence of the Internet, when Windows was 16 bits.\u00a0 There were no digital cameras, either.\u00a0 So, physical therapists would take Polaroid pictures; anterior and left and right lateral pictures or simply eyeball a patient and enter their posture into the computer using a diagram like the following:<\/p>\n<p><a href=\"http:\/\/haleyai.com\/wordpress\/wp-content\/uploads\/StickFigureDiagram.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-910\" title=\"StickFigureDiagram\" src=\"http:\/\/haleyai.com\/wordpress\/wp-content\/uploads\/StickFigureDiagram.png\" alt=\"\" width=\"776\" height=\"697\" srcset=\"http:\/\/haleyai.com\/wordpress\/wp-content\/uploads\/StickFigureDiagram.png 776w, http:\/\/haleyai.com\/wordpress\/wp-content\/uploads\/StickFigureDiagram-300x269.png 300w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/a><\/p>\n<p><!--more-->Therapists could also enter left-to-right balance and front-to-back weight bearing for each foot.\u00a0 In the anterior view you can see that pronation or supination could also be input.\u00a0 In the superior view, you can see that inverted or everted feet and knees were captured.\u00a0\u00a0 In the lateral views you can also input shoulder protraction.\u00a0 We\u2019ll skip over how spinal curvatures was considered here.<\/p>\n<p>Today we use vision and a balance board and\/or a foot pressure mat.\u00a0 First let\u2019s go over the basics and then dive into the vision\u2026<\/p>\n<p>The following shows the estimated locations of a person\u2019s joints from three of the four perspectives diagrammed above.\u00a0 Practically speaking, this is the same information rendered a different way, but it\u2019s a lot easier to capture and the subjectivity is gone.\u00a0 Polaroids are long gone, but the vision system also eliminates loading of files from digital cameras.<\/p>\n<p><a href=\"http:\/\/haleyai.com\/wordpress\/wp-content\/uploads\/3Dskeleton.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-912\" title=\"3Dskeleton\" src=\"http:\/\/haleyai.com\/wordpress\/wp-content\/uploads\/3Dskeleton.png\" alt=\"\" width=\"1002\" height=\"708\" srcset=\"http:\/\/haleyai.com\/wordpress\/wp-content\/uploads\/3Dskeleton.png 1002w, http:\/\/haleyai.com\/wordpress\/wp-content\/uploads\/3Dskeleton-300x211.png 300w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/a><\/p>\n<p>Getting the skeleton to be accurate enough for clinical purposes was not trivial.\u00a0 The camera has to be carefully set up on a tripod with the right pitch and no roll, for example.\u00a0 Easy said than done across dozens of clinics!\u00a0 The software helps, though.<\/p>\n<p>The Microsoft software estimates joint locations by matching a random forest of decision trees against the depth image it perceives.\u00a0 Rather than going into the details, let me just say that the Kinect was effectively trained to locate joints better in two dimensions than three.\u00a0 And the approach taken will never be accurate with baggy clothing.<\/p>\n<p>The Kinect is a reliable device, but it is also cumbersome and power hungry.\u00a0 More importantly, from the standpoint of perception, it does not have the resolution or accuracy of devices such as Intel\u2019s RealSense camera which is cheaper and doesn\u2019t require a power adapter.\u00a0 Also, Microsoft is no longer manufacturing the Kinect.<\/p>\n<p><a href=\"http:\/\/haleyai.com\/wordpress\/wp-content\/uploads\/RealSenseR200.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-921\" title=\"RealSenseR200\" src=\"http:\/\/haleyai.com\/wordpress\/wp-content\/uploads\/RealSenseR200.png\" alt=\"\" width=\"544\" height=\"124\" srcset=\"http:\/\/haleyai.com\/wordpress\/wp-content\/uploads\/RealSenseR200.png 544w, http:\/\/haleyai.com\/wordpress\/wp-content\/uploads\/RealSenseR200-300x68.png 300w\" sizes=\"auto, (max-width: 544px) 100vw, 544px\" \/><\/a><\/p>\n<p>To use the RealSense we had to find or write our own skeleton tracking \/ joint position estimation software.\u00a0 After an extensive review of the literature and evaluation of many pieces of software, I decided to write it as described further below.\u00a0 First, a few comments.\u00a0 Convolutional neural nets (CNN) do a marvelous job in 2 dimensions using only image data (no depth).\u00a0 We will integrate their estimates with the approach and work on 3-dimensional versions that incorporate depth information, whether from the RealSense or stereo cameras without depth (the RealSense is a stereo camera that uses an infrared laser to \u201chelp\u201d).<\/p>\n<p>Skipping over a lot of research, we decided to focus on two things:\u00a0 a simple geometric model of an articulating body and a much more detailed polygonal mesh covering a model of the body.\u00a0 The geometric model consists of spheres and sections of cones or cylinders that articulate at joints.\u00a0 The mesh model has thousands of polygons each with a surface normal that is oriented according to a linear model.\u00a0 The linear equation is based on principal components of how the mesh best fits a number of different scans of people in various but mostly standing poses.\u00a0 The geometric model is astonishingly fast and useful for getting pose information and joint positions.\u00a0 The latter model gives more accurate joint positions (not to mention body parameters).<\/p>\n<p>The following picture may give you an idea of how such models \u201cfits\u201d various body types:<\/p>\n<p><a href=\"https:\/\/ps.is.tue.mpg.de\/uploads\/research_project\/image\/105\/extra_slide_min.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" src=\"https:\/\/ps.is.tue.mpg.de\/uploads\/research_project\/image\/105\/extra_slide_min.jpg\" alt=\"\" width=\"5100\" height=\"3400\" \/><\/a><\/p>\n<p>Each of these articulating approaches performs more robustly than the Microsoft approach for loosely clothed bodies.<\/p>\n<p>The articulating geometric model is too easy to go into, so let\u2019s talk a little more about the body mesh approach.<\/p>\n<p>There are a few ways to go about this.\u00a0 You can obtain high resolution scans of people from various places or you can obtain your own using Kinect Fusion.\u00a0 Next, you need a body mesh with appropriate details where you care to have them.\u00a0 You can take your point cloud data and get a variety of such meshes or you can use a mesh such as you might find in animation software.\u00a0 Then you fit the mesh to each of your scans.\u00a0 Then you compute at least a dozen to perhaps a hundred principal components.<\/p>\n<p>Once you have the principal components you have an optimization problem.\u00a0 The basic idea is to find the body model parameters that best fit the depth map you obtain from the Kinect or RealSense or other stereoscopic camera setup.<\/p>\n<p>There are many details to be considered, but the first is pose.\u00a0 For example, if you can assume the person is standing facing the camera, it\u2019s a lot easier to adjust the parameters to the data.\u00a0 Pose includes joint angles and bone lengths, which are most of the parameters in an articulating geometric model.\u00a0 So, the first thing you can do is use the simple model to estimate those parameters or fit the body mesh while only optimizing on the pose parameters (holding the body type parameters constant).<\/p>\n<p>Once you have the articulating geometry fit, you can continue to estimate the body model and, if you want the best results, repeat until changes to the parameters quiesce (among other cutoff criteria).\u00a0 The estimation itself seeks to minimize error.\u00a0 One way of characterizing the error minimization problem is least mean squared error where the error is the difference between the depth map perceived and the surface of the body model represented by the mesh.\u00a0 Each iteration seeks to reduce the error by adjusting the parameters.\u00a0 This is typically done using some form of gradient descent.\u00a0 We use a popular, open-source machine learning package to do this job.<\/p>\n<p>Here&#8217;s an example of how the approach can perform, although we do not take exactly the same approach:<\/p>\n<p><a href=\"https:\/\/youtu.be\/OimYQMgqnqM\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-916\" title=\"3DBodyScanningBlack\" src=\"http:\/\/haleyai.com\/wordpress\/wp-content\/uploads\/3DBodyScanningBlack.png\" alt=\"\" width=\"652\" height=\"475\" srcset=\"http:\/\/haleyai.com\/wordpress\/wp-content\/uploads\/3DBodyScanningBlack.png 652w, http:\/\/haleyai.com\/wordpress\/wp-content\/uploads\/3DBodyScanningBlack-300x218.png 300w\" sizes=\"auto, (max-width: 652px) 100vw, 652px\" \/><\/a><\/p>\n<p>I would like to go into some of the other aspects, such as how we learn the efficacy of exercises for various postures but that\u2019s all for now!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Over the last 25 years we have developed two generations of AI systems for physical therapy.\u00a0 The first was before the emergence of the Internet, when Windows was 16 bits.\u00a0 There were no digital cameras, either.\u00a0 So, physical therapists would take Polaroid pictures; anterior and left and right lateral pictures or simply eyeball a patient &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/haleyai.com\/wordpress\/2017\/11\/08\/artificially-intelligent-physical-therapy\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Artificially Intelligent Physical Therapy&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[195,716],"tags":[],"class_list":["post-909","post","type-post","status-publish","format-standard","hentry","category-machine-learning","category-vision"],"_links":{"self":[{"href":"http:\/\/haleyai.com\/wordpress\/wp-json\/wp\/v2\/posts\/909","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/haleyai.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/haleyai.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/haleyai.com\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/haleyai.com\/wordpress\/wp-json\/wp\/v2\/comments?post=909"}],"version-history":[{"count":15,"href":"http:\/\/haleyai.com\/wordpress\/wp-json\/wp\/v2\/posts\/909\/revisions"}],"predecessor-version":[{"id":925,"href":"http:\/\/haleyai.com\/wordpress\/wp-json\/wp\/v2\/posts\/909\/revisions\/925"}],"wp:attachment":[{"href":"http:\/\/haleyai.com\/wordpress\/wp-json\/wp\/v2\/media?parent=909"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/haleyai.com\/wordpress\/wp-json\/wp\/v2\/categories?post=909"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/haleyai.com\/wordpress\/wp-json\/wp\/v2\/tags?post=909"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}