function [trainFilenames, testFilenames] = split_files(allFilenames, trainProportion)
    % Input:
    %   - allFilenames: Cell array of filenames
    %   - trainProportion: Proportion of files for training (e.g., 0.8 for 80%)

    % Generate random indices
    numFiles = numel(allFilenames);
    idx = randperm(numFiles);

    % Calculate the number of files for training and testing
    numTrain = round(trainProportion * numFiles);
    numTest = numFiles - numTrain;

    % Assign files to training and testing sets
    trainFilenames = allFilenames(idx(1:numTrain));
    testFilenames = allFilenames(idx(numTrain+1:end));
end

