% processedRecordings = importdata('behavior_recordings');
load processedRecordings.mat
c=1
for i=1:length(processedRecordings)
   cd(processedRecordings{i})
%    if exist('hpc_theta_phaselocking.mat')
%       load hpc_theta_phaselocking
%       f =find(units(:,1)<7);
%       for j=1:length(f)
% %           r = (rand(length(histo{j}),1)-.5)*2*pi;
% %            polarplot([0 circ_mean(r)],[0 circ_r(r)],'k')
% %           polarplot([0 circ_mean(r)],[0 circ_r(r)],'r')
%           dat(i).spike_phase_histograms{j} = histo{j};
%          hold on 
%       end    
%        
%    end
%  if exist('phaselocking_power_thresh.mat')
%         temp = importdata('phaselocking_power_thresh.mat');
%         dat(i).freqs = temp.freqs;
%         dat(i).spike_phase_histograms = temp.spike_phase_histograms;
%         dat(i).spike_phase_pval = temp.spike_phase_pval;
%         dat(i).spike_phase_zscore = temp.spike_phase_zscore;
%    end
% if exist('ripple_modulation.mat')
%    load ripple_modulation
%    dat(c).ripple_mod = ripple_mod;
%    dat(c).units = units;
%    dat(c).numRipples = numRipples;
%    c=c+1; 
% end

% 
% if exist('psd_behav.mat')
%     dat(i) = importdata('psd_behav.mat');
%     
%     
% end
%    temp = importdata('behav.mat');
%    dat(i).map = temp.map;
%    dat(i).mapping = temp.mapping;
%    dat(i).trials = temp.trials;
%    dat(i).pos = temp.pos;
%    if exist('phaselocking_power_thresh.mat')
%       l=load('phaselocking_power_thresh.mat');
%       dat(i).spike_phase_histograms = l.spike_phase_histograms;
%       dat(i).spike_phase_zscore = l.spike_phase_zscore;
%       dat(i).spike_phase_pval = l.spike_phase_pval;
%       dat(i).freqs = l.freqs;
%    end
    if ~isempty(dir('behav*.mat'))
        b = dir('behav*.mat');
        load(b.name);
        dat(i).pos = pos;
        dat(i).trials = trials;
        dat(i).mapping = mapping;
        dat(i).map = map;
       SetCurrentSession
       dat(i).units = GetUnits();
       for j=1:length(dat(i).units)
          dat(i).spikes{j}=GetSpikeTimes(dat(i).units(j,:)); 
       end
       dat(i).lfp = GetLFP([23 97]);
       [dat(i).rateMap dat(i).occuMap dat(i).phaseMap] = spaceRateMap_old(...
           dat(i).spikes,dat(i).pos,dat(i).map,dat(i).mapping,dat(i).trials,dat(i).lfp(:,[1 3]));
    end% %    [trials,mapping,map] = updateMappingVar(trials,mapping,map);
% %     save('behav.mat','x','y','trials','map*','pos')
   cd ..   
end
save('DT2_current_dataset.mat','-v.7.3')