function [filenames] = getTestbedDatafiles(foldername, type)
% List data-files found in foldername. Filter filetype if specified.
%
% INPUT:
% foldername = path to folder
% type (optional) = filetype filter ('vibration'|'external'|'intrinsic')
%
% OUTPUT:
% filenames = (filtred) list of data-files
%
% Last modified Feb. 23, 2017
% Ben Raanan, MBARI

d = dir(foldername);
names = {d.name};

% ignore non-relevant files
ignore = {'.','..','config.txt' };
for ig=ignore(:)'
    names(strcmp(names, ig)) = [];
end

if nargin > 1
    % filter files if type specified
    id = ~cellfun('isempty',regexp(names, type));
    filenames = names(id)';
else
    % return full list otherwise
    filenames = names';
end

end
