Hi Zachary,
Assuming that the "fullfile" string follows the same format for all the conditions, you can use "strsplit" to obtain the conditions. Then you can utilize the "containers.Map" object to group the data based on these conditions. Following is a sample code that does the grouping:
% Initialize a map from string to any
finalData = containers.Map('KeyType', 'char', 'ValueType', 'any');
% Loop for subject
for i = 1:length(allFileInfo)
% Loop for condition
for j = 1:length(allFileInfo{i})
filepath = allFileInfo{i}(j).fullfile;
dataTable = allFileInfo{i}(j).data;
% Split the file path into parts based on / using strsplit
pathParts = strsplit(filepath, '/');
% Assuming the filepath is consistent
subjectPart = pathParts{end-3};
sidePart = pathParts{end-2};
conditionPart = pathParts{end-1};
directionPart = strrep(pathParts{end}, '.txt', ''); % Removing extension
% Create a unique key for the group
groupKey = sprintf('%s_%s_%s', sidePart, conditionPart, directionPart);
if isKey(finalData, groupKey)
finalData(groupKey) = [finalData(groupKey); {dataTable}];
else
finalData(groupKey) = {dataTable};
end
end
end
% Convert the map to a cell array with the all the values
finalDataCellArray = values(finalData);
You can refer to the following documentation to read about each of the following: