-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalculateElectrotonics.m
More file actions
64 lines (47 loc) · 2.43 KB
/
calculateElectrotonics.m
File metadata and controls
64 lines (47 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
function [centrifugalAttenuation, centripetalAttenuation, centrifugalVoltageTransfer, centripetalVoltageTransfer,...
transferImpedanceToSoma, inputImpedance] = calculateElectrotonics (passiveParams, w, mn, geometryType)
numOfSegments = mn.('numOfSegments');
type = mn.('data').('local').('type');
parent = mn.('data').('local').('parent');
radius = mn.('data').('local').('radius');
area = mn.('data').('local').('area');
segment_length = mn.('data').('local').('segment_length');
childs_cellarray = mn.('data').('local').('childs_cellarray');
[cm, rm, ra_prox] = calculatePassiveParams4(passiveParams.('Cm'), passiveParams.('Rm_soma'), passiveParams.('Rm_dend'),...
passiveParams.('Ra'), numOfSegments, type, parent, radius, area, segment_length, geometryType);
A = zeros(numOfSegments, numOfSegments);
voltageAttenuationMatrix = zeros(numOfSegments, numOfSegments);
perc = 0.0;
h = waitbar(perc,'Calculating electrotonic properties...');
for i = 1:numOfSegments
perc = i/numOfSegments;
waitbar(perc,h);
if type(i) ~= 1 %% if not soma
A(i, parent(i)) = -1/ra_prox(i);
A(i, i) = +1/rm(i) + complex(0,w*cm(i)) + 1/ra_prox(i);
else
A(i, i) = +1/rm(i) + complex(0,w*cm(i));
end
daugther_array = cell2mat(childs_cellarray(i));
if ~isempty(daugther_array)
for j = 1:length(daugther_array)
daugther_index = daugther_array(j);
A(i, i) = A(i, i) + 1/ra_prox(daugther_index);
A(i, daugther_index) = -1/ra_prox(daugther_index);
end
end
end
close(h);
K = inv(A);
for i = 1:numOfSegments
for j = 1:numOfSegments
voltageAttenuationMatrix(i,j) = K(i,i)/K(i,j);
end
end
inputImpedance = diag(K);
transferImpedanceToSoma = K(:,1);
centrifugalAttenuation = voltageAttenuationMatrix(1,:)';
centripetalAttenuation = voltageAttenuationMatrix(:,1);
centrifugalVoltageTransfer = 1 ./ centrifugalAttenuation;
centripetalVoltageTransfer = 1 ./ centripetalAttenuation;
end