function [horicsd] = onedimCSDout(data);
% [csd1_8, interp_csd1_8, csd9_16, interp_csd9_16, csd17_24, interp_csd17_24, ...
     %   csd25_32, interp_csd25_32, csd33_40, interp_csd33_40, csd41_48, interp_csd41_48, ...
     %   csd49_56, interp_csd49_56, csd57_64, interp_csd57_64, varagout] = onedimCSD(data);
%waveFilt = BudapestbandPass(lfp(:,1:64),3000,10,25);
%data=waveFilt;
%time=lfp(1:end,65);
time=data(1:end,65);
extra1(1:3000,1)=0;
extra2(1:3000,1)=0;
extra9(1:3000,1)=0;
extra10(1:3000,1)=0;
wave57_64=[extra1 extra2 data(:,57) data(:,58) data(:,59) data(:,60) data(:,61) data(:,62) data(:,63) data(:,64) extra9 extra10 ];
wave49_56=[extra1 extra2 data(:,49) data(:,50) data(:,51) data(:,52) data(:,53) data(:,54) data(:,55) data(:,56) extra9 extra10 ];
wave41_48=[extra1 extra2 data(:,41) data(:,42) data(:,43) data(:,44) data(:,45) data(:,46) data(:,47) data(:,48) extra9 extra10 ];
wave33_40=[extra1 extra2 data(:,33) data(:,34) data(:,35) data(:,36) data(:,37) data(:,38) data(:,39) data(:,40) extra9 extra10 ];
wave25_32=[extra1 extra2 data(:,25) data(:,26) data(:,27) data(:,28) data(:,29) data(:,30) data(:,31) data(:,32) extra9 extra10 ];
wave17_24=[extra1 extra2 data(:,17) data(:,18) data(:,19) data(:,20) data(:,21) data(:,22) data(:,23) data(:,24) extra9 extra10 ];
wave9_16=[extra1 extra2 data(:,9) data(:,10) data(:,11) data(:,12) data(:,13) data(:,14) data(:,15) data(:,16) extra9 extra10 ];
wave1_8=[extra1 extra2 data(:,1) data(:,2) data(:,3) data(:,4) data(:,5) data(:,6) data(:,7) data(:,8) extra9 extra10 ];

x=wave57_64(1:3000,1:12);
nCh=size(x,2);
step=2; %step size
csdch=[step+1:nCh-step];
csd57_64=-(x(:,csdch+step)-2*x(:,csdch)+x(:,csdch-step));
interp_csd57_64=interp2(csd57_64,2,'linear');
x=[0 130]; y=[0 11];
figure
subplot (8,1,8); colorbar;
imagesc(y,x,interp_csd57_64'); xlabel ('Channel'); ylabel ('Time (ms)');
hold on;
t=(130/3000:130/3000:130);
plot(t,-(wave57_64(:,5))*50000+3,'k');


x=wave49_56(1:3000,1:12);
nCh=size(x,2);
step=2; %step size
csdch=[step+1:nCh-step];
csd49_56=-(x(:,csdch+step)-2*x(:,csdch)+x(:,csdch-step));
interp_csd49_56=interp2(csd49_56,2,'linear');
x=[0 130]; y=[0 11];
subplot (8,1,7)
imagesc(y,x,interp_csd49_56'); axis off;
hold on;
t=(130/3000:130/3000:130);
plot(t,-(wave49_56(:,5))*50000+3,'k');


x=wave41_48(1:3000,1:12);
nCh=size(x,2);
step=2; %step size
csdch=[step+1:nCh-step];
csd41_48=-(x(:,csdch+step)-2*x(:,csdch)+x(:,csdch-step));
interp_csd41_48=interp2(csd41_48,2,'linear');
x=[0 130]; y=[0 11];
subplot (8,1,6)
imagesc(y,x,interp_csd41_48'); axis off;
hold on;
t=(130/3000:130/3000:130);
plot(t,-(wave41_48(:,5))*50000+3,'k');

x=wave33_40(1:3000,1:12);
nCh=size(x,2);
step=2; %step size
csdch=[step+1:nCh-step];
csd33_40=-(x(:,csdch+step)-2*x(:,csdch)+x(:,csdch-step));
interp_csd33_40=interp2(csd33_40,2,'linear');
x=[0 130]; y=[0 11];
subplot (8,1,5)
imagesc(y,x,interp_csd33_40'); axis off;
hold on;
t=(130/3000:130/3000:130);
plot(t,-(wave33_40(:,5))*50000+3,'k');


x=wave25_32(1:3000,1:12);
nCh=size(x,2);
step=2; %step size
csdch=[step+1:nCh-step];
csd25_32=-(x(:,csdch+step)-2*x(:,csdch)+x(:,csdch-step));
interp_csd25_32=interp2(csd25_32,2,'linear');
x=[0 130]; y=[0 11];
subplot (8,1,4)
imagesc(y,x,interp_csd25_32'); axis off;
hold on;
t=(130/3000:130/3000:130);
plot(t,-(wave25_32(:,5))*50000+3,'k');



x=wave17_24(1:3000,1:12);
nCh=size(x,2);
step=2; %step size
csdch=[step+1:nCh-step];
csd17_24=-(x(:,csdch+step)-2*x(:,csdch)+x(:,csdch-step));
interp_csd17_24=interp2(csd17_24,2,'linear');
x=[0 130]; y=[0 11];
subplot (8,1,3)
imagesc(y,x,interp_csd17_24'); axis off;
hold on;
t=(130/3000:130/3000:130);
plot(t,-(wave17_24(:,5))*50000+3,'k');


x=wave9_16(1:3000,1:12);
nCh=size(x,2);
step=2; %step size
csdch=[step+1:nCh-step];
csd9_16=-(x(:,csdch+step)-2*x(:,csdch)+x(:,csdch-step));
interp_csd9_16=interp2(csd9_16,2,'linear');
x=[0 130]; y=[0 11];
subplot (8,1,2)
imagesc(y,x,interp_csd9_16'); axis off;
hold on;
t=(130/3000:130/3000:130);
plot(t,-(wave9_16(:,5))*50000+3,'k');


x=wave1_8(1:3000,1:12);
nCh=size(x,2);
step=2; %step size
csdch=[step+1:nCh-step];
csd1_8=-(x(:,csdch+step)-2*x(:,csdch)+x(:,csdch-step));
interp_csd1_8=interp2(csd1_8,2,'linear');
x=[0 130]; y=[0 11];
subplot (8,1,1)
imagesc(y,x,interp_csd1_8'); axis off;
hold on;
t=(130/3000:130/3000:130);
plot(t,-(wave1_8(:,5))*50000+3,'k');

horicsd=cat(2,csd1_8,csd9_16,csd17_24,csd25_32,csd33_40,csd41_48,csd49_56,csd57_64);

%Lrotate=ones(8,8);
%for m=1:8
    %for n=1:8
      %  Lrotate(m,n)=n*8-m+1;
      % end
      %end
%Lrotate=reshape(Lrotate,1,64);

Rrotate=ones(8,8);
for n=1:8
    for m=1:8
        Rrotate(m,n)=8*(8-m)+n;
    end
end

Rrotate=reshape(Rrotate,1,64);

figure
for n=1:64
subplot (8,8,Rrotate(n)); plot (time,horicsd(:,n)); title ('hori');
end
%figure
%for n=1:48
%subplot (8,6,transhori(n)); plot (time,horicsd(:,n));title ('transhori 1-8 etc')
%end