%% Calculate PSH for each SS object in the experiment
raw_dir = dir('C:\Users\Jon\Desktop\2010-12-21_Optimus-16259_21div_CNQX-and-Decodability\Stimulation-Data\2010-12-21_16259-Optimus*');

% for i = 1:length(raw_dir)
%     
%     cd(['C:\Users\Jon\Desktop\2010-12-21_Optimus-16259_21div_CNQX-and-Decodability\Stimulation-Data\' raw_dir(i).name])
%     
%     exp_dir = {'trial1','trial2'};
%      
%     for j = 1:length(exp_dir)
%         cd(exp_dir{j})
%         
%             fileinfo = dir([pwd '\*.SS']);    
%             fid = fileinfo(1).name;
%             load(fid,'-mat');
% 
%             SS.PeriStimHistogram([],[],[],0);
%             
%             SS.Save;
% 
%             cd ..
%     end
%    
%     
% end

%% Go through and look at PSH for each CNQX concentration
close all
col = jet(length(raw_dir));
figure();
hold on
for i = 1:length(raw_dir)
    
    cd(['C:\Users\Jon\Desktop\2010-12-21_Optimus-16259_21div_CNQX-and-Decodability\Stimulation-Data\' raw_dir(i).name])
    
    exp_dir = {'trial1','trial2'};
 
    for j = 1:length(exp_dir)
        cd(exp_dir{j})
        
            fileinfo = dir([pwd '\*.SS']);    
            fid = fileinfo(1).name;
            load(fid,'-mat');
            
            SS.psh.hist(isnan(SS.psh.hist)) = 0;

            plot(SS.psh.t,mean(SS.psh.hist),'color',col(i,:))
            drawnow
            cd ..
    end
    
end
   
    