% Sample using rasterized array
% Biological data

% Raster, PSTH, ISIH
figure;
colormap([1 1 1; 0 0 0]);	% black on white background

[ras1,ps1,is1] = rasterize( bio1, bioTrials);
subplot(3,4,1); imagesc(ras1');
subplot(3,4,5); plot(ps1);
subplot(3,4,9); plot(is1); drawnow;

[ras2,ps2,is2] = rasterize( bio2, bioTrials);
subplot(3,4,2); imagesc(ras2');
subplot(3,4,6); plot(ps2);
subplot(3,4,10); plot(is2); drawnow;

[ras3,ps3,is3] = rasterize( bio3, bioTrials);
subplot(3,4,3); imagesc(ras3');
subplot(3,4,7); plot(ps3);
subplot(3,4,11); plot(is3); drawnow;

[ras4,ps4,is4] = rasterize( bio4, bioTrials);
subplot(3,4,4); imagesc(ras4');
subplot(3,4,8); plot(ps4);
subplot(3,4,12); plot(is4); drawnow;

% Correlograms
figure;
ts = 100;	% time span

[cov11,cor11,rcor11]= correl( ras1, ras1, ts);
subplot(4,4,1); plot( -ts:ts, [cor11,rcor11,cov11]); drawnow;

[cov12,cor12,rcor12]= correl( ras1, ras2, ts);
subplot(4,4,2); plot( -ts:ts, [cor12,rcor12,cov12]); drawnow;

[cov13,cor13,rcor13]= correl( ras1, ras3, ts);
subplot(4,4,3); plot( -ts:ts, [cor13,rcor13,cov13]); drawnow;

[cov14,cor14,rcor14]= correl( ras1, ras4, ts);
subplot(4,4,4); plot( -ts:ts, [cor14,rcor14,cov14]); drawnow;

[cov22,cor22,rcor22]= correl( ras2, ras2, ts);
subplot(4,4,6); plot( -ts:ts, [cor22,rcor22,cov22]); drawnow;

[cov23,cor23,rcor23]= correl( ras2, ras3, ts);
subplot(4,4,7); plot( -ts:ts, [cor23,rcor23,cov23]); drawnow;

[cov24,cor24,rcor24]= correl( ras2, ras4, ts);
subplot(4,4,8); plot( -ts:ts, [cor24,rcor24,cov24]); drawnow;

[cov33,cor33,rcor33]= correl( ras3, ras3, ts);
subplot(4,4,11); plot( -ts:ts, [cor33,rcor33,cov33]); drawnow;

[cov34,cor34,rcor34]= correl( ras3, ras4, ts);
subplot(4,4,12); plot( -ts:ts, [cor34,rcor34,cov34]); drawnow;

[cov44,cor44,rcor44]= correl( ras4, ras4, ts);
subplot(4,4,16); plot( -ts:ts, [cor44,rcor44,cov44]); drawnow;

% Joint PSTH: 
%jpsth = ras1*ras2';	% big matrix
%figure; imagesc( jpsth); axis('xy'); axis('equal');
