function analyze_autocorrelation(input_data,use_first_val_only,valueforlabel,minutes_per_trial,genfigaddon,specfigaddon,colour,patchtitle)
%description: bare-bones autocorrelation of the psc or charge data, generally baseline only 
%called by: analyze_across_expts
%calls: [no custom functions]
%notes: this method is a bit ad-hoc
%code confirmed date: oct 8, 2009

figure(genfigaddon+specfigaddon)

if use_first_val_only
    input_data=input_data(1,:);
else
    input_data=sum(input_data);
end

autocorr_data=xcorr(input_data);
[maxval,maxind]=max(autocorr_data);
output_data=detrend(autocorr_data(maxind+1:end));

h1=subplot('position',[.2 .1 .5 .3]);
plot([0:minutes_per_trial:(length(input_data)-1)*minutes_per_trial],input_data,'o','markerfacecolor','k','markeredgecolor','k','markersize',4)
set(h1,'yaxislocation','left','xlim',[0 (length(input_data)-1)*minutes_per_trial])
ylabel(valueforlabel),xlabel('Time (min)')

h2=axes('position',get(h1,'position'));
plot([0:minutes_per_trial:(length(output_data)-1)*minutes_per_trial],output_data,'color',colour,'linewidth',.2)
set(h2,'yaxislocation','right','color','none','xlim',get(h1,'xlim'))

title(patchtitle)