MATLAB: Biomechanics Tutorial - Normalize Data to Support Phase (0-100%)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
what's going on everybody today I'm gonna go through a quick video about how to take data and normalize it from zero to 100% of the support phase I'm going to be using a script that I wrote a few days ago and posted a video about I will link to that in the description it's a pretty simple code it's just loading in a data structure called grf example dot matt and inside of this data structure we've got ground reaction forces in three dimensions and I'm gonna be using the vertical ground reaction force just to show you what this data looks like in the vertical it is multiple steps and it's just the vertical ground reaction force for each of those steps and what I did last week is I took a simple for loop and figured out when the heel strikes and toll offs were some people did point out to me and this is important that you can do this without using this for loop structure but just for continuity sake I'm gonna keep it here if you did have a really long data set you do want to try to avoid loop structures like this to save time so always try to vectorize if possible and you can do that using a few different options for heel strike and toe off identification alright so just to show you what those look like we'll go ahead and plot so you can see we've got red indicate heel strikes and green circles indicate toe offs and so you can see that we found these for each of these ten steps we found them and they look like they are in the appropriate location so we did accurately find those heel strike and tell off gate events and then what I did is I set up a a for loop that would go through each individual support phase and pull out the support time and the peak vertical ground reaction forces so let's just run this quickly show you what it does so if we look at support time for example what we're gonna see is that we get a bunch of different numbers so the first step took point seven three four seconds the next one is seven four seven seconds point seven to eight and what this means is that the data for each of these curves are different lengths and so therefore they're gonna they're gonna be different so if you were trying to do something for a manuscript like average across all of these steps so that you can get it on sambal curve for a figure it's gonna be very difficult because they're different lengths and so a common way to deal with this problem is to refit them from 0 to 100 percent prior to averaging across and then giving giving whoever given the reader an average curve so what I'm gonna do is just very quickly write some code that will take each of these data curves and transform it from 0 to 100% this is relatively easy I'm going to do it within this loop because we're going to do it for each step and I'm going to gather all of these into a into a single matrix and this will make it easier at the end to average across all of the columns so normalized GRS and I'm just gonna call this normalized ERF B will set this empty ok and now what I'm gonna do is I'm going to actually come into this for loop and normalize all of these steps though the first thing that we want to do is figure out the length of the data that we have and we're going to use and we're gonna basically we have to Reese this data and we're gonna end up ultimately using matlab's built-in spline function and spline requires a few things the first thing that we're gonna do is call linspace we're gonna say 0 99 and then we're calling in the length of the data that we want to evenly spaced out between 0 and 99 and that's gonna be GRF z from you'll strike the strikes okay whoo who off okay all right this is gonna do is it's gonna take the length of our data and space it normally from 0 to 99 okay then what we need to do is just create a variable I'll call it new length and that's going to be 0 99 now we get to use matlab's built-in spline function we're gonna say the grf the normed is equal to spline and then inside a spline what we're gonna pull is 8 a length and then we're gonna pull in GRF z we're gonna give it the data that we want to actually fit which again is from heel strikes a to gloss okay and then the last thing that we need to give spline is this new length okay let's make sure that we have this right in length and then we've got gr FC from heel strikes K 2 tow us K I actually think that we need that there and then this one can be taken off and then new length okay then the last thing that we're gonna do is just gather this so normalized PRF the we'll say all rows of the K column so what this is gonna do is on each each step is gonna have its own column within this matrix it's going to be equal to DRF the normed alright let's go ahead and run this and see what happens hopefully it works that runs just fine now normalized gr of Z should be a 100 by 10 double where each column is 100 rows and it is the actual ground reaction forces from each step that's what it looks like it is let's go ahead and plot these to make sure give ourselves some room here so we'll say figure hot and in MATLAB this is very easy we don't have to run any kind of for loop for this although you could if you wanted to normalize grf be well all of them on top of each other and you should see that they are all from zero to 100% in length and they are different from each other so it's not like it's the same one so this just shows that we took each one and normalized it from zero to 100% right now if you wanted to find the average of these what you could do is you could say mean GRF is equal to the mean of normalized PRF be 2 and that 2 is going to specify that you want to average across across columns so we'll evaluate that and this should be a single single column of 100 rows 100 by 1 double and this should be the average of all of those so let's go ahead and plot that to make sure that that's what that is mean PRF and there you have it and now let's make this a little bit better looking take all of them we'll plot all of them and then we're gonna say hold on and we're gonna plot the meaning ground reaction force and black and we're gonna make the line width larger so that it sticks out of it the line would do this way we'll see the mean on top of all of individual trials so there you have it right that thick black line is the mean and then you can see all of the other ground reaction forces each trial behind the mean you could do the same thing with the standard deviation and then instead of calling mean you would just call standard deep mallow standard deviation built-in function and then you would get the standard deviation you can go plus or minus one at each percent and then could maybe put some shading behind that mean ground reaction force curve okay I hope you enjoyed that video if you did please give it a thumbs up subscribe to my channel for more of this I will point out that the idea for this particular video came from a youtube comment someone asked me to do something like this so I am reading the comments and I'd be happy to take other suggestions and if I can do it I'm happy to and I'm happy to try to do things even if I don't currently know how to do them you should always keep trying to learn ok you can also find me on Twitter you find me on LinkedIn you can find a lot of my codes up on github and of course you can keep watching me here on YouTube alright until next time keep coding
Info
Channel: Dev Dan
Views: 846
Rating: 5 out of 5
Keywords: MATLAB, biomechanics, gait analysis, gait, forces, ground reaction force, code, programming
Id: KDNZaDUDY2c
Channel Id: undefined
Length: 9min 25sec (565 seconds)
Published: Wed Apr 08 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.