function [t,ta,all30] = plot_data(type)

if type==0 %0.5%
 files = {'13330018_corrd.abf','13403013_corrd.abf','13507016_corrd.abf','13508013_corrd.abf','13602017_corrd.abf','13605007_corrd.abf','13605011.abf','13605016_corrd.abf'}; 
 ca    =  [ 30                     30                  30                     5.1                 30                    2.5                        5.1              30]   ;
 start  = [1573                     1573              1573                   1973                 17533                 19614                      19614            19614 ];
end



if type==1
 files = {'13330017_corrd.abf','13330020_corrd.abf','13403012_corrd.abf','13403021_corrd.abf', '13507015_corrd.abf','13507017_corrd.abf','13508015_corrd.abf','13508023_corrd.abf','13602016_corrd.abf','13602019_corrd.abf','13605014_one_trace.abf','13605018_corrd.abf'}; 
 ca    =  [  30                        30                    30                   30               30                     30                   5.1                   30                  30                   30                30                     30];
 start  = [  1573                     1573                   1573                1573               1573               1573                    1973                  1973              17533              17540            19614                       19614];
end

if type==2
% 2%

files = {'13330019_corrd.abf','13403014_corrd.abf','13507009_corrd.abf','13507017_corrd.abf','13508014_corrd.abf','13508022_corrd.abf','13602018_corrd.abf','13602030_corrd.abf','13605008_corrd.abf','13605012_corrd.abf','13605017_corrd.abf','13809023_corrd.abf'}
ca     = [30                      1                    5.1                  1                    5.1                   30                   30                   5.1                2.5                   5.1                   30               30];

start = [1573 1573 1573 1573 1973 1973 1973+7780*2 1973+7780*2 19614 19614     19614  18614];

end




meantransient = cell(30); alltransient = cell(30);

meantransient{5}=0; meantransient{30}=0; meantransient{3}=0; meantransient{1}=0;
nmeantransient = zeros(1,30);

figure(10*type+2); clf; hold on;
for i=1:length(files)
  [d,si,h] = abf2load(files{i});  
  fprintf('%s : si = %f\n',files{i},si);
  size(d)
  if size(d,1) > 1
    d = d(:,1); 
  end
  
  figure(10*type+2);
  t =  ((1:length(d))- start(i))*0.5 ;
  ta = ca(i) * d / mean( d(start(i)-50:start(i)) )  ;
  plot(t, ta);  axis([-500 2500 0 40]);
  figure(10*type+3); subplot(5,5,i); plot(t , ta );  axis([-5 2005 ca(i)*0.8 ca(i)*1.5]);
  
  IX = t>=-1 & t<=2000;
  t = t(IX);
  meantransient{ round(ca(i)) } =  meantransient{ round(ca(i)) } + ta(IX);
  nmeantransient( round(ca(i)) ) =  nmeantransient( round(ca(i)) ) + 1;
  alltransient{ round(ca(i)) }{end+1} =  ta(IX);

end

figure(10*type+2);
plot([0 2000],[30 30],'k--');
plot([0 2000],[5.1 5.1],'k--');
legend(files,'Location','Best')

figure(4);

t30 = meantransient{30} / nmeantransient(30);
t5  = meantransient{5} / nmeantransient(5);

fprintf('%d files total -- %d with 30 uM\n',length(files), nmeantransient(30))

subplot(3,2,2*type+1); plot(t,t30); title('ca=30');
subplot(3,2,2*type+2); plot(t,t5); title('ca=5');

ta = t30;

all30 = alltransient{30};


