% processedRecordings = importdata('behavior_recordings');
files = dir('*2016*');
% Get a logical vector that tells which is a directory.
dirFlags = [files.isdir];
% Extract only those that are directories.
subFolders = files(dirFlags);


for c=1:length(dat) %ci=1:length(subFolders)
%    cd(subFolders(i).name)
%    if ~isempty(dir('behav*.mat')) && ~isempty(dir('*clu*')) && exist('meta.mat')
%        b = dir('behav*.mat');
%        load(b.name)
%        SetCurrentSession
%        load meta
%        units = GetUnits();
%        f = find(units(:,1)<5);
%        units = units(f,:);
%        lfp = GetLFP(meta.thetaChans(2));
%        for j=1:length(units)
%            spikes{j} = GetSpikeTimes(units(j,:));
%        end
%        [rateMap occuMap phaseMap] = spaceRateMap_old(spikes,pos,map,mapping,trials,lfp);
rateMap = dat(c).rateMap;
occuMap = dat(c).occuMap;
phaseMap = dat(c).phaseMap;
units = dat(c).units;
units = units(find(units(:,1)<5));
trials = dat(c).trials;

       for j=1:length(units)
           
           for k = 1:length(trials)
               if k < 9
               subplot(4,2,k)
               plot(1)
               if ~isempty(phaseMap{k})
                   if ~isempty(phaseMap{k}{j})
               scatter(phaseMap{k}{j}(:,1),phaseMap{k}{j}(:,7),'.k')
               hold on
               scatter(phaseMap{k}{j}(:,1),phaseMap{k}{j}(:,7)+2*pi,'.k')
%                scatter(phaseMap{k}{j}(:,1),phaseMap{k}{j}(:,6)+4*pi,'.k')
               hold off
               axis([0 length(dat(c).map{1}) -pi 3*pi])
                   end
               end
               end
           end
           title(num2str([c j]))
%            saveFigure(['/zpool/Dropbox/figures/DT2_' num2str(c) '_' num2str(j)])
            pause
            clf
       end   

%    end 
   cd ..
end