function stability_plots_may31_2010
%plots responses over time to show stability of the system, with different symbols for successes and failures, and a linear fit
name='patch20070319T125639'
numAPs=4;
APinquestion=1;
columnsinquestion=1:28;
threshold=2;
minutespertrial=0.75;

close all

%the data comes from
%done (thresh 2) -- patch20060413T194656(3,1:30) -- actually, better to use psc_o -- this is an stdp success case too, specific thresh = 1.5
%done (thresh 2.5) -- patch20070208T010642(4,1:60)  -- psc_a is preferable b/c psc_o generally fails, after trial 60 presyn patch poor -- thresh of 2.5 better here
%done (thresh 2) -- patch20070208T163503(3,:) 67 columns, and 2 works well as a threshold -- this is an stdp success case too, specific thresh = 3
%done (thresh 2) -- patch20070312T202231(3,29:end) -- 110 total columns... pos pressure stable after trial 28 -- this is a pos-pressure only expt
%done (thresh 2) -- patch20070319T125639(3,:) 28 trials, and 2 works well as a threshold -- this is an stdp success case too, specific thresh = 1.5

pscs=load(strcat('~/dwn_data_analysis_system/extracted_values_dwn/',name,'__pre-postPSC'));

plot(pscs(APinquestion+2,columnsinquestion),'ko'), title('PSCs')

rawcrits=load(strcat('~/dwn_data_analysis_system/extracted_values_dwn/',name,'__criteria_for_latency'));

[lats,crits]=find_detection_crits_and_latencies_generalizedform(rawcrits,threshold,numAPs)

figure
crits=crits(APinquestion,columnsinquestion)
plot(crits,'ko'),title('crits')

allvals=pscs(APinquestion+2,columnsinquestion);

figure
timebase=[0:minutespertrial:(size(columnsinquestion,2)*minutespertrial-minutespertrial)]
    
successes=allvals
successes(~crits)=nan

failures=allvals
failures(crits)=nan

z=size(timebase)

plot(timebase,successes,'o','markerfacecolor','k','markeredgecolor','k'),hold on
xlabel('time (min)'), ylabel('PSC')
plot(timebase,failures,'o','markerfacecolor','w','markeredgecolor','k')

p=polyfit(timebase,allvals,1);

plot([0 timebase(end)], [p(2) p(2)+p(1)*timebase(end)], 'k--')
box off






% 
% if fit to a line, the values (x-intercept, slope) are:
%  4.63918431327464  -0.08679512603852
%    3.87596281082787  -0.00037353326614
%    3.31214019417370   0.00183844369820
%    5.80159230183898   0.00597591916456
%    4.21132486386221   0.08666418918729
% 
% when ttests were performed on the first half versus the second half, the responses were
% 
% ttests =
%                   0   0.45878717483174
%                   0   0.77096778858539
%                   0   0.49103905494332
%                   0   0.82673182960983
%                   0   0.53184782783335