-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetSomatofugalProperties3.m
More file actions
202 lines (152 loc) · 8.82 KB
/
getSomatofugalProperties3.m
File metadata and controls
202 lines (152 loc) · 8.82 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
function somatofugalProperties = getSomatofugalProperties3 (mn_struct, parameters, metric, onlyTree, onlyBranch)
somatofugalParams = parameters.somatofugalParams;
indexesOfBranchPoints = mn_struct.('data').('local').('isBranchPoint');
indexesOfTerminations = mn_struct.('data').('local').('isTermination');
if onlyTree
zeroOrderSegments = mn_struct.('data').('zeroOrderSegments');
stemParent = mn_struct.('data').('local').('stemParent');
indexesTree = zeroOrderSegments(onlyTree) == stemParent;
end
if onlyBranch
branch = mn_struct.('data').('local').('branch');
indexesBranch = onlyBranch == branch;
end
if strcmp(metric, 'euclidian') || strcmp(metric, 'path')
localPropNames = parameters.('featureNames').('local').('morphological');
for i = 1:length(localPropNames)
name = char(localPropNames(i));
prop = mn_struct.('data').('local').(name);
count = 1;
for d = 0 : somatofugalParams.('step') : somatofugalParams.('finalDistance')-somatofugalParams.('step')
indexes = getCompartmentIndexesBySection5(mn_struct, d, d+somatofugalParams.('step'), 0, metric);
if onlyTree
indexes = and(indexes, indexesTree);
end
if onlyBranch
indexes = and(indexes, indexesBranch);
end
indexes = and(indexes, or(indexesOfBranchPoints, indexesOfTerminations));
if ~isempty(indexes)
somatofugalProperties.(name){count} = prop(indexes);
end
count = count + 1;
end
end
localPropNames = parameters.('featureNames').('local').('electronic');
for i = 1:length(localPropNames)
name = char(localPropNames(i));
prop = mn_struct.('data').('local').(name);
% Considering only w specified by indexOfSampleFreq
prop = prop(:,parameters.indexOfSampleFreq);
count = 1;
for d = 0 : somatofugalParams.('step') : somatofugalParams.('finalDistance')-somatofugalParams.('step')
indexes = getCompartmentIndexesBySection5(mn_struct, d, d+somatofugalParams.('step'), 0, metric);
if onlyTree
indexes = and(indexes, indexesTree);
end
if onlyBranch
indexes = and(indexes, indexesBranch);
end
indexes = and(indexes, or(indexesOfBranchPoints, indexesOfTerminations));
if ~isempty(indexes)
somatofugalProperties.(name){count} = prop(indexes);
end
count = count + 1;
end
end
% calculating additional properties which do not depend on segment
% sizes
area = mn_struct.('data').('local').('area');
count = 1;
for d = 0 : somatofugalParams.('step') : somatofugalParams.('finalDistance')-somatofugalParams.('step')
indexes = getCompartmentIndexesBySection5(mn_struct, d, d+somatofugalParams.('step'), 0, metric);
indexesInShell = getIndexesOfBranchesInAShell3(mn_struct, d+somatofugalParams.('step'), metric);
if onlyTree ~= 0
indexes = and(indexes, indexesTree);
indexesInShell = and(indexesInShell, indexesTree);
end
if ~isempty(logical(indexes))
somatofugalProperties.('areaInPath'){count} = sum(area(logical(indexes)));
somatofugalProperties.('cumArea'){count} = sum(cell2mat(somatofugalProperties.('areaInPath')));
somatofugalProperties.('numOfBranchPoints'){count} = nnz(somatofugalProperties.('isBranchPoint'){count});
somatofugalProperties.('cumNumOfBranchPoints'){count} = sum(cell2mat(somatofugalProperties.('numOfBranchPoints')));
somatofugalProperties.('numOfTerminations'){count} = nnz(somatofugalProperties.('isTermination'){count});
somatofugalProperties.('cumNumOfTerminations'){count} = sum(cell2mat(somatofugalProperties.('numOfTerminations')));
somatofugalProperties.('cumNumOfDendSegments'){count} = somatofugalProperties.('cumNumOfBranchPoints'){count} + ...
somatofugalProperties.('cumNumOfTerminations'){count};
somatofugalProperties.('numOfBranchesInShell'){count} = nnz(indexesInShell);
end
count = count + 1;
end
elseif strcmp(metric, 'order')
order = mn_struct.('data').('local').('order');
max_order = max(order);
localPropNames = parameters.('featureNames').('local').('morphological');
for i = 1:length(localPropNames)
name = char(localPropNames(i));
prop = mn_struct.('data').('local').(name);
count = 1;
for j = 0:max_order
indexes = getCompartmentIndexesBySection5(mn_struct, 0, 0, j, metric);
if onlyTree
indexes = and(indexes, indexesTree);
end
if onlyBranch
indexes = and(indexes, indexesBranch);
end
indexes = and(indexes, or(indexesOfBranchPoints, indexesOfTerminations));
if ~isempty(indexes)
somatofugalProperties.(name){count} = prop(indexes);
end
count = count + 1;
end
end
localPropNames = parameters.('featureNames').('local').('electronic');
for i = 1:length(localPropNames)
name = char(localPropNames(i));
prop = mn_struct.('data').('local').(name);
prop = prop(:,parameters.indexOfSampleFreq);
count = 1;
for d = 0 : somatofugalParams.('step') : somatofugalParams.('finalDistance')-somatofugalParams.('step')
indexes = getCompartmentIndexesBySection5(mn_struct, d, d+somatofugalParams.('step'), 0, metric);
if onlyTree
indexes = and(indexes, indexesTree);
end
if onlyBranch
indexes = and(indexes, indexesBranch);
end
indexes = and(indexes, or(indexesOfBranchPoints, indexesOfTerminations));
if ~isempty(indexes)
somatofugalProperties.(name){count} = prop(indexes);
end
count = count + 1;
end
end
% calculating additional properties which do not depend on segment
% sizes
area = mn_struct.('data').('local').('area');
% radius = mn_struct.('data').('local').('radius');
count = 1;
for j = 0:max_order
indexes = getCompartmentIndexesBySection5(mn_struct, 0, 0, j, metric);
indexesInShell = getCompartmentIndexesBySection5(mn_struct, 0, 0, j, metric);
if onlyTree ~= 0
indexes = and(indexes, indexesTree);
indexesInShell = and(indexesInShell, indexesTree);
end
if ~isempty(logical(indexes))
somatofugalProperties.('areaInPath'){count} = sum(area(logical(indexes)));
somatofugalProperties.('cumArea'){count} = sum(cell2mat(somatofugalProperties.('areaInPath')));
somatofugalProperties.('numOfBranchPoints'){count} = nnz(somatofugalProperties.('isBranchPoint'){count});
somatofugalProperties.('cumNumOfBranchPoints'){count} = sum(cell2mat(somatofugalProperties.('numOfBranchPoints')));
somatofugalProperties.('numOfTerminations'){count} = nnz(somatofugalProperties.('isTermination'){count});
somatofugalProperties.('cumNumOfTerminations'){count} = sum(cell2mat(somatofugalProperties.('numOfTerminations')));
% somatofugalProperties.('diameter'){count} = 2*radius(logical(indexes));
somatofugalProperties.('cumNumOfDendSegments'){count} = somatofugalProperties.('cumNumOfBranchPoints'){count} + ...
somatofugalProperties.('cumNumOfTerminations'){count};
somatofugalProperties.('numOfBranchesInShell'){count} = nnz(indexesInShell);
end
count = count + 1;
end
end
end