time = []; amplitude = []; rise = []; decay = []; area = [];
culture = []; div = []; treatment = []; fid = []; bath = [];

fpath = ['/Users/flamingo/Desktop/all miniAnalysis events ASC/ASC/'];
fpath_info = dir(fpath);      %get info about contents of directory
isfile = ~[fpath_info.isdir]; %get index for files only
fidlist = {fpath_info(isfile).name}; %create list of files

tmp = load('miniFileInfo.mat');

for j = 1:length(fidlist)
    
    fname = fidlist{j};
    x = importdata([fpath fname]);
    culture_tmp = tmp.culture(strmatch(fname,tmp.fid));
    div_tmp = tmp.div(strmatch(fname,tmp.fid));
    treatment_tmp = tmp.treatment(strmatch(fname,tmp.fid));
    fname_tmp = tmp.fid(strmatch(fname,tmp.fid));
    bath_tmp = tmp.bath(strmatch(fname,tmp.fid));
    
    time = [time; x(:,2)];
    if  strmatch('cinderella360',culture_tmp)
        amplitude = [amplitude; x(:,3)/2];
        area = [area; x(:,6)/2];
        culture_tmp
    elseif  strmatch('cinderella19307',culture_tmp)
        amplitude = [amplitude; x(:,3)/2];
        area = [area; x(:,6)/2];
        culture_tmp
    elseif  strmatch('euclid1',culture_tmp)
        amplitude = [amplitude; x(:,3)/2];
        area = [area; x(:,6)/2];
        culture_tmp
    else
        amplitude = [amplitude; x(:,3)];
        area = [area; x(:,6)];
    end
    rise = [rise; x(:,4)];
    decay = [decay; x(:,5)];
    culture = [culture; repmat(culture_tmp,size(x,1),1)];
    div = [div; repmat(div_tmp,size(x,1),1)];
    treatment = [treatment; repmat(treatment_tmp,size(x,1),1)];
    fid = [fid; repmat({fname},size(x,1),1)];
    bath = [bath; repmat(bath_tmp,size(x,1),1)];
    
end

save miniDB time amplitude rise decay area culture div treatment fid bath
clear;
load miniDB