load('fig5.mat')

% analysing PET1 only

% get all means in the grey matter for all it
greyMatterMeans_MLEM{1} = squeeze(mean(mean(greyMatterPixelVals_MLEM{1},1),3));
greyMatterMeans_TVMAPSLR{1} = squeeze(mean(mean(greyMatterPixelVals_TVMAPSLR{1},1),3));
greyMatterMeans_MLEM_double{1} = squeeze(mean(mean(greyMatterPixelVals_MLEM_double{1},1),3));

% and CVs
greyMatterCVs_MLEM{1} = squeeze(mean(std(greyMatterPixelVals_MLEM{1},1)./mean(greyMatterPixelVals_MLEM{1},1),3));
greyMatterCVs_TVMAPSLR{1} = squeeze(mean(std(greyMatterPixelVals_TVMAPSLR{1},1)./mean(greyMatterPixelVals_TVMAPSLR{1},1),3));
greyMatterCVs_MLEM_double{1} = squeeze(mean(std(greyMatterPixelVals_MLEM_double{1},1)./mean(greyMatterPixelVals_MLEM_double{1},1),3));

% get all means in the white matter for all it
whiteMatterMeans_MLEM{1} = squeeze(mean(mean(whiteMatterPixelVals_MLEM{1},1),3));
whiteMatterMeans_TVMAPSLR{1} = squeeze(mean(mean(whiteMatterPixelVals_TVMAPSLR{1},1),3));
whiteMatterMeans_MLEM_double{1} = squeeze(mean(mean(whiteMatterPixelVals_MLEM_double{1},1),3));

% and CVs
whiteMatterCVs_MLEM{1} = squeeze(mean(std(whiteMatterPixelVals_MLEM{1},1)./mean(whiteMatterPixelVals_MLEM{1},1),3));
whiteMatterCVs_TVMAPSLR{1} = squeeze(mean(std(whiteMatterPixelVals_TVMAPSLR{1},1)./mean(whiteMatterPixelVals_TVMAPSLR{1},1),3));
whiteMatterCVs_MLEM_double{1} = squeeze(mean(std(whiteMatterPixelVals_MLEM_double{1},1)./mean(whiteMatterPixelVals_MLEM_double{1},1),3));

%% then plot
startInd = 1;
numIt = numel(greyMatterMeans_MLEM{1});

linWidth = 1.2;
markerSize = 9;
faceTint = 0.6;
fontSize = 20;

mlemColor = [0,0.5,0];
mlemMarker = 's';
mlemMarkerStart = 10;
markerInt = 10;
mlemOpts = {'color',mlemColor,'LineWidth',linWidth,'MarkerFaceColor',mlemColor+(1-mlemColor).*faceTint};

linColors = {[0.7,0,0];
             [0,0,0];
             [0,0,0.7]};
linMarkers = {'v','d','x','p'};

% plot grey matter CV vs mean for scan 1
figure
subplot(1,2,1)
hMlem = plotSparseMarker(greyMatterMeans_MLEM{1}(startInd:end),greyMatterCVs_MLEM{1}(startInd:end),mlemMarker,markerSize,markerInt,mlemMarkerStart,mlemOpts{:});
hold on
hSlr= plotSparseMarker(greyMatterMeans_TVMAPSLR{1}(startInd:end),greyMatterCVs_TVMAPSLR{1}(startInd:end),linMarkers{1},markerSize,markerInt,7,'color',linColors{1},'markerFaceColor',linColors{1}+(1-linColors{1}).*faceTint,'lineWidth',linWidth);
hMlemFull = plotSparseMarker(0.5*greyMatterMeans_MLEM_double{1}(startInd:end),greyMatterCVs_MLEM_double{1}(startInd:end),linMarkers{2},markerSize,markerInt,4,'color',linColors{2},'markerFaceColor',linColors{2}+(1-linColors{2}).*faceTint,'lineWidth',linWidth);
ylabel('CV')
xlabel('Mean')
% legend([hMlem,hMlemFull,hSlr],{'ML-EM','Full counts ML-EM','TV-OSL-SLR'},'FontSize',16,'location','southeast')
xlim([0.416,0.423])
ylim([0.07,0.17])
title('Grey matter','fontweight','normal')
set(findall(gca,'-property','FontSize'),'FontSize',fontSize), pbaspect([8,5,1])

% plot white matter CV vs mean for scan 1
subplot(1,2,2)
hMlem = plotSparseMarker(whiteMatterMeans_MLEM{1}(startInd:end),whiteMatterCVs_MLEM{1}(startInd:end),mlemMarker,markerSize,markerInt,mlemMarkerStart,mlemOpts{:});
hold on
hSlr= plotSparseMarker(whiteMatterMeans_TVMAPSLR{1}(startInd:end),whiteMatterCVs_TVMAPSLR{1}(startInd:end),linMarkers{1},markerSize,markerInt,7,'color',linColors{1},'markerFaceColor',linColors{1}+(1-linColors{1}).*faceTint,'lineWidth',linWidth);
hMlemFull = plotSparseMarker(0.5*whiteMatterMeans_MLEM_double{1}(startInd:end),whiteMatterCVs_MLEM_double{1}(startInd:end),linMarkers{2},markerSize,markerInt,4,'color',linColors{2},'markerFaceColor',linColors{2}+(1-linColors{2}).*faceTint,'lineWidth',linWidth);
ylabel('CV')
xlabel('Mean')
legend([hMlem,hMlemFull,hSlr],{'ML-EM','Full counts ML-EM','TV-OSL-SLR'},'FontSize',16,'location','northeast')
xlim([0.1045,0.108])
ylim([0.1,0.32])
title('White matter','fontweight','normal')
set(findall(gca,'-property','FontSize'),'FontSize',fontSize), pbaspect([8,5,1])

