function paperTimeEvolution
%% Relative roundness and mean-width plot

[data500, data750, data999] = loadFilteredData(1, 0.1, 0.015);

%% create figures
close all
figure(1), hold on
% cla
title('Mean width over time')
xlabel('time in minutes');
ylabel('mean width in pixel')
% xlim([0 400]),ylim([150 250]);

figure(2), hold on
% cla
title('Relative additive sphericity over time')
xlabel('time in minutes');
ylabel('relative additive sphericity')
% xlim([0 400]),ylim([0.45 0.65]);

figure(3), hold on
% cla
title('Number of points')
xlabel('time in minutes');
ylabel('number of points')
% xlim([0 400]),ylim([0.45 0.65]);

%% plots
[hWidth500, hRound500, hNumber500] = plotData(data500);
% set([hWidth500, hRound500], 'color', [1 0 0]);
set([hWidth500, hRound500, hNumber500], 'color', [0 0 0], 'lineWidth', 2, ...
    'lineStyle', ':');

[hWidth750, hRound750, hNumber750] = plotData(data750);
% set([hWidth750, hRound750], 'color', [0 1 0]);
set([hWidth750, hRound750, hNumber750], 'color', [0 0 0], 'lineWidth', 2, ...
    'lineStyle', '--');

[hWidth999, hRound999, hNumber999] = plotData(data999);
% set([hWidth999, hRound999], 'color', [0 0 1]);
set([hWidth999, hRound999, hNumber999], 'color', [0 0 0], 'lineWidth', 2, ...
    'lineStyle', '-');

% [hWidthAAA, hRoundAAA] = plotData(dataAAA);
% % set([hWidth999, hRound999], 'color', [0 0 1]);
% set([hWidthAAA, hRoundAAA], 'color', [1 0 0], 'lineWidth', 2, ...
%     'lineStyle', '-');

%% legends
figure(1)
legend('500rpmF', '1800rpmF', '500rpmN2', 'location', 'southeast')
figure(2)
legend('500rpmF', '1800rpmF', '500rpmN2', 'location', 'southeast')
figure(3)
legend('500rpmF', '1800rpmF', '500rpmN2', 'location', 'southeast')

%% print
figure(1)
print('-dpng', 'widthOverTime.png')
figure(2)
print('-dpng', 'roundnessOverTime.png')
figure(3)
print('-dpng', 'smapleNumberOverTime.png')
end


function [hWidth, hRound, hNumber] = plotData(data)
% init
timeVector = unique(data.time);
widthVector = timeVector*0;
roundVector = timeVector*0;
widthStdVector = timeVector*0;
roundStdVector = timeVector*0;

% cycle through times
for iTime = 1:length(timeVector)
    thisTime = timeVector(iTime)
    thisFilter = data.time==thisTime;
    thisWidth = data.width(thisFilter);
    thisRound = data.relativeRoundness(thisFilter)
    
    widthVector(iTime) = mean(thisWidth);
    widthStdVector(iTime) = std(thisWidth) / sqrt(length(thisWidth));
    roundVector(iTime) = mean(thisRound);
    roundStdVector(iTime) = std(thisRound) / sqrt(length(thisRound));
    numberVector(iTime) = sum(thisFilter);
    
%     figure(1)
%     plot(thisWidth*0+thisTime, thisWidth, 'b.')
%     plot(thisTime, mean(thisWidth), 'rx')
%     plot([thisTime thisTime], mean(thisWidth) + [-1 1]*std(thisWidth), 'rd'); 
    
%     figure(2)
%     plot(thisRound*0+thisTime, thisRound, 'b.')
%     plot(thisTime, mean(thisRound), 'rx')
%     plot([thisTime thisTime], mean(thisRound) + [-1 1]*std(thisRound));
end

figure(1)
hWidth = plot(timeVector, widthVector, 'r-o', ...
    'lineWidth', 1, 'markerSize', 3, 'MarkerFaceColor', [1 1 1]*0.0);
% plot(timeVector, widthVector + widthStdVector, 'k.')
% plot(timeVector, widthVector - widthStdVector, 'k.')
figure(2)
hRound = plot(timeVector, roundVector, 'r-o', ...
    'lineWidth', 1, 'markerSize', 3, 'MarkerFaceColor', [1 1 1]*0.0);
% plot(timeVector, roundVector + roundStdVector, 'k.')
% plot(timeVector, roundVector - roundStdVector, 'k.')

figure(3)
hNumber = plot(timeVector, numberVector, 'r-o', ...
    'lineWidth', 1, 'markerSize', 3, 'MarkerFaceColor', [1 1 1]*0.0);

end