Hi @Renee Wurfel ,
When analyzing your code, I did notice the error you're encountering when trying to read the CSV file in MATLAB, let's break down the key areas to check and troubleshoot. Make sure that the file `P02_S09_T01.csv` is located in the current working directory of MATLAB. You can check your current directory by using the command:
pwd
If the file is not in this directory, you can either move it there or specify an absolute path in your `readmatrix` function. For example:
raw_data = readmatrix('C:\path\to\your\file\P02_S09_T01.csv');
Now, addressing your query regarding, “To split the EMG signal into propulsion cycles, you need to identify the start and end points of each cycle. Since you have video documentation, you can visually confirm the timing of hand pushes and releases. Typically, this can be done by detecting peaks in the acceleration data or specific patterns in the EMG signal that correspond to the push phase.”
Please see my step by step instructions below.
Identify Propulsion Cycles
I do agree with @Taylor comments, “I would recommend using the findpeaks function. You can set a minimum amplitude value (Threshold) and minimum time between cycles (MinPeakDistance) if you have a rough idea of the frequency of contration cycles.” Use MATLAB’s `findpeaks` function on the acceleration or filtered EMG data to identify when the hand is pushing against the rim. For example:
[pks, locs] = findpeaks(acc_rms_signal, 'MinPeakHeight', threshold_value);
Here, `threshold_value` should be set based on your data characteristics to ensure only significant peaks are detected.
Define Cycles
Once peaks are identified, define each cycle by pairing successive peaks (push release) and calculate their indices for segmentation.
Segment EMG Data
With the identified cycle indices, segment your EMG data accordingly:
cycles = []; % Initialize a matrix to store segmented cycles
for i = 1:length(locs)-1
start_idx = locs(i);
end_idx = locs(i+1);
% Store each cycle in a cell array
cycles{i} = Biceps_Brachii(start_idx:end_idx);
end
Average Each Cycle
After segmentation, compute the average for each cycle:
average_cycles = cellfun(@mean, cycles);
This will give you a vector of average EMG values for each propulsion cycle.
Convert Time to Percentage of Cycle
To convert time into percentage of cycle duration:
cycle_durations = cellfun(@length, cycles);
percent_cycles = cellfun(@(x) (1:length(x)) / length(x) * 100, cycles,
‘UniformOutput', false);
This will yield a cell array where each entry corresponds to the percentage time for that specific cycle.Also, visualizing each segmented cycle alongside their averages can provide insights into muscle activation patterns throughout propulsion. I will use plotting functions to create clear visual representations:
figure;
hold on;
for i = 1:length(cycles)
plot(percent_cycles{i}, cycles{i});
end
plot(average_cycles, 'k--', 'LineWidth', 2); % Plot average as dashed line
title('EMG Signal During Propulsion Cycles');
xlabel('Percentage of Cycle (%)');
ylabel('EMG Signal (mV)');
hold off;
Repeat similar steps for other muscle sensors (triceps, deltoids, trapezius) using their respective data arrays after confirming consistency in cycle identification across all muscles. Also, depending on your research goals, consider analyzing frequency domain features using techniques like Fast Fourier Transform (FFT) or investigating muscle co-activation patterns during propulsion. If you still require further assistance or specific code implementations for additional analyses, feel free to ask!