
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% index_session_script
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% MV

% RUN this code once for each session
analogCh = 1;
session = sessionTemplate(pwd,'showGUI',true);% fill the forms %1

% opto pulses
[pulses] = bz_getAnalogPulses('analogCh',analogCh,'manualThr',true); % 

% Brain events
UDStates = detectUD('plotOpt', true,'forceDetect',false','NREMInts','all', 'deltaWaveThreshold',[]); % ,'skipCluster',26,'spikeThreshold',.5,'deltaWaveThreshold',[],'ch',18);
% UDStates = detectUD('plotOpt', true,'forceDetect',true'); % ,'skipCluster',26,'spikeThreshold',.5,'deltaWaveThreshold',[],'ch',18);

% Cell metrics
cell_metrics = ProcessCellMetrics('session', session,'excludeMetrics',{'deepSuperficial'});% %2
cell_metrics = CellExplorer('metrics',cell_metrics); 

% computeSessionSummary('listOfAnalysis',{'spikes','downStates','thetaModulation','analogPulses','ripples'});
getOptogeneticResponse('numRep',0); %3

lfpScriptDarpan;

% index path
currentPath = split(pwd,':'); currentPath = currentPath{end};
sessionName = split(pwd,'\'); sessionName = sessionName{end};
load('..\preliminaryResults_ndnf_hf.mat');
allSessions.(sessionName).path = currentPath; disp('Adding: '); disp(currentPath)% indexing session...
allSessions.(sessionName).strain = 'ndnf-CRE';
allSessions.(sessionName).tag = 1;
allSessions.(sessionName).exp = 'hf'; % fm hf
allSessions.(sessionName).behav = 0; % 0 no, 1 alternation, 2 cueSide
allSessions.(sessionName).brainRegions = {'motorCortex'}; % 
save('..\preliminaryResults_ndnf_hf.mat','allSessions'); disp('Saving...');
