%% plot frequencies

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

%n_cutoff = 30;
freq_cut = 1/60;

clearvars freq* -except freq_cut
for i = 1:length(cellList)
    %varSuffix = [num2str(i,'%03d')];
    cellID{i} = cellList{i};
    tmp_data = eval(cellID{i});
    tmp_freq = tmp_data(:,19);
    tmp_freq = tmp_freq(isfinite(tmp_freq) & tmp_freq>=freq_cut);
    freq.mean(i) = mean(tmp_freq);
    freq.n(i) = length(tmp_freq);
    freq.stderr(i) = std(tmp_freq)/sqrt(freq.n(i));
    disp([cellID{i},': ',num2str(freq.mean(i)),' +/- ', ...
        num2str(freq.stderr(i)), ' pA', ...
        '   (n=',num2str(freq.n(i)),')']);
end
freq_venus20628(:,1) = freq.mean(freq.n>=n_cutoff);
freq_venus20628(:,2) = freq.stderr(freq.n>=n_cutoff);


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

%numCells = length(cellList)

clear freq
for i = 1:length(cellList)
    %varSuffix = [num2str(i,'%03d')];
    cellID{i} = cellList{i};
    tmp_data = eval(cellID{i});
    tmp_freq = tmp_data(:,19);
    tmp_freq = tmp_freq(isfinite(tmp_freq) & tmp_freq>=freq_cut);
    freq.mean(i) = mean(tmp_freq);
    freq.n(i) = length(tmp_freq);
    freq.stderr(i) = std(tmp_freq)/sqrt(freq.n(i));
    disp([cellID{i},': ',num2str(freq.mean(i)),' +/- ', ...
        num2str(freq.stderr(i)), ' pA', ...
        '   (n=',num2str(freq.n(i)),')']);
end
freq_venus20629(:,1) = freq.mean(freq.n>=n_cutoff);
freq_venus20629(:,2) = freq.stderr(freq.n>=n_cutoff);

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

ylabel('Frequency (Hz)','FontSize',14);