clc
clear all
close all





%%
clc
clear all

Left_vext0 = csvread('vext1_Leftside_Abeta0_stimulateonlyAbeta0_edgedist0.1_.csv');
CLeft_vext0 = csvread('MYSARpn1x2_vext1_Leftside_Abeta0_stimulateonlyAbeta0_edgedist0.1_.csv');


time = Left_vext0(:,1) ;

figure
plot(time , Left_vext0 (:,56)  , 'g')
hold on
plot(time , CLeft_vext0(:,56)  , 'b')



%%
clc
clear all

Surface_area_MYSA = 8*3*pi*1e-8 ;  %cm2


ground_leak = csvread('Connectground_MYSA29_ipas.csv');
Left_Trans_Leak = csvread('TransmembraneCurrent_Leak_Leftside_Abeta0_stimulateonlyAbeta0_edgedist0.1_.csv');

time = ground_leak(:,1) ;

figure
plot(time , ground_leak(:,2)*Surface_area_MYSA*1e6  , 'g' , 'LineWidth' , 2)
hold on
plot(time , Left_Trans_Leak(:,28)*Surface_area_MYSA*1e6  , 'k' , 'LineWidth' , 2)
xlim([0 1])
title('MYSA transmembrane leak current')

%%

clc
clear all


Left_vext0 = csvread('vext0_Leftside_Abeta0_stimulateonlyAbeta0_edgedist0.1_.csv');
Right_vext0 = csvread('vext0_Rightside_Abeta0_stimulateonlyAbeta0_edgedist0.1_.csv');
time = Right_vext0(:,1)  ;

figure
plot(time , Left_vext0(:,56)  , 'k')
hold on

plot( time , Left_vext0(:,54) ,'c')
hold on

plot( time , Right_vext0(:,54) ,'m')


mLeft_vext0 = csvread('MYSARpn1x2_vext0_Leftside_Abeta0_stimulateonlyAbeta0_edgedist0.1_.csv');
mRight_vext0 = csvread('MYSARpn1x2_vext0_Rightside_Abeta0_stimulateonlyAbeta0_edgedist0.1_.csv');



plot(time , mLeft_vext0(:,56)   , '--k')
hold on

plot( time , mLeft_vext0(:,54) ,'--c')
hold on

plot( time , mRight_vext0(:,54),'--m')


%%
clc
clear all
close all


nodev = csvread('connectGround_node15_v_vext.csv');

GIl = ((nodev(:,2)+nodev(:,5)) - (nodev(:,3)+nodev(:,6)))/(0.066219513) ;
GIR = ((nodev(:,4)+nodev(:,7)) - (nodev(:,3)+nodev(:,6)))/(0.066219513) ;

time = nodev(:,1)  ;


figure
plot(time , -GIl , 'g' , 'LineWidth' , 2)
hold on
% xlim([0 1])

%%
clc
clear all




Left_vext0 = csvread('vext0_Leftside_Abeta0_stimulateonlyAbeta0_edgedist0.1_.csv');
Right_vext0 = csvread('vext0_Rightside_Abeta0_stimulateonlyAbeta0_edgedist0.1_.csv');
vnode = csvread('node15_V_05_stimulateonlyAbeta0_edgedist0.1_.csv');

time = vnode(:,1) ; 

% figure
% plot(time , vnode(:,2)+Left_vext0(:,56)  , 'k')
% hold on

%

vnode0 = csvread('node15_v_0_stimulateonlyAbeta0_edgedist0.1_.csv');
% time =vnode0(:,1)  ;
% plot( time , vnode0(:,2)+Left_vext0(:,55) ,'c')
% hold on

vnode1 = csvread('node15_v_1_stimulateonlyAbeta0_edgedist0.1_.csv');

% plot( time , vnode1(:,2)+Right_vext0(:,55) ,'m')



%

Il = ((vnode0(:,2)+Left_vext0(:,55)) - (vnode(:,2)+Left_vext0(:,56)))/(0.066219513) ;

IR = ((vnode1(:,2)+Right_vext0(:,55)) - (vnode(:,2)+Left_vext0(:,56)))/(0.066219513) ;

figure
plot(time , -Il*1e6 , 'b' , 'LineWidth' , 2)
hold on
% plot(time , -GIl*1e6 , 'g' , 'LineWidth' , 2)
% title('left')
xlim([0 1])

% figure

% plot(time , -IR*1e6 , 'r' , 'LineWidth' , 2)
% hold on
% % plot(time , -GIR*1e6 , 'g' , 'LineWidth' , 2)
% % xlim([0 1])
% title('intra current  mA')

%%
clc
clear all


Left_vext0 = csvread('vext0_Leftside_Abeta0_stimulateonlyAbeta0_edgedist0.1_.csv');
  
Left_vext0_change = csvread('MYSARpn1x2_vext0_Leftside_Abeta0_stimulateonlyAbeta0_edgedist0.1_.csv');

vnode = csvread('node15_V_05_stimulateonlyAbeta0_edgedist0.1_.csv');

vnode_changed = csvread('MYSARpn1x2_node15_V_05_stimulateonlyAbeta0_edgedist0.1_.csv');

time = vnode(:,1) ; 

figure
plot(time , vnode(:,2)+Left_vext0(:,56)  , 'g')
hold on
plot(time , vnode_changed(:,2)+Left_vext0_change(:,56) , 'b')
hold on

%%
clc
clear all

vnode = csvread('node15_V_05_stimulateonlyAbeta0_edgedist0.1_.csv');

vnode_changed = csvread('MYSARpn1x2_node15_V_05_stimulateonlyAbeta0_edgedist0.1_.csv');

time = vnode(:,1) ; 

figure
plot(time , vnode(:,2)  , 'g')
hold on
plot(time , vnode_changed(:,2) , 'b')
hold on



%%
clc
clear all

il = csvread('node15_ileak_05_stimulateonlyAbeta0_edgedist0.1_.csv');

il_changed = csvread('MYSARpn1x2_node15_ileak_05_stimulateonlyAbeta0_edgedist0.1_.csv');

time = il(:,1) ; 

figure
plot(time , il(:,2) , 'g')
hold on
plot(time , il_changed(:,2) , 'b')
hold on

%%
clc
clear all


Left_vext0 = csvread('vext0_Leftside_Abeta0_stimulateonlyAbeta0_edgedist0.1_.csv');
  
Left_vext0_change = csvread('MYSARpn1x2_vext0_Leftside_Abeta0_stimulateonlyAbeta0_edgedist0.1_.csv');

time = Left_vext0(:,1)  ;

figure
plot(time , Left_vext0(:,56) , 'g')
hold on
plot(time , Left_vext0_change (:,56) , 'b')
hold on


%%
clc
clear all

v_changed = csvread('MYSARpn1x2_MYSA29_V_05_stimulateonlyAbeta0_edgedist0.1_.csv');

v = csvread('MYSA29_V_05_stimulateonlyAbeta0_edgedist0.1_.csv');

Left_vext0 = csvread('vext0_Leftside_Abeta0_stimulateonlyAbeta0_edgedist0.1_.csv');
  
Left_vext0_change = csvread('MYSARpn1x2_vext0_Leftside_Abeta0_stimulateonlyAbeta0_edgedist0.1_.csv');
  
time = v(:,1)  ;

figure
plot( time , v(:,2)+Left_vext0(:,54) ,'g')
hold on
plot( time , v_changed(:,2)+Left_vext0_change(:,54) ,'b' )
xlim([0.12 1])
% ylim([0.12 1])


figure
plot( time , Left_vext0(:,54) ,'g')
hold on
plot( time , Left_vext0_change(:,54) ,'b' )
xlim([0 1])


figure
plot( v(:,2)+Left_vext0(:,54) , Left_vext0(:,54)  ,'k' , 'LineWidth' , 2)
hold on
plot( v_changed(:,2)+Left_vext0_change(:,54) , Left_vext0_change(:,54)  ,'b'  , 'LineWidth' , 2)
hold on

xlim([0 1])







%%
figure
plot( time , v(:,2) , 'g')
hold on
plot( time , v_changed(:,2) , 'b')
xlim([0 0.12])

%%
clc
clear all

Surface_area_node = 2.59415600000000*pi*1e-8 ;  %cm2
Surface_area_MYSA = 8*3*pi*1e-8 ;  %cm2
Surface_area_FLUT = 8*8.05888*pi*1e-8 ;  %cm2
Surface_area_STIN = 8*19.641280*pi*1e-8 ;  %cm2



%

Left_Trans_Leak = csvread('TransmembraneCurrent_Leak_Leftside_Abeta0_stimulateonlyAbeta0_edgedist0.1_.csv');

Left_Trans_Cap = csvread('TransmembraneCurrent_Capacitive_Leftside_Abeta0_stimulateonlyAbeta0_edgedist0.1_.csv');


Right_Trans_Leak = csvread('TransmembraneCurrent_Leak_Rightside_Abeta0_stimulateonlyAbeta0_edgedist0.1_.csv');

Right_Trans_Cap = csvread('TransmembraneCurrent_Capacitive_Rightside_Abeta0_stimulateonlyAbeta0_edgedist0.1_.csv');




[soton satr] = size(Left_Trans_Leak) ;
time = Left_Trans_Leak(:,1)  ;

%  changing the unit from mA/cm2  to nA


for i=2:22
    
    Left_Trans_Leak(:,i) = Left_Trans_Leak(:,i)*Surface_area_STIN ;  % mA
    Left_Trans_Leak(:,i) = Left_Trans_Leak(:,i)*1e6  ; % nA
end

for i=23:27
    
    Left_Trans_Leak(:,i) = Left_Trans_Leak(:,i)*Surface_area_FLUT ;  % mA
    Left_Trans_Leak(:,i) = Left_Trans_Leak(:,i)*1e6  ; % nA
end


for i=28
    
    Left_Trans_Leak(:,i) = Left_Trans_Leak(:,i)*Surface_area_MYSA ;  % mA
    Left_Trans_Leak(:,i) = Left_Trans_Leak(:,i)*1e6  ; % nA
end


%%%%%%%%%%%%%%%

for i=2:22
    
    Left_Trans_Cap(:,i) = Left_Trans_Cap(:,i)*Surface_area_STIN ;  % mA
    Left_Trans_Cap(:,i) = Left_Trans_Cap(:,i)*1e6  ; % nA
end

for i=23:27
    
    Left_Trans_Cap(:,i) = Left_Trans_Cap(:,i)*Surface_area_FLUT  ; % mA
    Left_Trans_Cap(:,i) = Left_Trans_Cap(:,i)*1e6  ; % nA
end


for i=28
    
    Left_Trans_Cap(:,i) = Left_Trans_Cap(:,i)*Surface_area_MYSA  ; % mA
    Left_Trans_Cap(:,i) = Left_Trans_Cap(:,i)*1e6  ; % nA
end







for i=2:22
    
    Right_Trans_Leak(:,i) = Right_Trans_Leak(:,i)*Surface_area_STIN ;  % mA
    Right_Trans_Leak(:,i) = Right_Trans_Leak(:,i)*1e6  ; % nA
end

for i=23:27
    
    Right_Trans_Leak(:,i) = Right_Trans_Leak(:,i)*Surface_area_FLUT ;  % mA
    Right_Trans_Leak(:,i) = Right_Trans_Leak(:,i)*1e6  ; % nA
end


for i=28
    
    Right_Trans_Leak(:,i) = Right_Trans_Leak(:,i)*Surface_area_MYSA ;  % mA
    Right_Trans_Leak(:,i) = Right_Trans_Leak(:,i)*1e6  ; % nA
end


%%%%%%%%%%%%%%%

for i=2:22
    
    Right_Trans_Cap(:,i) = Right_Trans_Cap(:,i)*Surface_area_STIN ;  % mA
    Right_Trans_Cap(:,i) = Right_Trans_Cap(:,i)*1e6  ; % nA
end

for i=23:27
    
    Right_Trans_Cap(:,i) = Right_Trans_Cap(:,i)*Surface_area_FLUT  ; % mA
    Right_Trans_Cap(:,i) = Right_Trans_Cap(:,i)*1e6  ; % nA
end


for i=28
    
    Right_Trans_Cap(:,i) = Right_Trans_Cap(:,i)*Surface_area_MYSA  ; % mA
    Right_Trans_Cap(:,i) = Right_Trans_Cap(:,i)*1e6  ; % nA
end



%
startColor = [1, 1, 1];
xx = startColor ;

figure
for i=28
    if i<25
        m=0.008 ;
        xx = xx - m  ;
    else
        m=0.2  ;   
        xx = xx - m  ;
    end
    plot(time , Right_Trans_Leak(:,i) , 'color', xx , 'LineWidth' , 2 ) ;

    hold on
  
end

xlabel('time(ms)')
ylabel('transmembrane-il (nA)')
title('Left side')
xlim([0 0.12])


% for i=2:satr
%    
%     plot(time , Right_Trans_Leak(:,i) , 'LineWidth' , 2)
%     hold on
%     
%     
% end
% xlabel('time(ms)')
% ylabel('transmembrane_il (nA)')
% title('Right side')


%% MYSA Rpn1*2

clc
clear all

Surface_area_node = 2.59415600000000*pi*1e-8 ;  %cm2
Surface_area_MYSA = 8*3*pi*1e-8 ;  %cm2
Surface_area_FLUT = 8*8.05888*pi*1e-8 ;  %cm2
Surface_area_STIN = 8*19.641280*pi*1e-8 ;  %cm2



%

Left_Trans_Leak = csvread('MYSARpn1x2_TransmembraneCurrent_Leak_Leftside_Abeta0_stimulateonlyAbeta0_edgedist0.1_.csv');

Left_Trans_Cap = csvread('MYSARpn1x2_TransmembraneCurrent_Capacitive_Leftside_Abeta0_stimulateonlyAbeta0_edgedist0.1_.csv');


Right_Trans_Leak = csvread('MYSARpn1x2_TransmembraneCurrent_Leak_Rightside_Abeta0_stimulateonlyAbeta0_edgedist0.1_.csv');

Right_Trans_Cap = csvread('MYSARpn1x2_TransmembraneCurrent_Capacitive_Rightside_Abeta0_stimulateonlyAbeta0_edgedist0.1_.csv');




[soton satr] = size(Left_Trans_Leak) ;
time = Left_Trans_Leak(:,1)  ;

%  changing the unit from mA/cm2  to nA


for i=2:22
    
    Left_Trans_Leak(:,i) = Left_Trans_Leak(:,i)*Surface_area_STIN ;  % mA
    Left_Trans_Leak(:,i) = Left_Trans_Leak(:,i)*1e6  ; % nA
end

for i=23:27
    
    Left_Trans_Leak(:,i) = Left_Trans_Leak(:,i)*Surface_area_FLUT ;  % mA
    Left_Trans_Leak(:,i) = Left_Trans_Leak(:,i)*1e6  ; % nA
end


for i=28
    
    Left_Trans_Leak(:,i) = Left_Trans_Leak(:,i)*Surface_area_MYSA ;  % mA
    Left_Trans_Leak(:,i) = Left_Trans_Leak(:,i)*1e6  ; % nA
end


%%%%%%%%%%%%%%%

for i=2:22
    
    Left_Trans_Cap(:,i) = Left_Trans_Cap(:,i)*Surface_area_STIN ;  % mA
    Left_Trans_Cap(:,i) = Left_Trans_Cap(:,i)*1e6  ; % nA
end

for i=23:27
    
    Left_Trans_Cap(:,i) = Left_Trans_Cap(:,i)*Surface_area_FLUT  ; % mA
    Left_Trans_Cap(:,i) = Left_Trans_Cap(:,i)*1e6  ; % nA
end


for i=28
    
    Left_Trans_Cap(:,i) = Left_Trans_Cap(:,i)*Surface_area_MYSA  ; % mA
    Left_Trans_Cap(:,i) = Left_Trans_Cap(:,i)*1e6  ; % nA
end







for i=2:22
    
    Right_Trans_Leak(:,i) = Right_Trans_Leak(:,i)*Surface_area_STIN ;  % mA
    Right_Trans_Leak(:,i) = Right_Trans_Leak(:,i)*1e6  ; % nA
end

for i=23:27
    
    Right_Trans_Leak(:,i) = Right_Trans_Leak(:,i)*Surface_area_FLUT ;  % mA
    Right_Trans_Leak(:,i) = Right_Trans_Leak(:,i)*1e6  ; % nA
end


for i=28
    
    Right_Trans_Leak(:,i) = Right_Trans_Leak(:,i)*Surface_area_MYSA ;  % mA
    Right_Trans_Leak(:,i) = Right_Trans_Leak(:,i)*1e6  ; % nA
end


%%%%%%%%%%%%%%%

for i=2:22
    
    Right_Trans_Cap(:,i) = Right_Trans_Cap(:,i)*Surface_area_STIN ;  % mA
    Right_Trans_Cap(:,i) = Right_Trans_Cap(:,i)*1e6  ; % nA
end

for i=23:27
    
    Right_Trans_Cap(:,i) = Right_Trans_Cap(:,i)*Surface_area_FLUT  ; % mA
    Right_Trans_Cap(:,i) = Right_Trans_Cap(:,i)*1e6  ; % nA
end


for i=28
    
    Right_Trans_Cap(:,i) = Right_Trans_Cap(:,i)*Surface_area_MYSA  ; % mA
    Right_Trans_Cap(:,i) = Right_Trans_Cap(:,i)*1e6  ; % nA
end



%
startColor = [1, 0, 1];     % [1, 0, 1]   xx(1,1) 
xx = startColor ;

% figure
for i=28
    if i<25
        m=0.008 ;
        xx(1,1) = xx(1,1) - m  ;
    else
        m=0.2  ;   
        xx(1,1) = xx(1,1) - m  ;
    end
    plot(time , Right_Trans_Leak(:,i)  ,'color', xx , 'LineWidth' , 2 ) ;

    hold on
  
end

xlabel('time(ms)')
ylabel('transmembrane-il (nA)')
title('Left side')
xlim([0 0.12])


% for i=2:satr
%    
%     plot(time , Right_Trans_Leak(:,i) , 'LineWidth' , 2)
%     hold on
%     
%     
% end
% xlabel('time(ms)')
% ylabel('transmembrane_il (nA)')
% title('Right side')









%%
clc
clear all


Surface_area_node = 2.59415600000000*pi*1e-8 ;  %cm2
Surface_area_MYSA = 8*3*pi*1e-8 ;  %cm2
Surface_area_FLUT = 8*8.05888*pi*1e-8 ;  %cm2
Surface_area_STIN = 8*19.641280*pi*1e-8 ;  %cm2



%

Left_Trans_Leak = csvread('TransmembraneCurrent_Leak_Leftside_Abeta0_stimulateonlyAbeta0_edgedist0.1_.csv');

Left_Trans_Cap = csvread('TransmembraneCurrent_Capacitive_Leftside_Abeta0_stimulateonlyAbeta0_edgedist0.1_.csv');


Right_Trans_Leak = csvread('TransmembraneCurrent_Leak_Rightside_Abeta0_stimulateonlyAbeta0_edgedist0.1_.csv');

Right_Trans_Cap = csvread('TransmembraneCurrent_Capacitive_Rightside_Abeta0_stimulateonlyAbeta0_edgedist0.1_.csv');




[soton satr] = size(Left_Trans_Leak) ;
time = Left_Trans_Leak(:,1)  ;

%  changing the unit from mA/cm2  to nA


for i=2:22
    
    Left_Trans_Leak(:,i) = Left_Trans_Leak(:,i)*Surface_area_STIN ;  % mA
    Left_Trans_Leak(:,i) = Left_Trans_Leak(:,i)*1e6  ; % nA
end

for i=23:27
    
    Left_Trans_Leak(:,i) = Left_Trans_Leak(:,i)*Surface_area_FLUT ;  % mA
    Left_Trans_Leak(:,i) = Left_Trans_Leak(:,i)*1e6  ; % nA
end


for i=28
    
    Left_Trans_Leak(:,i) = Left_Trans_Leak(:,i)*Surface_area_MYSA ;  % mA
    Left_Trans_Leak(:,i) = Left_Trans_Leak(:,i)*1e6  ; % nA
end


%%%%%%%%%%%%%%%

for i=2:22
    
    Left_Trans_Cap(:,i) = Left_Trans_Cap(:,i)*Surface_area_STIN ;  % mA
    Left_Trans_Cap(:,i) = Left_Trans_Cap(:,i)*1e6  ; % nA
end

for i=23:27
    
    Left_Trans_Cap(:,i) = Left_Trans_Cap(:,i)*Surface_area_FLUT  ; % mA
    Left_Trans_Cap(:,i) = Left_Trans_Cap(:,i)*1e6  ; % nA
end


for i=28
    
    Left_Trans_Cap(:,i) = Left_Trans_Cap(:,i)*Surface_area_MYSA  ; % mA
    Left_Trans_Cap(:,i) = Left_Trans_Cap(:,i)*1e6  ; % nA
end







for i=2:22
    
    Right_Trans_Leak(:,i) = Right_Trans_Leak(:,i)*Surface_area_STIN ;  % mA
    Right_Trans_Leak(:,i) = Right_Trans_Leak(:,i)*1e6  ; % nA
end

for i=23:27
    
    Right_Trans_Leak(:,i) = Right_Trans_Leak(:,i)*Surface_area_FLUT ;  % mA
    Right_Trans_Leak(:,i) = Right_Trans_Leak(:,i)*1e6  ; % nA
end


for i=28
    
    Right_Trans_Leak(:,i) = Right_Trans_Leak(:,i)*Surface_area_MYSA ;  % mA
    Right_Trans_Leak(:,i) = Right_Trans_Leak(:,i)*1e6  ; % nA
end


%%%%%%%%%%%%%%%

for i=2:22
    
    Right_Trans_Cap(:,i) = Right_Trans_Cap(:,i)*Surface_area_STIN ;  % mA
    Right_Trans_Cap(:,i) = Right_Trans_Cap(:,i)*1e6  ; % nA
end

for i=23:27
    
    Right_Trans_Cap(:,i) = Right_Trans_Cap(:,i)*Surface_area_FLUT  ; % mA
    Right_Trans_Cap(:,i) = Right_Trans_Cap(:,i)*1e6  ; % nA
end


for i=28
    
    Right_Trans_Cap(:,i) = Right_Trans_Cap(:,i)*Surface_area_MYSA  ; % mA
    Right_Trans_Cap(:,i) = Right_Trans_Cap(:,i)*1e6  ; % nA
end









startColor = [1, 1, 1];

xx = startColor ;


figure
for i=2:satr
    
    if i<25
        m=0.008 ;
        xx = xx - m  ;
    else
        m=0.2  ;   
        xx = xx - m  ;
    end
   
    plot(time , Left_Trans_Cap(:,i) ,'color', xx , 'LineWidth' , 2)
    hold on
    
    
end
xlabel('time(ms)')
ylabel('Transmembrane-icap (nA)')
title('Left side')
xlim([0.95 4])


% for i=2:satr
%    
%     plot(time , Right_Trans_Cap(:,i) , 'LineWidth' , 2)
%     hold on
%     
%     
% end
% xlabel('time(ms)')
% ylabel('icap (nA)')
% title('Right side')


%% MYSA Rpn1 *2
clc
clear all



Surface_area_node = 2.59415600000000*pi*1e-8 ;  %cm2
Surface_area_MYSA = 8*3*pi*1e-8 ;  %cm2
Surface_area_FLUT = 8*8.05888*pi*1e-8 ;  %cm2
Surface_area_STIN = 8*19.641280*pi*1e-8 ;  %cm2



%

Left_Trans_Leak = csvread('MYSARpn1x2_TransmembraneCurrent_Leak_Leftside_Abeta0_stimulateonlyAbeta0_edgedist0.1_.csv');

Left_Trans_Cap = csvread('MYSARpn1x2_TransmembraneCurrent_Capacitive_Leftside_Abeta0_stimulateonlyAbeta0_edgedist0.1_.csv');


Right_Trans_Leak = csvread('MYSARpn1x2_TransmembraneCurrent_Leak_Rightside_Abeta0_stimulateonlyAbeta0_edgedist0.1_.csv');

Right_Trans_Cap = csvread('MYSARpn1x2_TransmembraneCurrent_Capacitive_Rightside_Abeta0_stimulateonlyAbeta0_edgedist0.1_.csv');




[soton satr] = size(Left_Trans_Leak) ;
time = Left_Trans_Leak(:,1)  ;

%  changing the unit from mA/cm2  to nA


for i=2:22
    
    Left_Trans_Leak(:,i) = Left_Trans_Leak(:,i)*Surface_area_STIN ;  % mA
    Left_Trans_Leak(:,i) = Left_Trans_Leak(:,i)*1e6  ; % nA
end

for i=23:27
    
    Left_Trans_Leak(:,i) = Left_Trans_Leak(:,i)*Surface_area_FLUT ;  % mA
    Left_Trans_Leak(:,i) = Left_Trans_Leak(:,i)*1e6  ; % nA
end


for i=28
    
    Left_Trans_Leak(:,i) = Left_Trans_Leak(:,i)*Surface_area_MYSA ;  % mA
    Left_Trans_Leak(:,i) = Left_Trans_Leak(:,i)*1e6  ; % nA
end


%%%%%%%%%%%%%%%

for i=2:22
    
    Left_Trans_Cap(:,i) = Left_Trans_Cap(:,i)*Surface_area_STIN ;  % mA
    Left_Trans_Cap(:,i) = Left_Trans_Cap(:,i)*1e6  ; % nA
end

for i=23:27
    
    Left_Trans_Cap(:,i) = Left_Trans_Cap(:,i)*Surface_area_FLUT  ; % mA
    Left_Trans_Cap(:,i) = Left_Trans_Cap(:,i)*1e6  ; % nA
end


for i=28
    
    Left_Trans_Cap(:,i) = Left_Trans_Cap(:,i)*Surface_area_MYSA  ; % mA
    Left_Trans_Cap(:,i) = Left_Trans_Cap(:,i)*1e6  ; % nA
end







for i=2:22
    
    Right_Trans_Leak(:,i) = Right_Trans_Leak(:,i)*Surface_area_STIN ;  % mA
    Right_Trans_Leak(:,i) = Right_Trans_Leak(:,i)*1e6  ; % nA
end

for i=23:27
    
    Right_Trans_Leak(:,i) = Right_Trans_Leak(:,i)*Surface_area_FLUT ;  % mA
    Right_Trans_Leak(:,i) = Right_Trans_Leak(:,i)*1e6  ; % nA
end


for i=28
    
    Right_Trans_Leak(:,i) = Right_Trans_Leak(:,i)*Surface_area_MYSA ;  % mA
    Right_Trans_Leak(:,i) = Right_Trans_Leak(:,i)*1e6  ; % nA
end


%%%%%%%%%%%%%%%

for i=2:22
    
    Right_Trans_Cap(:,i) = Right_Trans_Cap(:,i)*Surface_area_STIN ;  % mA
    Right_Trans_Cap(:,i) = Right_Trans_Cap(:,i)*1e6  ; % nA
end

for i=23:27
    
    Right_Trans_Cap(:,i) = Right_Trans_Cap(:,i)*Surface_area_FLUT  ; % mA
    Right_Trans_Cap(:,i) = Right_Trans_Cap(:,i)*1e6  ; % nA
end


for i=28
    
    Right_Trans_Cap(:,i) = Right_Trans_Cap(:,i)*Surface_area_MYSA  ; % mA
    Right_Trans_Cap(:,i) = Right_Trans_Cap(:,i)*1e6  ; % nA
end



startColor = [1, 0, 1];
xx = startColor ;


%figure
for i=2:satr
    
    if i<25
        m=0.008 ;
        xx(1,1) = xx(1,1) - m  ;
    else
        m=0.2  ;   
        xx(1,1) = xx(1,1) - m  ;
    end
   
    plot(time , Left_Trans_Cap(:,i) , 'color', xx , 'LineWidth' , 2)
    hold on
    
    
end
xlabel('time(ms)')
ylabel('icap (nA)')
title('Left side')
xlim([0.95 4])


% for i=2:satr
%    
%     plot(time , Right_Trans_Cap(:,i) , 'LineWidth' , 2)
%     hold on
%     
%     
% end
% xlabel('time(ms)')
% ylabel('icap (nA)')
% title('Right side')




%%   vext0

clc
clear all

Rpn0 = 429128.527578172*1e6*1e-4 ;  %ohm/micron   node and MYSA
Rpn2 = 108066.18906880693*1e6*1e-4 ;  %ohm/micron  FLUT
Rpx = 108066.18906880693*1e6*1e-4 ;  %ohm/micron    STIN





Left_vext0 = csvread('vext0_Leftside_Abeta0_stimulateonlyAbeta0_edgedist0.1_.csv');

time = Left_vext0(:,1) ;


%

j=1 ;
for i=2:42
    
    I_vext0_left(:,j) = (Left_vext0(:,i) - Left_vext0(:,i+1))/Rpx  ;   %mA.micron
    I_vext0_left(:,j) = I_vext0_left(:,j)/9.8205   ;   %mA
    I_vext0_left(:,j) = I_vext0_left(:,j)*1e6  ;       % nA

    j=j+1 ; 
    
end



for i=43:52
    
    I_vext0_left(:,j) = (Left_vext0(:,i) - Left_vext0(:,i+1))/Rpn2  ;   %mA.micron
    I_vext0_left(:,j) = I_vext0_left(:,j)/4.0294   ;   %mA
    I_vext0_left(:,j) = I_vext0_left(:,j)*1e6  ;       % nA

    j=j+1 ; 
    
end



for i=53:54
    
    I_vext0_left(:,j) = (Left_vext0(:,i) - Left_vext0(:,i+1))/Rpn0  ;   %mA.micron
    I_vext0_left(:,j) = I_vext0_left(:,j)/1.5   ;   %mA
    I_vext0_left(:,j) = I_vext0_left(:,j)*1e6  ;       % nA

    j=j+1 ; 
    
end


for i=55
    
    I_vext0_left(:,j) = (Left_vext0(:,i) - Left_vext0(:,i+1))/Rpn0  ;   %mA.micron
    I_vext0_left(:,j) = I_vext0_left(:,j)/0.5   ;   %mA
    I_vext0_left(:,j) = I_vext0_left(:,j)*1e6  ;       % nA

    j=j+1 ; 
    
end

startColor = [1, 1, 1];
xx = startColor ;
% figure
% for i=53:54
%    
%     
%     if i<48
%         m=0.005 ;
%         xx = xx - m  ;
%     else
%         m=0.1  ;   
%         xx = xx - m  ;
%     end
%     plot(time , I_vext0_left(:,i) , 'Color' , xx ,'LineWidth' , 2)
%     hold on
%     
%     
% end
% xlabel('time(ms)')
% ylabel('periaxonal current (nA)')
% title('Left side')
% 
% xlim([0.12 1])
% ylim([0 6e-5])



V = (Left_vext0(:,54) - Left_vext0(:,55)) ;
figure
plot(time , V , 'g')
hold on
% xlim([0.12 1])

%%  MYSA Rpn1 *2
clc
clear all


Rpn0 = 429128.527578172*1e6*1e-4 ;  %ohm/micron   node
Rpn1 = 2 * 429128.527578172*1e6*1e-4 ;  %ohm/micron    MYSA
Rpn2 = 108066.18906880693*1e6*1e-4 ;  %ohm/micron  FLUT
Rpx = 108066.18906880693*1e6*1e-4 ;  %ohm/micron    STIN





Left_vext0 = csvread('MYSARpn1x2_vext0_Leftside_Abeta0_stimulateonlyAbeta0_edgedist0.1_.csv');
time = Left_vext0(:,1) ;


%

j=1 ;
for i=2:42
    
    I_vext0_left(:,j) = (Left_vext0(:,i) - Left_vext0(:,i+1))/Rpx  ;   %mA.micron
    I_vext0_left(:,j) = I_vext0_left(:,j)/9.8205   ;   %mA
    I_vext0_left(:,j) = I_vext0_left(:,j)*1e6  ;       % nA

    j=j+1 ; 
    
end



for i=43:52
    
    I_vext0_left(:,j) = (Left_vext0(:,i) - Left_vext0(:,i+1))/Rpn2  ;   %mA.micron
    I_vext0_left(:,j) = I_vext0_left(:,j)/4.0294   ;   %mA
    I_vext0_left(:,j) = I_vext0_left(:,j)*1e6  ;       % nA

    j=j+1 ; 
    
end



for i=53:54
    
    I_vext0_left(:,j) = (Left_vext0(:,i) - Left_vext0(:,i+1))/Rpn1  ;   %mA.micron
    I_vext0_left(:,j) = I_vext0_left(:,j)/1.5   ;   %mA
    I_vext0_left(:,j) = I_vext0_left(:,j)*1e6  ;       % nA

    j=j+1 ; 
    
end


for i=55
    
    I_vext0_left(:,j) = (Left_vext0(:,i) - Left_vext0(:,i+1))/Rpn0  ;   %mA.micron
    I_vext0_left(:,j) = I_vext0_left(:,j)/0.5   ;   %mA
    I_vext0_left(:,j) = I_vext0_left(:,j)*1e6  ;       % nA

    j=j+1 ; 
    
end

startColor = [1, 0, 1];
xx = startColor ;
% figure
% for i=53:54
%    
%     
%     if i<48
%         m=0.005 ;
%         xx(1,1) = xx(1,1) - m  ;
%     else
%         m=0.1  ;   
%         xx(1,1) = xx(1,1) - m  ;
%     end
%     plot(time , I_vext0_left(:,i)  , 'Color' , xx ,'LineWidth' , 2)
%     hold on
%     
%     
% end
% xlabel('time(ms)')
% ylabel('periaxonal current (nA)')
% title('Left side')
% xlim([0.12 1])
% ylim([0 6e-5])



V = (Left_vext0(:,54) - Left_vext0(:,55)) ;

plot(time , V , 'b')
%  xlim([0.12 1])



%%

clc
clear all


Rpn0 = 429128.527578172*1e6*1e-4 ;  %ohm/micron   node and MYSA
Rpn2 = 108066.18906880693*1e6*1e-4 ;  %ohm/micron  FLUT
Rpx = 108066.18906880693*1e6*1e-4 ;  %ohm/micron    STIN




Right_vext0 = csvread('vext0_Rightside_Abeta0_stimulateonlyAbeta0_edgedist0.1_.csv');

time = Right_vext0(:,1) ;





j=1 ;
for i=2:42
    
    I_vext0_right(:,j) = (Right_vext0(:,i) - Right_vext0(:,i+1))/Rpx  ;   %mA.micron
    I_vext0_right(:,j) = I_vext0_right(:,j)/9.8205   ;   %mA
    I_vext0_right(:,j) = I_vext0_right(:,j)*1e6  ;       % nA

    j=j+1 ; 
    
end



for i=43:52
    
    I_vext0_right(:,j) = (Right_vext0(:,i) - Right_vext0(:,i+1))/Rpn2  ;   %mA.micron
    I_vext0_right(:,j) = I_vext0_right(:,j)/4.0294   ;   %mA
    I_vext0_right(:,j) = I_vext0_right(:,j)*1e6  ;       % nA

    j=j+1 ; 
    
end



for i=53:54
    
    I_vext0_right(:,j) = (Right_vext0(:,i) - Right_vext0(:,i+1))/Rpn0  ;   %mA.micron
    I_vext0_right(:,j) = I_vext0_right(:,j)/1.5   ;   %mA
    I_vext0_right(:,j) = I_vext0_right(:,j)*1e6  ;       % nA

    j=j+1 ; 
    
end


for i=55
    
    I_vext0_right(:,j) = (Right_vext0(:,i) - Right_vext0(:,i+1))/Rpn0  ;   %mA.micron
    I_vext0_right(:,j) = I_vext0_right(:,j)/0.5   ;   %mA
    I_vext0_right(:,j) = I_vext0_right(:,j)*1e6  ;       % nA

    j=j+1 ; 
    
end


startColor = [1, 1, 1];
xx = startColor ;
figure
for i=2:54
    
    if i<48
        m=0.005 ;
        xx = xx - m  ;
    else
        m=0.1  ;   
        xx = xx - m  ;
    end
   
    plot(time , I_vext0_right(:,i)  , 'Color' , xx , 'LineWidth' , 2)
    hold on
    
    
end
xlabel('time(ms)')
ylabel('periaxonal current (nA)')
title('Right side')
xlim([0.95 4])



%% MYSA Rpn1 *2
clc
clear all


Rpn0 = 429128.527578172*1e6*1e-4 ;  %ohm/micron   node and MYSA
Rpn2 = 108066.18906880693*1e6*1e-4 ;  %ohm/micron  FLUT
Rpx = 108066.18906880693*1e6*1e-4 ;  %ohm/micron    STIN

Right_vext0 = csvread('MYSARpn1x2_vext0_Rightside_Abeta0_stimulateonlyAbeta0_edgedist0.1_.csv');


time = Right_vext0(:,1)  ;




j=1 ;
for i=2:42
    
    I_vext0_right(:,j) = (Right_vext0(:,i) - Right_vext0(:,i+1))/Rpx  ;   %mA.micron
    I_vext0_right(:,j) = I_vext0_right(:,j)/9.8205   ;   %mA
    I_vext0_right(:,j) = I_vext0_right(:,j)*1e6  ;       % nA

    j=j+1 ; 
    
end



for i=43:52
    
    I_vext0_right(:,j) = (Right_vext0(:,i) - Right_vext0(:,i+1))/Rpn2  ;   %mA.micron
    I_vext0_right(:,j) = I_vext0_right(:,j)/4.0294   ;   %mA
    I_vext0_right(:,j) = I_vext0_right(:,j)*1e6  ;       % nA

    j=j+1 ; 
    
end



for i=53:54
    
    I_vext0_right(:,j) = (Right_vext0(:,i) - Right_vext0(:,i+1))/Rpn0  ;   %mA.micron
    I_vext0_right(:,j) = I_vext0_right(:,j)/1.5   ;   %mA
    I_vext0_right(:,j) = I_vext0_right(:,j)*1e6  ;       % nA

    j=j+1 ; 
    
end


for i=55
    
    I_vext0_right(:,j) = (Right_vext0(:,i) - Right_vext0(:,i+1))/Rpn0  ;   %mA.micron
    I_vext0_right(:,j) = I_vext0_right(:,j)/0.5   ;   %mA
    I_vext0_right(:,j) = I_vext0_right(:,j)*1e6  ;       % nA

    j=j+1 ; 
    
end



% figure
for i=2:54
   
    plot(time , I_vext0_right(:,i) , ':' , 'LineWidth' , 2)
    hold on
    
    
end
xlabel('time(ms)')
ylabel('periaxonal current (nA)')
title('Right side')













%%  vext1
clc
clear all


xr = 95769.75706051444*1e6*1e-4 ;   %ohm/micron





Left_vext1 = csvread('vext1_Leftside_Abeta0_stimulateonlyAbeta0_edgedist0.1_.csv');

time = Left_vext1(:,1) ;


%

j=1 ;
for i=2:42
    
    I_vext1_left(:,j) = (Left_vext1(:,i) - Left_vext1(:,i+1))/xr   ;   %mA.micron
    I_vext1_left(:,j) = I_vext1_left(:,j)/9.8205   ;   %mA
    I_vext1_left(:,j) = I_vext1_left(:,j)*1e6  ;       % nA

    j=j+1 ; 
    
end



for i=43:52
    
    I_vext1_left(:,j) = (Left_vext1(:,i) - Left_vext1(:,i+1))/xr  ;   %mA.micron
    I_vext1_left(:,j) = I_vext1_left(:,j)/4.0294   ;   %mA
    I_vext1_left(:,j) = I_vext1_left(:,j)*1e6  ;       % nA

    j=j+1 ; 
    
end



for i=53:54
    
    I_vext1_left(:,j) = (Left_vext1(:,i) - Left_vext1(:,i+1))/xr  ;   %mA.micron
    I_vext1_left(:,j) = I_vext1_left(:,j)/1.5   ;   %mA
    I_vext1_left(:,j) = I_vext1_left(:,j)*1e6  ;       % nA

    j=j+1 ; 
    
end


for i=55
    
    I_vext1_left(:,j) = (Left_vext1(:,i) - Left_vext1(:,i+1))/xr  ;   %mA.micron
    I_vext1_left(:,j) = I_vext1_left(:,j)/0.5   ;   %mA
    I_vext1_left(:,j) = I_vext1_left(:,j)*1e6  ;       % nA

    j=j+1 ; 
    
end



figure

startColor = [1, 1, 1];
xx = startColor ;


for i=54
    
    
    
    if i<30
        m=0.009 ;
        xx = xx - m  ;
    else
        m=0.025  ;   
        xx = xx - m  ;
    end
   
    plot(time , I_vext1_left(:,i) , 'color' , xx ,  'LineWidth' , 2)
    hold on
    
    
end
xlabel('time(ms)')
ylabel('Longitudinal current (nA)')
title('Left side')
xlim([0 0.12])

%% MYSA Rpn1 *2

clc
clear all

xr = 95769.75706051444*1e6*1e-4 ;   %ohm/micron



Left_vext1 = csvread('MYSARpn1x2_vext1_Leftside_Abeta0_stimulateonlyAbeta0_edgedist0.1_.csv');

time = Left_vext1(:,1) ; 




%

j=1 ;
for i=2:42
    
    I_vext1_left(:,j) = (Left_vext1(:,i) - Left_vext1(:,i+1))/xr   ;   %mA.micron
    I_vext1_left(:,j) = I_vext1_left(:,j)/9.8205   ;   %mA
    I_vext1_left(:,j) = I_vext1_left(:,j)*1e6  ;       % nA

    j=j+1 ; 
    
end



for i=43:52
    
    I_vext1_left(:,j) = (Left_vext1(:,i) - Left_vext1(:,i+1))/xr  ;   %mA.micron
    I_vext1_left(:,j) = I_vext1_left(:,j)/4.0294   ;   %mA
    I_vext1_left(:,j) = I_vext1_left(:,j)*1e6  ;       % nA

    j=j+1 ; 
    
end



for i=53:54
    
    I_vext1_left(:,j) = (Left_vext1(:,i) - Left_vext1(:,i+1))/xr  ;   %mA.micron
    I_vext1_left(:,j) = I_vext1_left(:,j)/1.5   ;   %mA
    I_vext1_left(:,j) = I_vext1_left(:,j)*1e6  ;       % nA

    j=j+1 ; 
    
end


for i=55
    
    I_vext1_left(:,j) = (Left_vext1(:,i) - Left_vext1(:,i+1))/xr  ;   %mA.micron
    I_vext1_left(:,j) = I_vext1_left(:,j)/0.5   ;   %mA
    I_vext1_left(:,j) = I_vext1_left(:,j)*1e6  ;       % nA

    j=j+1 ; 
    
end



% figure

startColor = [1, 0, 1];
xx = startColor ;


for i=54
    
    
    
    if i<30
        m=0.005 ;
        xx(1,1) = xx(1,1) - m  ;
    else
        m=0.1  ;   
        xx(1,1) = xx(1,1) - m  ;
    end
   
    plot(time , I_vext1_left(:,i) , 'color' , xx ,  'LineWidth' , 2)
    hold on
    
    
end
xlabel('time(ms)')
ylabel('Longitudinal current (nA)')
title('Left side')
xlim([0 0.12])







%%
clc
clear all



xr = 95769.75706051444*1e6*1e-4 ;   %ohm/micron


Right_vext1 = csvread('vext1_Rightside_Abeta0_stimulateonlyAbeta0_edgedist0.1_.csv');

time = Right_vext1(:,1)  ;






j=1 ;
for i=2:42
    
    I_vext1_right(:,j) = (Right_vext1(:,i) - Right_vext1(:,i+1))/xr   ;   %mA.micron
    I_vext1_right(:,j) = I_vext1_right(:,j)/9.8205   ;   %mA
    I_vext1_right(:,j) = I_vext1_right(:,j)*1e6  ;       % nA

    j=j+1 ; 
    
end



for i=43:52
    
    I_vext1_right(:,j) = (Right_vext1(:,i) - Right_vext1(:,i+1))/xr  ;   %mA.micron
    I_vext1_right(:,j) = I_vext1_right(:,j)/4.0294   ;   %mA
    I_vext1_right(:,j) = I_vext1_right(:,j)*1e6  ;       % nA

    j=j+1 ; 
    
end



for i=53:54
    
    I_vext1_right(:,j) = (Right_vext1(:,i) - Right_vext1(:,i+1))/xr  ;   %mA.micron
    I_vext1_right(:,j) = I_vext1_right(:,j)/1.5   ;   %mA
    I_vext1_right(:,j) = I_vext1_right(:,j)*1e6  ;       % nA

    j=j+1 ; 
    
end


for i=55
    
    I_vext1_right(:,j) = (Right_vext1(:,i) - Right_vext1(:,i+1))/xr  ;   %mA.micron
    I_vext1_right(:,j) = I_vext1_right(:,j)/0.5   ;   %mA
    I_vext1_right(:,j) = I_vext1_right(:,j)*1e6  ;       % nA

    j=j+1 ; 
    
end


startColor = [1, 1, 1];
xx = startColor ;
% figure
% 
% for i=1:54
%     
%     
%     if i<48
%         m=0.005 ;
%         xx = xx - m  ;
%     else
%         m=0.1  ;   
%         xx = xx - m  ;
%     end
%    
%     plot(time , I_vext1_right(:,i)  , 'LineWidth' , 2)
%     hold on
%     
%     
% end
xlabel('time(ms)')
ylabel('Longitudinal current (nA)')
title('Right side')
xlim([0.95 4])


%% MYSA Rpn1 *2
clc
clear all


xr = 95769.75706051444*1e6*1e-4 ;   %ohm/micron


Right_vext1 = csvread('MYSARpn1x2_vext1_Rightside_Abeta0_stimulateonlyAbeta0_edgedist0.1_.csv');


time = Right_vext1(:,1) ;




j=1 ;
for i=2:42
    
    I_vext1_right(:,j) = (Right_vext1(:,i) - Right_vext1(:,i+1))/xr   ;   %mA.micron
    I_vext1_right(:,j) = I_vext1_right(:,j)/9.8205   ;   %mA
    I_vext1_right(:,j) = I_vext1_right(:,j)*1e6  ;       % nA

    j=j+1 ; 
    
end



for i=43:52
    
    I_vext1_right(:,j) = (Right_vext1(:,i) - Right_vext1(:,i+1))/xr  ;   %mA.micron
    I_vext1_right(:,j) = I_vext1_right(:,j)/4.0294   ;   %mA
    I_vext1_right(:,j) = I_vext1_right(:,j)*1e6  ;       % nA

    j=j+1 ; 
    
end



for i=53:54
    
    I_vext1_right(:,j) = (Right_vext1(:,i) - Right_vext1(:,i+1))/xr  ;   %mA.micron
    I_vext1_right(:,j) = I_vext1_right(:,j)/1.5   ;   %mA
    I_vext1_right(:,j) = I_vext1_right(:,j)*1e6  ;       % nA

    j=j+1 ; 
    
end


for i=55
    
    I_vext1_right(:,j) = (Right_vext1(:,i) - Right_vext1(:,i+1))/xr  ;   %mA.micron
    I_vext1_right(:,j) = I_vext1_right(:,j)/0.5   ;   %mA
    I_vext1_right(:,j) = I_vext1_right(:,j)*1e6  ;       % nA

    j=j+1 ; 
    
end


startColor = [1, 1, 1];
xx = startColor ;
% figure
% 
% for i=1:54
%     
%     
%     if i<48
%         m=0.005 ;
%         xx = xx - m  ;
%     else
%         m=0.1  ;   
%         xx = xx - m  ;
%     end
%    
%     plot(time , I_vext1_right(:,i)  , 'LineWidth' , 2)
%     hold on
%     
%     
% end
% xlabel('time(ms)')
% ylabel('Longitudinal current (nA)')
% title('Right side')
% xlim([0.95 4])







%% 
clc
clear all


Surface_area_node = 2.59415600000000*pi ;  %micron2
Surface_area_MYSA = 8*3*pi ;  
Surface_area_FLUT = 8*8.05888*pi ;  
Surface_area_STIN = 8*19.641280*pi ;  


%%%%%%%%%%%%  I4


Right_vext1 = csvread('vext1_Rightside_Abeta0_stimulateonlyAbeta0_edgedist0.1_.csv');

time = Right_vext1(:,1)  ;

Left_vext0 = csvread('vext0_Leftside_Abeta0_stimulateonlyAbeta0_edgedist0.1_.csv');





XG =  7.08e+04 *1e-8  ;   %S/micron2

IT = (Left_vext0(:,56)-Right_vext1(:,56))*XG   ;


IT = IT * Surface_area_node*1e6  ; 

figure
plot(time , -IT  ,'g' , 'LineWidth'  , 2)
hold on

xlabel('time(ms)')
ylabel('IT (nA)')
xlim([0 0.12])

%% MYSA Rpn1 *2

clc
clear all


Surface_area_node = 2.59415600000000*pi ;  %micron2
Surface_area_MYSA = 8*3*pi ;  
Surface_area_FLUT = 8*8.05888*pi ;  
Surface_area_STIN = 8*19.641280*pi ;  



Right_vext1 = csvread('MYSARpn1x2_vext1_Rightside_Abeta0_stimulateonlyAbeta0_edgedist0.1_.csv');

time = Right_vext1(:,1)  ;

Left_vext0 = csvread('MYSARpn1x2_vext0_Leftside_Abeta0_stimulateonlyAbeta0_edgedist0.1_.csv');



%%%%%%%%  I4

XG =  7.08e+04 *1e-8  ;   %S/micron2

IT = (Left_vext0(:,56)-Right_vext1(:,56))*XG   ;


IT = IT * Surface_area_node*1e6  ; 

% figure
plot(time , -IT  , 'b' ,  'LineWidth' , 2)


xlabel('time(ms)')
ylabel('IT (nA)')
xlim([0 0.12])








%% to the neaby fiber

clc
clear all

Surface_area_node = 2.59415600000000*pi ;  %micron2
Surface_area_MYSA = 8*3*pi ;  
Surface_area_FLUT = 8*8.05888*pi ;  
Surface_area_STIN = 8*19.641280*pi ;  



XG =  7.08e+04 *1e-8  ;   %S/micron2

Right_vext1 = csvread('vext1_Rightside_Abeta0_stimulateonlyAbeta0_edgedist0.1_.csv');

time = Right_vext1(:,1)  ;

N =  csvread('vext1_Abeta1_stimulateonlyAbeta0_edgedist0.1_.csv');


I_nearby = (Right_vext1(:,56)-N(:,2))*XG   ;
I_nearby = I_nearby * Surface_area_node*1e6  ; 

figure
plot(time , I_nearby ,'k' , 'LineWidth' , 2)
hold on

xlabel('time(ms)')
ylabel('I-nearby (nA)')
xlim([0.95 4])

%% MYSA Rpn1 *2

clc
clear all

Surface_area_node = 2.59415600000000*pi ;  %micron2
Surface_area_MYSA = 8*3*pi ;  
Surface_area_FLUT = 8*8.05888*pi ;  
Surface_area_STIN = 8*19.641280*pi ;  



XG =  7.08e+04 *1e-8  ;   %S/micron2

Right_vext1 = csvread('MYSARpn1x2_vext1_Rightside_Abeta0_stimulateonlyAbeta0_edgedist0.1_.csv');

time = Right_vext1(:,1)  ;

N =  csvread('MYSARpn1x2_vext1_Abeta1_stimulateonlyAbeta0_edgedist0.1_.csv');


I_nearby = (Right_vext1(:,56)-N(:,2))*XG   ;
I_nearby = I_nearby * Surface_area_node*1e6  ; 

% figure
plot(time , I_nearby ,'b' , 'LineWidth' , 2)
hold on

xlabel('time(ms)')
ylabel('I-nearby (nA)')
xlim([0.95 4])



%% to boundary
clc
clear all

Surface_area_node = 2.59415600000000*pi ;  %micron2
Right_vext1 = csvread('MYSARpn1x2_vext1_Rightside_Abeta0_stimulateonlyAbeta0_edgedist0.1_.csv');

time = Right_vext1(:,1)  ;


B =  csvread('MYSARpn1x2_Boundary_stimulateonlyAbeta0_edgedist0.1_.csv');


I_boundary = (Right_vext1(:,56)-B(:,2))*16.1*1e-8   ;
I_boundary = I_boundary * Surface_area_node*1e6  ; 


% figure
plot(time , I_boundary ,'--' , 'LineWidth' , 2)


xlabel('time(ms)')
ylabel('I-boundary (nA)')
xlim([0.95 4])







%%  node icap and Na
clc
clear all

Surface_area_node = 2.59415600000000*pi*1e-8 ;  %cm2


node_icapp = csvread('icap_Node15Abeta0_stimulateonlyAbeta0_edgedist0.1_.csv');  %mA/cm2

time = node_icapp(:,1) ;


node_icap = node_icapp(:,2)*Surface_area_node*1e6  ;


figure
plot(time , node_icap , 'k' , 'LineWidth' , 2)
hold on
xlabel('time(ms)')
ylabel('node,icap (nA)')
xlim([0.95 4])


%% MYSA Rpn1 *2
clc
clear all

Surface_area_node = 2.59415600000000*pi*1e-8 ;  %cm2


node_icapp = csvread('MYSARpn1x2_icap_Node15Abeta0_stimulateonlyAbeta0_edgedist0.1_.csv');  %mA/cm2

time = node_icapp(:,1) ;


node_icap = node_icapp(:,2)*Surface_area_node*1e6  ;


% figure
plot(time , node_icap , 'b' ,'LineWidth' , 2)
xlabel('time(ms)')
ylabel('node,icap (nA)')






%% ina

clc
clear all

Surface_area_node = 2.59415600000000*pi*1e-8 ;  %cm2

node_inaa = csvread('ina_Node15Abeta0_stimulateonlyAbeta0_edgedist0.1_.csv');  %mA/cm2

time = node_inaa(:,1)  ;

node_ina = node_inaa(:,2)*Surface_area_node*1e6  ;


figure
plot(time , node_ina ,'k' , 'LineWidth' , 2)
xlabel('time(ms)')
ylabel('node,ina (nA)')
xlim([0.95 4])
hold on


%% MYSA Rpn1 *2

Surface_area_node = 2.59415600000000*pi*1e-8 ;  %cm2

node_inaa = csvread('MYSARpn1x2_ina_Node15Abeta0_stimulateonlyAbeta0_edgedist0.1_.csv');  %mA/cm2

time = node_inaa(:,1)  ;

node_ina = node_inaa(:,2)*Surface_area_node*1e6  ;


% figure
plot(time , node_ina , 'b' , 'LineWidth' , 2)
xlabel('time(ms)')
ylabel('node,ina (nA)')
xlim([0.95 4])



%%  
% 
% clc
% clear all
% 
% 
% 
% 
% 
% mycm=0.1    ;
% mygm=0.001  ;
% nl = 104 ;
% 
% xg0_MYSA  = (mygm/(nl*2))*1e-8 ;  %S/micron2
% C_MYSA = (mycm/(nl*2))*1e-6*1e-8   ;     %Farad/micron2
% 
% 
% k=1 ;
% for i=2:2:42
%     
%     
% Left_myelin_leak(:,k) = (Left_vext0(:,i)-Left_vext1(:,i))* xg0_MYSA    ;
% Left_myelin_leak(:,k) = Left_myelin_leak(:,k)*Surface_area_STIN*1e6  ;
% 
% 
% clear C
% C = (Left_vext0(:,i)-Left_vext1(:,i))  ;
% dvdt = gradient(C(:)) ./ gradient(time(:));
% 
% Left_myelin_cap(:,k) = dvdt*C_MYSA ;
% Left_myelin_cap(:,k) = Left_myelin_cap(:,k) *Surface_area_STIN*1e6  ;
% 
% 
% 
% k=k+1 ;
% 
% end
% 
% 
% for i=44:2:52
%     
% Left_myelin_leak(:,k) = (Left_vext0(:,i)-Left_vext1(:,i))* xg0_MYSA    ;
% Left_myelin_leak(:,k) = Left_myelin_leak(:,k)*Surface_area_FLUT*1e6  ;
% 
% clear C
% C = (Left_vext0(:,i)-Left_vext1(:,i))  ;
% dvdt = gradient(C(:)) ./ gradient(time(:));
% 
% Left_myelin_cap(:,k) = dvdt*C_MYSA ;
% Left_myelin_cap(:,k) = Left_myelin_cap(:,k) *Surface_area_FLUT*1e6  ;
% 
% 
% k=k+1 ;
% 
% end
% 
% 
% for i=54
%     
% Left_myelin_leak(:,k) = (Left_vext0(:,i)-Left_vext1(:,i))* xg0_MYSA    ;
% Left_myelin_leak(:,k) = Left_myelin_leak(:,k)*Surface_area_MYSA*1e6  ;
% 
% clear C
% C = (Left_vext0(:,i)-Left_vext1(:,i))  ;
% dvdt = gradient(C(:)) ./ gradient(time(:));
% 
% Left_myelin_cap(:,k) = dvdt*C_MYSA ;
% Left_myelin_cap(:,k) = Left_myelin_cap(:,k) *Surface_area_MYSA*1e6  ;
% 
% 
% 
% 
% 
% k=k+1 ;
% 
% end
% 
% startColor = [1, 1, 1];
% xx = startColor ;
% figure
% for i=1:27
%     
%     if i<20
%         m=0.005 ;
%         xx = xx - m  ;
%     else
%         m=0.1  ;   
%         xx = xx - m  ;
%     end
%    
%     plot(time , Left_myelin_leak(:,i)  , 'LineWidth' , 2)
%     hold on
%     
%     
% end
% xlabel('time(ms)')
% ylabel('myelin-leak (nA)')
% title('left')
% 
% %%
% 
% 
% 
% 
% 
% 
% 
% 
% 
% 
% 
% 
% 
% 
% startColor = [1, 1, 1];
% xx = startColor ;
% figure
% for i=1:27
%     
%     if i<20
%         m=0.005 ;
%         xx = xx - m  ;
%     else
%         m=0.1  ;   
%         xx = xx - m  ;
%     end
%    
%     plot(time , Left_myelin_cap(:,i)  , 'LineWidth' , 2)
%     hold on
%     
%     
% end
% 
% xlabel('time(ms)')
% ylabel('myelin-cap (nA)')
% title('left')
% xlim([0.95 4])
% 
% 
% 
% 
% 
% 
% 








% %% 
% 
% 
% mycm=0.1    ;
% mygm=0.001  ;
% nl = 104 ;
% 
% xg0_MYSA  = (mygm/(nl*2))*1e-8 ;  %S/micron2
% C_MYSA = (mycm/(nl*2))*1e-6*1e-8   ;     %Farad/micron2
% 
% 
% k=1 ;
% for i=2:2:42
%     
% Right_myelin_leak(:,k) = (Right_vext0(:,i)-Right_vext1(:,i))* xg0_MYSA    ;
% Right_myelin_leak(:,k) = Right_myelin_leak(:,k)*Surface_area_STIN*1e6  ;
% 
% clear C
% C = (Right_vext0(:,i)-Right_vext1(:,i))  ;
% dvdt = gradient(C(:)) ./ gradient(time(:));
% 
% right_myelin_cap(:,k) = dvdt*C_MYSA ;
% right_myelin_cap(:,k) = right_myelin_cap(:,k) *Surface_area_STIN*1e6  ;
% 
% 
% 
% 
% k=k+1 ;
% 
% end
% 
% 
% for i=44:2:52
%     
% Right_myelin_leak(:,k) = (Right_vext0(:,i)-Right_vext1(:,i))* xg0_MYSA    ;
% Right_myelin_leak(:,k) = Right_myelin_leak(:,k)*Surface_area_FLUT*1e6  ;
% 
% clear C
% C = (Right_vext0(:,i)-Right_vext1(:,i))  ;
% dvdt = gradient(C(:)) ./ gradient(time(:));
% 
% right_myelin_cap(:,k) = dvdt*C_MYSA  ;
% right_myelin_cap(:,k) = right_myelin_cap(:,k) *Surface_area_FLUT*1e6  ;
% 
% 
% 
% 
% k=k+1 ;
% 
% end
% 
% 
% for i=54
%     
% Right_myelin_leak(:,k) = (Right_vext0(:,i)-Right_vext1(:,i))* xg0_MYSA    ;
% Right_myelin_leak(:,k) = Right_myelin_leak(:,k)*Surface_area_MYSA*1e6  ;
% 
% clear C
% C = (Right_vext0(:,i)-Right_vext1(:,i))  ;
% dvdt = gradient(C(:)) ./ gradient(time(:));
%  
% right_myelin_cap(:,k) = dvdt*C_MYSA  ;
% right_myelin_cap(:,k) = right_myelin_cap(:,k) *Surface_area_MYSA*1e6  ;
% 
% 
% 
% 
% k=k+1 ;
% 
% end
% 
% startColor = [1, 1, 1];
% xx = startColor ;
% figure
% for i=1:27
%    
%     
%     if i<20
%         m=0.005 ;
%         xx = xx - m  ;
%     else
%         m=0.1  ;   
%         xx = xx - m  ;
%     end
%     plot(time , Right_myelin_leak(:,i)  , 'LineWidth' , 2)
%     hold on
%     
%     
% end
% 
% xlabel('time(ms)')
% ylabel('myelin-leak (nA)')
% title('right')
% xlim([0.95 4])
% 
% 
% %%
% startColor = [1, 1, 1];
% xx = startColor ;
% figure
% for i=20:27
%     
%     
%     if i<20
%         m=0.005 ;
%         xx = xx - m  ;
%     else
%         m=0.1  ;   
%         xx = xx - m  ;
%     end
%    
%     plot(time , right_myelin_cap(:,i)  , 'Color' ,xx, 'LineWidth' , 2)
%     hold on
%     
%     
% end
% 
% xlabel('time(ms)')
% ylabel('myelin-cap (nA)')
% title('right')
% xlim([0.95 4])
% 










