
%%
%[groomBins ] = behaviorExtractionFunct('openArm', 3,10,mouseData, true, false, 'quiescent'); %behaviorExtractionFunct(behavior, preBinTime, postBinTime, data, rawData, base, baseBehavior)

groomBins = bins;
clear bins
%normal (1) average to entire trace (2) Tobias average (3) normalize to
%quiescence (4) normalize to window (5) no normalization
treatTraces = averageAllCellsFunct(groomBins,true,true,1,2400,1, [1 30]); %averageAllCellsFunct(bins, treat, start, startTime, stopTime, normal, normalWindow, baselineBehavior)
nullTraces = averageAllCellsFunct(groomBins,false,true,1,2400,1, [1 30]); %averageAllCellsFunct(bins, treat, start, startTime, stopTime, normal, normalWindow, baselineBehavior)

sortAllCellsGraphFunct(treatTraces, [25 100], [-1 1], 3,10, 'Grooming start', 'Sapap3-KO') %sortAllCellsGraphFunct(traces, sortWindow, clims, binLengthStart, binLengthEnd, behaviorName, treatment)
sortAllCellsGraphFunct(nullTraces, [25 100], [-1 1], 3,10, 'Grooming start', 'Sapap3-WT') %sortAllCellsGraphFunct(traces, sortWindow, clims, binLength, behaviorName, treatment)
   %sortAllCellsGraphFunct(traces, sortWindow, clims, binLength, behaviorName, treatment)

[testStats pvals sigIdx sigP] = graphSetsOfAverageTraces(treatTraces,nullTraces,true,3,3,10,[-.1 .3],'Grooming start'); %graphSetsOfAverageTraces(treatTraces, nullTraces, test, span, binLengthStart, binLengthEnd, yLimits,  behaviorName)
test = testStats(sigP);
testPval = pvals(sigP);
%graphSetsOfAverageTraces(treatTraces,nullTraces,true,3,5,[-1 9],'Grooming start'); %diff ylims for window normalized data

xlabel('Time (s)')
ylabel('Z-scored Fluorescence')

clear nullTraces treatTraces
%%
[quiescentBins ] = behaviorExtractionFunct('quiescent', 2,2,mouseData, true, true, 'quiescent');

%baseline = calculatePercentileBaselineFunct(mouseData,25, true);

%normal (1) average to entire trace (2) Tobias average (3) normalize to
%quiescence (4) normalize to window (5) no normalization
treatTraces = averageAllCellsFunct(quiescentBins,true,true,5,1200,1, [1 6]); %averageAllCellsFunct(bins, treat, start, startTime, stopTime, normal, normalWindow, baselineBehavior)
nullTraces = averageAllCellsFunct(quiescentBins,false,true,5,1200,1, [1 6]); %averageAllCellsFunct(bins, treat, start, startTime, stopTime, normal, normalWindow, baselineBehavior)

sortAllCellsGraphFunct(treatTraces, [20 35], [-1 1], 2, 'Quiescent start', 'Sapap3-KO') %sortAllCellsGraphFunct(traces, sortWindow, clims, binLength, behaviorName, treatment)
sortAllCellsGraphFunct(nullTraces, [20 35], [-1 1], 2, 'Quiescent start', 'Sapap3-WT') %sortAllCellsGraphFunct(traces, sortWindow, clims, binLength, behaviorName, treatment)
graphSetsOfAverageTraces(treatTraces,nullTraces,true,3,2,[-.2 .3],'Quiescent start'); %grapbehSetsOfAverageTraces(treatTraces, nullTraces, test, span, binLength, yLimits, behaviorName)

graphSetsOfAverageTraces(treatTraces,nullTraces,true,3,2,[-1 6],'Quiescent start'); %diff ylims for window normalized data

clear nullTraces treatTraces
xlabel('Time (ms)')
ylabel('Normalized \Delta F/F')

%%
treatTraces = averageAllCellsFunct(faceBins,true,true,960,4500,5, [30 35]);
nullTraces = averageAllCellsFunct(faceBins,false,true,960,4500,5, [30 35]);

sortAllCellsGraphFunct(treatTraces, [50 60], [-.4 .4], 5, 'face grooming', 'SKF')
sortAllCellsGraphFunct(nullTraces, [50 60], [-.4 .4], 5, 'face grooming', 'saline')
graphSetsOfAverageTraces(treatTraces,nullTraces,true,3,5,[.2 .7],'face grooming');

%normalization
normalBins = behaviorExtractionFunct('NoMovement', 5,5,mouseData, false);

treatTraces = averageAllCellsFunct(normalBins,true,true,960,4500,true, [1 5]);
nullTraces = averageAllCellsFunct(normalBins,false,true,960,4500,true, [1 5]);

sortAllCellsGraphFunct(treatTraces, [50 60], [-.4 .4], 5, 'No Movement', 'SKF')
sortAllCellsGraphFunct(nullTraces, [50 60], [-.4 .4], 5, 'No Movement', 'saline')
graphSetsOfAverageTraces(treatTraces,nullTraces,true,2,5,[0 .5],'No Movement');