% 2019-11-28
% Easy way to generate list of files for analysis

function files = selectMatFiles(lastDir)
    pickFiles = 1;
    files = cell(1,30);
    j=1;
    
    while pickFiles
        % Select .mat file with expmt struct
        [expFile,expDir] = uigetfile(strcat(lastDir,'*.mat'),'Select a expmt .mat file containing centroid traces');

        % Generate expPath (complete file path) from expFile (file name in folder) and expDir (directory)
        files{j} = [expDir,expFile];
        disp(expFile);

        fileChoice = questdlg('Would you like to add another file?',...
        'Convert another file?',...
        'Yes','No','Yes');

        if strcmp(fileChoice,'No')
            disp('Done adding files');
            pickFiles = false;
            files = files(~cellfun('isempty',files));
        elseif strcmp(fileChoice,'Yes')
            pickFiles = true;
            j = j+1;

            splitDir = split(expDir,'\');
            lastDir = strcat(strjoin(splitDir(1:length(splitDir)-2),'\\'),'\');
        end
    end
end