function [csd] = linear7chCSD(data);
time=data(1:end,8);
extra1(1:3000,1)=0;
extra2(1:3000,1)=0;
extra9(1:3000,1)=0;
extra10(1:3000,1)=0;
wave=[extra1, extra2, data(:,7), data(:,6), data(:,5), data(:,4), data(:,3), extra9, extra10];
x=wave(1:3000,1:9);
nCh=size(x,2);
step=2; %step size
csdch=[step+1:nCh-step];
csd=-(x(:,csdch+step)-2*x(:,csdch)+x(:,csdch-step));
interp_csd=interp2(csd,2,'linear');
x=[0 130]; y=[0 8];
imagesc(x,y,interp_csd); xlabel ('Time (ms)'); ylabel ('Channel');
hold on;
t=(130/3000:130/3000:130);
plot(t,-(wave(:,4))*50000+3,'k');

%figure
%for n=1:5
%subplot (5,2,1); plot (time, csd(:,1)); title ('CSD'); 
%subplot (5,2,3); plot (time, csd(:,2));
%subplot (5,2,5); plot (time, csd(:,3));
%subplot (5,2,7); plot (time, csd(:,4));
%subplot (5,2,9); plot (time, csd(:,5));
%axis([0 1000 -0.4 0.4]); axis off;
%end
%hold on;
%for n=1:5
 %   subplot (5,2,2); plot(time, data(:,1), ('r')); title ('Voltage');
  %  subplot (5,2,4); plot(time, data(:,2), ('r'));
   % subplot (5,2,6); plot(time, data(:,3), ('r'));
    %subplot (5,2,8); plot(time, data(:,4), ('r'));
    %subplot (5,2,10); plot(time, data(:,5), ('r'));
    %end
%csdfft = fft(csd);
%csdmag = abs(csdfft);
%f = (0:length(csdfft)-1)'*1000/length(csdfft);
%figure
%for n=1:5
%subplot(5,1,n); plot(f(1:100), csdmag(1:100, n)); axis([0 100 0 50]); xlabel ('Frequency (Hz)'); ylabel ('Magnitude');%axis off;
%end