% === Script Initialization and Setup ===
clear all;
close all;
% Define indices for data plotting.
plot_reps = [1,2]; % Specify which repetitions to plot [1-7].
plot_gestures = [1,13]; % Specify which movement types to plot [1-17].
channelsToPlot = [1,5,6,7,9,10]; % Specify which data channels to display in subplots [1-12].
% === File Loading and Validation ===
fileName = uigetfile('', 'Select File');
if fileName == 0
error('No File selected.');
end
[~, baseName, ~] = fileparts(fileName);
fileParts = split(baseName,'_');
if length(fileParts) < 2
error('File name does not match expected format: [sessionID]_[subjectID]');
end
sessionParts = split(fileParts{1},'session');
sessionIdx = str2double(sessionParts{2});
subjectParts = split(fileParts{2},'participant');
subjectIdx = str2double(subjectParts{2});
% Load the 'DATA_WRIST' variable from the selected MAT file.
Edata = load(fileName, 'DATA_WRIST');
DATA_WRIST = Edata.DATA_WRIST;
% === Plotting Loop ===
for j = 1:length(plot_reps)
repIdx = plot_reps(j);
for k = 1:length(plot_gestures)
moveIdx = plot_gestures(k);
if all(cellfun(@isempty, DATA_WRIST(repIdx,moveIdx)))
continue;
end
% === Y-Axis Limit Calculation ===
allChannelData = DATA_WRIST{repIdx, moveIdx}(:,channelsToPlot);
globalMaxAbs = max(max(abs(allChannelData)));
yLimit = globalMaxAbs * 1.05;
figure('WindowState', 'maximized');
for i = 1:length(channelsToPlot)
ch = channelsToPlot(i);
subplot(length(channelsToPlot), 1, i);
currentData = DATA_WRIST{repIdx, moveIdx}(:,ch);
plot(currentData, 'b', 'LineWidth', 1);
ylim([-yLimit, yLimit]);
xlim([0,10240]);
ylabel(sprintf('Ch %d', ch));
grid on;
if i == length(channelsToPlot)
xlabel('Samples');
else
set(gca, 'XTickLabel', []);
end
end
sgtitle(sprintf('Participant %d - Session %d - Gesture %d - Repetition %d', subjectIdx,sessionIdx, moveIdx, repIdx));
end
end