function [ spike ] = findspike_old( raw , threshold)
% Function findspike return index to spikes in data.
%   Detailed explanation goes here...this dates from before using the
%   median filter.

n = length(raw);
x = 1:n;
% threshold = 10;

%- dif_r = raw(1:n-1)-raw(2:n);
dif_2r = abs(raw(1:n-2) - raw(3:n));

height = abs(raw(2:n-1)-(raw(1:n-2) + raw(3:n))/2);
med_height = median(height(find(~isnan(height))));

spike = find((height > med_height*threshold)&(dif_2r < med_height*threshold))+1;
spike2 = find((height > med_height*threshold))+1;

plot(raw, 'k.'); % Fluorescence Data w/o Negative Values
hold on;
plot(x(spike), raw(spike), 'r*'); % Spikes to be Removed
plot(x(spike2), raw(spike2), 'bo'); % Spikes to be Removed
hold off

%- cond_dif_r = abs(dif_r(find(~isnan(dif_r))));  % Make version of data wo NaNs
%- r_med = median(cond_dif_r);

% spike = find(abs(dif_r(1:n-2)./dif_2r) > threshold & abs(dif_r(1:n-2)/r_med) > threshold);
%- spike = find(abs(dif_r(1:n-2)/r_med) > threshold);

%- spike = spike+1;

% plot(raw); hold on; plot(spike+1, raw(spike+1), 'r*');hold off

end

