%% This code takes in the data from "results.xls" and puts it in a legible format ("plots.xls")

results = readtable('results.xlsx');

%% Arms
% none: 0, 25, 30, 35 MPa
% rt-PA:0, 25, 30, 35 MPa

plotData = zeros(8,6);
lytic = {'none','rt-PA'};
pressure = [0,25,30,35];
row = 1;

for i = 1:length(lytic)
    for j = 1:length(pressure)
        data = results(results.PNP_MPa_==pressure(j) & strcmp(results.Lytic,lytic(i)) & ~strcmp(results.Arm,'20cycle') & ~strcmp(results.Arm,'5cycle')& ~strcmp(results.Arm,'20cycle25MPa'),:);
        plotData(row,:) = [nanmean(data.MassLoss___),nanstd(data.MassLoss___),...
            nanmean(data.Hemolysis),nanstd(data.Hemolysis),nanmean(data.D_Dimer),nanstd(data.D_Dimer)];
    row = row+1;
    end
end

xlswrite('plots.xlsx',plotData,'B2:G9')

none_0MPa = results(results.PNP_MPa_==0 & strcmp(results.Lytic,'none') & ~strcmp(results.Arm,'20cycle') & ~strcmp(results.Arm,'5cycle'),:);
none_25MPa= results(results.PNP_MPa_==25 & strcmp(results.Lytic,'none') & ~strcmp(results.Arm,'20cycle') & ~strcmp(results.Arm,'20cycle25MPa') & ~strcmp(results.Arm,'5cycle'),:);
none_30MPa= results(results.PNP_MPa_==30 & strcmp(results.Lytic,'none') & ~strcmp(results.Arm,'20cycle') & ~strcmp(results.Arm,'5cycle'),:);
none_35MPa= results(results.PNP_MPa_==35 & strcmp(results.Lytic,'none') & ~strcmp(results.Arm,'20cycle') & ~strcmp(results.Arm,'5cycle'),:);

rtPA_0MPa = results(results.PNP_MPa_==0 & strcmp(results.Lytic,'rt-PA') & ~strcmp(results.Arm,'20cycle') & ~strcmp(results.Arm,'5cycle'),:);
rtPA_25MPa= results(results.PNP_MPa_==25 & strcmp(results.Lytic,'rt-PA') & ~strcmp(results.Arm,'20cycle') & ~strcmp(results.Arm,'20cycle25MPa') & ~strcmp(results.Arm,'5cycle'),:);
rtPA_30MPa= results(results.PNP_MPa_==30 & strcmp(results.Lytic,'rt-PA') & ~strcmp(results.Arm,'20cycle') & ~strcmp(results.Arm,'5cycle'),:);
rtPA_35MPa= results(results.PNP_MPa_==35 & strcmp(results.Lytic,'rt-PA') & ~strcmp(results.Arm,'20cycle') & ~strcmp(results.Arm,'5cycle'),:);

% Added this code in later to account for different pulse durations
multiCycleData = zeros(4,6);

none_5cycle = results(results.LyticAmount_uL_==0 & strcmp(results.Arm,'5cycle') & results.PNP_MPa_==35,:);
rtPA_5cycle = results(results.LyticAmount_uL_>0 & strcmp(results.Arm,'5cycle') & results.PNP_MPa_==35,:);
none_20cycle = results(results.LyticAmount_uL_==0 & strcmp(results.Arm,'20cycle')& results.PNP_MPa_==35,:);
rtPA_20cycle = results(results.LyticAmount_uL_>0 & strcmp(results.Arm,'20cycle')& results.PNP_MPa_==35,:);

multiCycleData(1,:) = [nanmean(none_5cycle.MassLoss___),nanstd(none_5cycle.MassLoss___),...
    nanmean(none_5cycle.Hemolysis),nanstd(none_5cycle.Hemolysis),nanmean(none_5cycle.D_Dimer),nanstd(none_5cycle.D_Dimer)];
multiCycleData(2,:) = [mean(none_20cycle.MassLoss___),std(none_20cycle.MassLoss___),...
    nanmean(none_20cycle.Hemolysis),nanstd(none_20cycle.Hemolysis),nanmean(none_20cycle.D_Dimer),nanstd(none_20cycle.D_Dimer)];
multiCycleData(3,:) = [mean(rtPA_5cycle.MassLoss___),std(rtPA_5cycle.MassLoss___),...
    nanmean(rtPA_5cycle.Hemolysis),nanstd(rtPA_5cycle.Hemolysis),nanmean(rtPA_5cycle.D_Dimer),nanstd(rtPA_5cycle.D_Dimer)];
multiCycleData(4,:) = [mean(rtPA_20cycle.MassLoss___),std(rtPA_20cycle.MassLoss___),...
    nanmean(rtPA_20cycle.Hemolysis),nanstd(rtPA_20cycle.Hemolysis),nanmean(rtPA_20cycle.D_Dimer),nanstd(rtPA_20cycle.D_Dimer)];

xlswrite('plots.xlsx',multiCycleData,'B11:G14')

