Do not know how to normalize gait cycles from 0-100%

31 visualizaciones (últimos 30 días)
Nathan
Nathan el 20 de Dic. de 2023
Comentada: Star Strider el 20 de Dic. de 2023
Visualize joint angles. Next, write a function that takes the right heel strikes and a data matrix, separates that matrix into gait cycles, and normalizes them from 0- 100% of the gait cycle. Apply this function to the EMG and IK data for every trial. (Hint: use the interp1 function to normalize the data to be 101 points long). For each subject and walking condition, calculate the mean joint angle trajectories across all gait cycles and trials. Then calculate and plot the mean and standard deviation trajectories across all subjects of the hip, knee, and ankle flexion for both legs and both walking conditions. Plot treadmill and level ground walking in the same plot (you should have a figure with 6 subplots and each subplot should have two sets of mean and standard deviations). See the example figure below, which shows the mean and standard deviation from only treadmill walking. By visually observing these plots, does the inter-subject joint angle variability seem to differ between the two conditions? Include both the plots and observations in your report.
This is how the data is stored.
%% Load the relevant data into MATLAB
clc
clear all
% Loads the 'Treadmill' data into a datastucture
subjects = {'AB09', 'AB10', 'AB11', 'AB12', 'AB13', 'AB14', 'AB16'}; % Defines a cell array that contains the names of the different subjects.
dates = {'10_21_2018', '10_28_2018', '10_28_2018', '11_04_2018', '11_04_2018', '11_25_2018', '11_11_2018'}; % Defines a cell array that contains the dates that contains corresponding date strings.
for i = 1:length(subjects) % Starts a for loop, that iterates over the indices from 1 to the length of the 'subjects'.
filepath = strcat('/Users/nathanvermaerke/Downloads/MATLAB_Assignment/Data/',(subjects{i}),'/',(dates{i}),'/treadmill/'); % Constructs a filepath for each iteration
Data.treadmill(i).subjects = subjects{i}; % Assigsn subject the the 'subjects' field of the data structure.
Data.treadmill(i).ik = load(filepath+"ik/treadmill_07_01.mat"); % Loads the Inverse Kinematics data from a MAT-file.
Data.treadmill(i).emg = load(filepath+"emg/treadmill_07_01.mat"); % Loads the EMG-data from a MAT-file.
Data.treadmill(i).conditions = load(filepath+"conditions/treadmill_07_01.mat"); % Loads the conditions data from a MAT-file.
Data.treadmill(i).gcRight = load(filepath+"gcRight/treadmill_07_01.mat"); % Loads the Inverse gcRight data from a MAT-file.
end
% Levelground
for i = 1:length(subjects) % Starts a for loop, that iterates over the indices from 1 to the length of the 'subjects'.
filepath = strcat('/Users/nathanvermaerke/Downloads/MATLAB_Assignment/Data/',(subjects{i}),'/',(dates{i}),'/levelground/'); % Constructs a filepath for each iteration
folderlist = struct2table(dir(strcat(filepath, 'ik/')));
triallist = folderlist.name;
triallist_logical = contains(triallist, 'ccw_normal_');
trials = triallist(triallist_logical);
% These lines list and filter the files in the "ik" directory. It uses the dir function to get the file information,
% converts the structure to a table using struct2table, extracts the file names, checks which names contain the substring
% 'ccw_normal_', and creates a list of trials accordingly.
for k = 1:length(trials) % Starts a nested for loop that iterates over the trials for the current subject and date.
Data.levelground(i).subjects = subjects{i}; % Assigsn subject the the 'subjects' field of the data structure.
trialName = strcat('trial', num2str(k)); % creates a trial name by concatenating the string 'trial' with the current trial index converted to a string.
Data.levelground(i).ik.(trialName) = load(strcat(filepath,"ik/",trials(k)));
Data.levelground(i).emg.(trialName) = load(strcat(filepath,"emg/",trials(k)));
Data.levelground(i).conditions.(trialName) = load(strcat(filepath,"conditions/",trials(k)));
Data.levelground(i).gcRight.(trialName) = load(strcat(filepath,"gcRight/",trials(k)));
% These lines load data for each trial and store it in the respective fields of the Data.levelground structure.
% Each trial's data is loaded and associated with its corresponding trial name.
end
end

Respuesta aceptada

Star Strider
Star Strider el 20 de Dic. de 2023
To normalise the time variables within a gait cycle, divide them by the heel-strike time differences in each cycle. The same approach applies to other variables within each gait cycle, depending on how you want to normalise them.
That is how I would do it, although the problem statement lacks a broader context, so I am not certain what is to be normalised.
  2 comentarios
Nathan
Nathan el 20 de Dic. de 2023
Thank you for your answer!
I have already calculated each heelstrike and I already know the gait cycles for each trial per subject, but now I need to write a function that uses this to create a data matrix where I have a column for each gait normalized (0-100%). That's what I think, but I don't know where to start with this.
Maybe this gives you some more context, this also part of the question of the assigment.
"Write a function that takes the heel strike (HS) and toe- off (TO) event times, calculates and outputs the stride duration, stance time, and swing time. For the kth gait cycle:
  • Stride duration = HS(k+1) – HS(k)
  • Stance time = TO(k) – HS(k)
  • Swing time = HS(k+1) – TO(k)
Write a function that calculates the coefficient of variation using the following formula: CV = std/averageUse your function to calculate the coefficient of variation of stride duration, stance time, and swing time in treadmill and level ground walking (right leg only) for each subject (so you will have 6 values per subject). Use boxcharts to visualize the coefficient of variation of each variable and condition, and use paired t-tests to compare the coefficient of variation of each variable between walking conditions (see the documentation for ttest – here you will perform 3 t-tests)."
Thank you in advance.
Sincerely
A desperate student
Star Strider
Star Strider el 20 de Dic. de 2023
I certainly understand about being under time pressure and having to figure out how to complete a project successfully!
I would normalise the times by stride duration, since that appears to be the longest time in every gait cycle. Those should be relatively straightforward to calculate.
For the coefficient of variation calculation, you need to use a vector of all the absolute (as opposed to normalised) times for each parameter. The best measure of variation in a mean is the standard error of the mean, that being the mean divided by the square root of the number of observations. It is used to calculate the confidence interval of the mean if you need to do that.
Use the ttest function for the paired t-tests. (Paired tests compare each study participant with themselves, rather than an unpaired test between study participants.)
It is not obvious to me if you are supposed to compare the t-test results. If you are, the multcompare function could be helpful. (I believe that I linked to the correct one here.)
There are two slightly different functions for the box charts, one being boxchart and the other being boxplot. The swarmchart function could add information.
Let me know if you have other concerns or need clarification. I know from experience that this can be a bit daunting when first encountered.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Labels and Styling en Help Center y File Exchange.

Productos


Versión

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by