function [cfg] = readinTestbedConfig(foldername)
% Read and parse testebed configuration file.
%
% Input:
%   flodername = path to folder containing config.txt configuration file
%
% Output:
%   cfg = table containing parsed configuration data (type 'cell').
%
% Last modified March 8, 2017
% Ben Raanan, MBARI

fname = [foldername filesep 'config.txt'];

fileID = fopen(fname, 'r');
if fileID ~= -1
    % read in text file lines
    c = textscan(fileID, '%s', 'Delimiter','\n');
    fclose(fileID);
    
    c = c{1};  % thanks mathworks!
    
    % split contant into cells
    cfg = cell(length(c),4);
    for k=1:length(c)
        split = strsplit(c{k}, ',');
        cfg(k,1:length(split)) = split;
    end
    
    % arrange in table
    cfg = cell2table(cfg(2:end,:), 'VariableNames', cfg(1,:));
else
    error(['Failed to open file: ' fname])
end
