close all

base = 'Z:\jon';

fids = {
    [base '/2014_01_27_Tooth-25019_1-minute-clamps-and-replay_oc-v1.1/2014_01_27_Tooth-25019_mode0-1-16-32_04_ts-summary.fig']
    [base '/2014_01_27_Tooth-25019_1-minute-clamps-and-replay_oc-v1.1/2014_01_27_Tooth-25019_mode0-1-16-32_04_replay_00_ts-summary.fig']
    %     [base '/2014_01_27_Tooth-25019_1-minute-clamps-and-replay_oc-v1.1/2014_01_27_Tooth-25019_mode0-1-16-32_04_replay_01_ts-summary.fig']
    [base '/2014_01_28_Tooth-25019_1-minute-clamps-and-replay_oc-v1.1/2014_01_28_Tooth-25019_mode0-1-16-32_01_ts-summary.fig']
    [base '/2014_01_28_Tooth-25019_1-minute-clamps-and-replay_oc-v1.1/2014_01_28_Tooth-25019_mode0-1-16-32_01_replay_00_ts-summary.fig']
    %     [base '/2014_01_28_Tooth-25019_1-minute-clamps-and-replay_oc-v1.1/2014_01_28_Tooth-25019_mode0-1-16-32_01_replay_01_ts-summary.fig']
    [base '/2014_02_10_Tooth-25024_1-minute-clamps-and-replay_oc-v1.1/2014_02_10_Tooth-25024_mode0-1-16-32-48_03_ts-summary.fig']
    [base '/2014_02_10_Tooth-25024_1-minute-clamps-and-replay_oc-v1.1/2014_02_10_Tooth-25024_mode0-1-16-32-48_03_replay_00_ts-summary.fig']
    [base '/2014_02_10_Tooth-25024_1-minute-clamps-and-replay_oc-v1.1/2014_02_10_Tooth-25024_mode0-1-16-32-48_01_ts-summary.fig']
    [base '/2014_02_10_Tooth-25024_1-minute-clamps-and-replay_oc-v1.1/2014_02_10_Tooth-25024_mode0-1-16-32-48_01_replay_00_ts-summary.fig']
    [base '/2014_02_10_Tooth-25024_1-minute-clamps-and-replay_oc-v1.1/2014_02_10_Tooth-25024_mode0-1-16-32-48_02_ts-summary.fig']
    [base '/2014_02_10_Tooth-25024_1-minute-clamps-and-replay_oc-v1.1/2014_02_10_Tooth-25024_mode0-1-16-32-48_02_replay_00_ts-summary.fig']
    };

figs = {};
ax = {};

for i = 1:numel(fids)
    figs{i} =  open(fids{i});
    ax{i} = get(figs{i}, 'Children');
end

end_ax = ax{end};
for j = 1:numel(fids)-1
    this_ax = ax{j};
    switch numel(this_ax)
        case 18
            for i = 1:numel(this_ax)
                ax2Children = get(this_ax(i),'Children');
                copyobj(ax2Children, end_ax(i));
            end
        case 24
            for i = 1:numel(this_ax)
                ax2Children = get(this_ax(i),'Children');
                copyobj(ax2Children, end_ax(i+6));
            end
        case 30
            for i = 1:numel(this_ax)
                ax2Children = get(this_ax(i),'Children');
                copyobj(ax2Children, end_ax(i));
            end
    end
end

close(figs{1:end-1})

% saveas(gcf, 'replay_mega-summary')
% export_fig('replay_mega-summary','-pdf','-transparent',gcf)