clear all;

ctrl_avg_normTTX = [];
TTX_avg_normTTX = [];
TTXCTZ_avg_normTTX = [];
ctrl_samp_normTTX = [];
TTX_samp_normTTX = [];
TTXCTZ_samp_normTTX = [];
ctrl_cellID = {};
TTX_cellID = {};
TTXCTZ_cellID = {};

dirID = 'C:\Users\mingfaifong\Documents\2012-12-06_TTX-CTZ-vehicle_patch-analysis\amplitude-30events_01\';
y = dir(dirID); z = [y.isdir];
fidlist = {y(~z).name}';

for i_files = 1:length(fidlist)
    load([dirID fidlist{i_files}]);
    
    fidlist{i_files}
    length(cell_avg{1})
    length(cell_avg{2})
    length(cell_avg{3})
    
    ctrl_avg_normTTX = [ctrl_avg_normTTX, cell_avg{1}/culture_avg(2)];
    TTX_avg_normTTX = [TTX_avg_normTTX, cell_avg{2}/culture_avg(2)];
    TTXCTZ_avg_normTTX = [TTXCTZ_avg_normTTX, cell_avg{3}/culture_avg(2)];

    for i = 1:length(cell_avg{1})
        ctrl_cellID{end+1} = [cultureID{1} '_cell',num2str(i)];
    end
    for i = 1:length(cell_avg{2})
        TTX_cellID{end+1} = [cultureID{2} '_cell',num2str(i)];
    end
    for i = 1:length(cell_avg{3})
        TTXCTZ_cellID{end+1} = [cultureID{3} '_cell',num2str(i)];
    end

    ctrl_samp_normTTX = [ctrl_samp_normTTX; cell_sampdata{1}/culture_avg(2)];
    TTX_samp_normTTX = [TTX_samp_normTTX; cell_sampdata{2}/culture_avg(2)];
    TTXCTZ_samp_normTTX = [TTXCTZ_samp_normTTX; cell_sampdata{3}/culture_avg(2)];
end

save([dirID,'ctrl-TTX-TTXCTZ_normToTTX'],'*_normTTX','*_cellID');