%% plot charge transfer

subplot(4,1,4); hold off;
% subplot(2,1,1);
% hold off;
cellList = who('venus20628_cell*');
%numCells = length(cellList)

%n_cutoff = 30;

clear charge*
for i = 1:length(cellList)
    %varSuffix = [num2str(i,'%03d')];
    cellID{i} = cellList{i};
    tmp_data = eval(cellID{i});
    tmp_charge = tmp_data(:,6);
    charge.mean(i) = mean(tmp_charge);
    charge.n(i) = length(tmp_charge);
    charge.stderr(i) = std(tmp_charge)/sqrt(charge.n(i));
    disp([cellID{i},': ',num2str(charge.mean(i)),' +/- ', ...
        num2str(charge.stderr(i)), ' pA', ...
        '   (n=',num2str(charge.n(i)),')']);
end
charge_venus20628(:,1) = charge.mean(charge.n>=n_cutoff); hold off;
charge_venus20628(:,2) = charge.stderr(charge.n>=n_cutoff);

cellList = who('venus20629_cell*');
disp('');

%numCells = length(cellList)

clear charge
for i = 1:length(cellList)
    %varSuffix = [num2str(i,'%03d')];
    cellID{i} = cellList{i};
    tmp_data = eval(cellID{i});
    tmp_charge = tmp_data(:,6);
    charge.mean(i) = mean(tmp_charge);
    charge.n(i) = length(tmp_charge);
    charge.stderr(i) = std(tmp_charge)/sqrt(charge.n(i));
    disp([cellID{i},': ',num2str(charge.mean(i)),' +/- ', ...
        num2str(charge.stderr(i)), ' pA', ...
        '   (n=',num2str(charge.n(i)),')']);
end
charge_venus20629(:,1) = charge.mean(charge.n>=n_cutoff);
charge_venus20629(:,2) = charge.stderr(charge.n>=n_cutoff);

errorbar(1:size(charge_venus20628,1),charge_venus20628(:,1),charge_venus20628(:,2),'ro'); hold on;
errorbar([1:size(charge_venus20629,1)]+size(charge_venus20628,1)+1,charge_venus20629(:,1),charge_venus20629(:,2),'bo');
% plot([1,size(charge_venus20628,1)],[mean(charge_venus20628(:,1)) mean(charge_venus20628(:,1))],'r--');
% plot([1,size(charge_venus20629,1)]+size(charge_venus20628,1)+1,[mean(charge_venus20629(:,1)) mean(charge_venus20629(:,1))],'b--');
plot([0.5,size(charge_venus20629,1)+size(charge_venus20628,1)+1.5],[mean(charge_venus20628(:,1)) mean(charge_venus20628(:,1))],'r--');
plot([0.5,size(charge_venus20629,1)+size(charge_venus20628,1)+1.5],[mean(charge_venus20629(:,1)) mean(charge_venus20629(:,1))],'b--');

ylabel('Charge Transfer (fC)','FontSize',14);