function plot_fig_2D

% plot_fig_2D
% Tang et al, Recurrent computations for visual pattern completion. 2018

% Internal notes
% v5_plot_stimulusSetRaster --> plot_fig_2D
% pathname='QTanalysis';

data_occlusion_filename='data_occlusion_PHYS.mat';
colormap_filename='colorMapRedBlue.mat';
x=load(data_occlusion_filename);    % structure containing all data
c=load(colormap_filename);          % colormap 64x3

figure(1); set(gcf,'Color','w');
set(gcf,'Position',[993 270 220 220]);
subplot(1,2,1);
idx = find(x.dat.patient == 27);

vt = x.dat.vt{idx(1)};
VT = NaN(length(vt),length(idx));
lat = x.dat.latency(idx);
cat = x.dat.truth(idx);
for k = 1:length(idx)
    vt = (x.dat.vt{idx(k)});
    VT(:,k) = vt;
end

for k = 1:5
    idx = find(cat == k);
    [~,sidx] = sort(lat(idx));
    VT(:,idx) = VT(:,idx(sidx));
    
    
end

imagesc(VT',[-600 800]); colormap(c.colorMap); hold on;
for k = 1:5
    idx = find(cat == k);
    
    plot([0 length(vt)],[min(idx) min(idx)],'k-'); hold on;
    
end


set(gca,'TickDir','out');
set(gca,'XTick',[]);
set(gca,'YTick',[]);

subplot(1,2,2);
idx = find(x.dat.patient == 26);

vt = x.dat.vt{idx(1)};
VT = NaN(length(vt),length(idx));
lat = x.dat.latency(idx);
cat = x.dat.truth(idx);
for k = 1:length(idx)
    vt = (x.dat.vt{idx(k)});
    VT(:,k) = vt;
end

for k = 1:5
    idx = find(cat == k);
    [~,sidx] = sort(lat(idx),'descend');
    VT(:,idx) = VT(:,idx(sidx));
end

imagesc(VT',[-400 400]); colormap(c.colorMap); hold on;
for k = 1:5
    idx = find(cat == k);
    
    plot([0 length(vt)],[min(idx) min(idx)],'k-'); hold on;
    
end


set(gca,'TickDir','out');
set(gca,'XTick',[]);
set(gca,'YTick',[]);





