Skip to main content

findPrefixes.m


% This function is part of the NMSM Pipeline, see file for full license.
%
% This function finds the prefixes of the trials to be used in the
% personalization process. If the trial_prefixes field is present in the
% config file, the prefixes are taken from there. Otherwise, the prefixes
% are taken from the names of the files in the IDData folder.
%
% (struct, string) -> (None)
% finds the prefixes of the trials to be used in the personalization


function prefixes = findPrefixes(tree, inputDirectory)
prefixField = getFieldByName(tree, 'trial_prefixes');
if(isstruct(prefixField) && length(prefixField.Text) > 0)
prefixes = strsplit(prefixField.Text, ' ');
else
files = dir(fullfile(inputDirectory, "IDData"));
if isempty(files)
files = dir(fullfile(inputDirectory, "IKData"));
end

prefixes = string([]);
for i=1:length(files)
if(~files(i).isdir)
prefixes(end+1) = files(i).name(1:end-4);
end
end
end
end