%close all; figure;
for ii = 1:12
subplot(3,4,ii); hold off

%% linear comp
clear all;
%f_datcol = 3; %amplitudes
f_datcol = 6; %charge transfer
n_cutoff = 30;

load('C:\Users\mingfaifong\Documents\2012-06-21_anchovy4_14DIV_Patch_post-TTX\anchovy4_alldata');
dat_TTX = dat;
load('C:\Users\mingfaifong\Documents\2012-06-21_anchovy6_14DIV_Patch_post-TTX-CTZ\anchovy6_alldata');
dat_TTXCTZ = dat;

sampdata_TTX = [];
for i = 1:size(dat_TTX,1)
    if length(dat_TTX{i}) >= n_cutoff
        sampdata_TTX = [sampdata_TTX; randsample(dat_TTX{i}(:,f_datcol),n_cutoff)];
    end
end

sampdata_TTXCTZ= [];
for i = 1:size(dat_TTXCTZ,1)
    if length(dat_TTXCTZ{i}) >= n_cutoff
        %sampdata_TTXCTZ= [sampdata_TTXCTZ; randsample(dat_TTXCTZ{i}(:,f_datcol),n_cutoff)];
        sampdata_TTXCTZ= [sampdata_TTXCTZ; randsample(dat_TTXCTZ{i}(:,f_datcol),n_cutoff)];
    end
end


maxsamp = min([length(sampdata_TTX),length(sampdata_TTXCTZ)]);

sampdata_TTX = randsample(sampdata_TTX,maxsamp);
sampdata_TTXCTZ= randsample(sampdata_TTXCTZ,maxsamp);

rankdata_TTX = sort(sampdata_TTX);
rankdata_TTXCTZ = sort(sampdata_TTXCTZ);

maxmini = max([sampdata_TTX; sampdata_TTXCTZ]);
axislim = 50*ceil(0.02*maxmini);

%close all;
%figure;

% subplot(1,3,1);
% plot(rankdata_TTX,rankdata_TTXCTZ,'ro'); xlabel('Ranked Ctrl mEPSC Charge (fC)'); ylabel('Ranked TTX mEPSC Charge (fC)');
% hold on; plot([0 maxmini],[0 maxmini],'k--');
% axis square;
% subplot(1,3,2);
% plot(rankdata_TTX,rankdata_TTXCTZCTZ,'bo'); xlabel('Ranked Ctrl mEPSC Charge (fC)'); ylabel('Ranked TTX+CTZ mEPSC Charge (fC)');
% hold on; plot([0 maxmini],[0 maxmini],'k--');
% title('zeno7109','FontSize',16);
% axis square;
% subplot(1,3,3);

plot(rankdata_TTX,rankdata_TTXCTZ,'ko'); xlabel('Ranked TTX mEPSC Charge (fC)'); ylabel('Ranked TTX+CTZ mEPSC Charge (fC)');
%plot(rankdata_TTX,rankdata_TTXCTZ,'ko'); xlabel('Ranked TTX mEPSC Amplitude (pA)'); ylabel('Ranked TTX+CTZ mEPSC Amplitude (pA)');

hold on; plot([0 axislim],[0 axislim],'k--');
axis([0 axislim 0 axislim])
axis square;
title('anchovy4,6','FontSize',16);


end