You are on page 1of 44

How to utilize the Margin

of Stability code.
Last Updated: 6/26/2014

1. We begin in Cortex

2. Make sure View Planes Show


Analog and 3D Views.

3. Analog Graphs F1Z and F3Z need


to be selected

Right click on the analog


graph window

4. Once completed final cortex


window should look as such.

F2
Z

5. Now we trim the data.


We trim the data in order to look at
the MoS during either single or
double support.
So we have to utilize the analog force
plate data in order to approximate
when the subject is in either single or
double support.
So depending on if you want to
gather MoS data for single or double
support the manner in which you

5. Now we trim the data.

SINGLE SUPPORT

DOUBLE SUPPORT

5. Now we trim the data.


Single support data
must be selected in
cortex running
from one peak of
the curve to the
second peak of the
force platform
curve.

SINGLE SUPPORT

5. Now we trim the data.


Double support can be
trimmed at two different
points, but consistency is KEY.
Double support exists from
the beginning/end of the
curve to approximately the
peak of the first/last hump,
dependent on what portion of
the gait cycle one wishes to
select.
REMEMBER APPROXIMATELY
TO THE PEAK! NOT AT THE
PEAK otherwise one enters
single support.
DOUBLE SUPPORT

6. Trim selected data.


Select trim capture w/options
under the File menu option.
Make sure that Save Selected
Frames is selected.
Provide the location at which you
wish to save it, with an appropriate
naming convention that you can use
consistently across trials and
subejcts.
The file naming convention
originally used was:
Folders: [Subject type][Subject #]
For example, MS08 or MSC08.

Files: Trimmed_Trimmed_[Subject Type]


[Subject #]C2_[Foot Used][Trial
Number]
For example, Trimmed_Trimmed_MS08C2_R5
or Trimmed_TrimmedMSC08C2_R5

7. Once you have trimmed all


necessary data, you may close Cortex.
The files we are concerned with are the .trc
files. Opening them in excel should reveal
XYZ data for all markers across the trimmed
frames.

NOW WE BEGIN WITH


MATLAB
SETTING UP THE DATA FOR
ANALYSIS

1. Open Matlab
Prior to calculating the MoS we must
organize the raw data from the
trimmed .trc files.
In order to organize this data we
have two sets of MATLAB code.
One set of code for Single Support
and a separate set for Double
Support
For each set of code you will organize
left and right foot data separately.

1. Open Matlab
For Single Support .trc organization one will use
the following files:
Write_Trimmed_Files_For_Analysis_Right_Foot_SACRA
L_SHIFT.m
Write_Trimmed_Files_For_Analysis_Left_Foot_AP_Sacr
al_Shift.m

For Double Support .trc organization one will use


the following files:
Write_Trimmed_Files_For_Analysis_Right_Foot_DS_Shif
t.m
Write_Trimmed_Files_For_Analysis_Left_Foot_DS_Shift.
m

2. Open Appropriate File for .trc


Organization (Single or Double Support?)

The steps necessary for one to use


the code for Single and Double
Support are identical.
So for the purposes of demonstrating
how to utilize the organization code I
will use Double Support Code.

3. Specify Subjects to be Analyzed.

When you run the data organization


code, you must specify which
subjects you wish to look at.
In this case I am looking at all of the
subjects with MS listed here.
So I enter their subject number or
FOLDER_NUMBER between the two
[..] brackets.

4. Specify Total Number of


Subjects Analyzed
Here we specify the total number of subjects we wish to
organize.
The line of code you are to change begins with
for folder_count = 1:1
The portion after the equals sign will always begin with 1:1
It is the final number on that line which in the picture below is 10,
that will be changed from time to time depending on the total
number of subjects to be analyzed.
As specified in STEP 3 we are going to look at 10 MS Subjects in
this example.

5. Specify File Name and


Location

5. Specify File Name and


Location
sheet_read is the
variable where the
location of the folder and
.trc file are stored.
My folders for this
example were located at:
F:\Thesis_Files\Double_Su
pport_Trimmings\...

5. Specify File Name and


Location
Once you have located
your folders you must
enter the name of the
folder MINUS the SUBJECT
NUMBER.
The name of my folders
was MS therefore I
typed MS, BUT I did NOT
type the subject number.

5. Specify File Name and


Location
Now we must specify the specific FILE
MINUS the SUBJECT NUMBER and TRAIL
NUMBER.
My files were titled, Trimmed_Trimmed_M
It was listed without the subject and trail
number.
BUT youll notice that the subject and trail
number surround the condition number,
C2_L.
Youll also notice that the condition
number was still listed. So file and folder
names are allowed to be broken up with
variable names.

5. Specify foot used


Write a L to indicate LEFT FOOT.
Write a R to indicate RIGHT FOOT.

5. Specify File Type


All files should be trc, so place .trc after
rootname.

5. Specify Output File Name


The output file name is at your discretion,
but be sure to include a underscore at
the end of your file name because
subject number is added when the file is
output.

5. Specify Number of trails per


Subject
Here we specify the total number of trails per subject:
The line of code you are to change begins with
for counter_file = 1:1
The portion after the equals sign will always begin with 1:1
It is the final number on that line which in the picture below is
5, that will be changed from time to time depending on the
total number of trails per subject.
The number of trails per subject MUST be the SAME for ALL
SUBJECTS that you listed within STEP 3 (folder_count).

6. Run the code!


Now that you have successfully entered
all the information you can run the code
by clicking on the green play button!

6. How the output file should look!


(Number of Sheets)
Each output file for each subject (left or right
foot) should have a number of sheets equal to
the number of trails you conducted per foot
plus one (in this case we conducted 5 trails
plus one, so six sheets).
The first sheet (Sheet M) contains the data
necessary to calculate leg length.
The remaining sheets (One through Five in this
case) represent either the left or right foot
trials, dependent upon what your specified for
foot_used.

6. How the output file should look!


(The layout of Sheet M)
Sheet M should
contain six columns.
The number of rows
are dependent upon
how you trimmed
the data and the
frames during which
the CoM (Sacral
Marker) is within the
Base of Support.

During Double
Support: Troch

During Double
Support: Troch

During Single
Support: Troch

During Single
Support: Troch

6. How the output file should look!


(The layout of Sheets 1,2,3)
Sheets 1,2,3
should contain nine
columns.
The number of rows
are dependent upon
how you trimmed the
data and the frames
during which the
CoM (Sacral Marker)
is within the Base of
Support.

During
Double
Support:
V. Sacral

During
Double
Support:
MTP LAT

During
Double
Support:
Cal Lat

During
Single
Support:
V. Sacral

During
Single
Support:
MTP Lat

During
Single
Support:
Heel

SECOND PHASE OF USING


MATLAB
CALCULATING THE MARGIN
OF STABILITY

1. Open Matlab
For all Margin of stability calculations
one can use the following file:
New_MoS_Cal_All.m

2. Specify Subjects for which MoS


will be calculated.
Before running the MoS code, one must specify which
subjects one wishs to calculate MoS for.
In this case I am looking at all of the same subjects with
MS listed within STEP 3 of the DATA ORGANIZATION
CODE, except now their marker positions are organized
for analysis.
So I enter their subject number or FOLDER_NUMBER
between the two [..] brackets.

3. Specify Total Number of Subjects


for which MoS will be Calculated
Here we specify the total number of subjects for which we wish
to calculate MoS.
The line of code you are to change begins with
for counter_MoS_file = 1:1
The portion after the equals sign will always begin with 1:1
It is the final number on that line which in the picture below is 10, that
will be changed from time to time depending on the total number of
subjects for which MoS will be calculated.
As specified in STEP 2 we are going to look at 10 MS Subjects in this
example.

4. Specify File Name and


Location
filename is the variable
where the location of the
file is stored.
My file was located at:
C:\Users\Sahibjit
Ranu\Downloads\Matlab_D
S\MS\Sacral_Shifted_DS_M
L\...

4. Specify File Name and


Location
Now we must specify the specific
FILE name MINUS the SUBJECT
NUMBER.
My files were titled,
Ordered_Data_ML_DS_MS_
It was listed without the subject
number.
BUT youll notice that the subject
number is followed by the foot
used and file type (L.xls).

5. Specify foot used


Write a L to indicate LEFT FOOT.
Write a R to indicate RIGHT FOOT.

5. Specify Type of MoS You Would


Like To Calculate
MoS_type = SS
This is used for ALL AP DATA regardless of
whether it is AP DOUBLE SUPPORT or AP
SINGLE SUPPORT.

MoS_type = DS_ML
This is used for ONLY DOUBLE SUPPORT in the
ML DIRECTION.

5. Specify File Type


All files should be .xls, so place .xls after
rootname.

5. Specify Output File Name


The output file name is at your discretion,
subject number and foot used is added
automatically when the file is output.

5. Specify Number of trails per


Subject
Here we specify the total
number of trails per subject:
The line of code you are to
change begins with
for sheet_count= 1:1
The portion after the equals
sign will always begin with
1:1
It is the final number on that
line which in the picture below
is 5, that will be changed from
time to time depending on the
total number of trails per
subject.
The number of trails per subject
MUST be the SAME for ALL
SUBJECTS that you listed within
STEP 2 (folder_number).

6. Run the code!


Now that you have successfully entered
all the information you can run the code
by clicking on the green play button!

6. How the output file should look!


(Number of Sheets)
Each output file for each subject (left or right foot)
should have 2 sheets.
Margin of Stability
Subject Averages

The first sheet (Margin of Stability) contains


margin of stability values for each frame. Each
column is a trail and each row is the margin of
stability value for that frame.
The second sheet (Subject Averages) lists out (in
the following order): the mean, maximum,
minimum, and range.

6. How the output file should look! (The


layout of the Margin of Stability Sheet)
The Margin of Stability
sheet should contain a
quantity of columns
equivalent to the number
of trials conducted.
The number of rows are
dependent upon how you
trimmed the data and
the frames during which
the CoM (Sacral Marker)
is within the Base of
Support.

Total Number of
Trials (5)

Total
Number
of Frame
over
which
the MoS
was
Calculat
ed.

6. How the output file should look! (The


layout of the Subject Averages sheet)
The Subject
Averages sheet
should contain four
columns.
The number of rows
is equal to one.
The columns are in
the following order:
Mean MoS, Maximum
MoS, Minimum MoS,
and Range of MoS.

Mea
n
MoS

Ma
x
Mo
S

Min
Mo
S

Rang
e of
MoS