-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwritenetworktofile.m
More file actions
73 lines (70 loc) · 2.58 KB
/
writenetworktofile.m
File metadata and controls
73 lines (70 loc) · 2.58 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
function writenetworktofile(fname, simulation, inputneuron, neuron, IIneuron)
%writenetworktofile writes network out to a file
% inputs are name of file, structures simulation, , inputneuronneuron and IIneuron
% started LSS 15 Sept 2025.
%
% count number of network arcs for initialising arrays
arcsfrominputs = 0;
arcsfromTPNs = 0 ;
arcsfromIIs = 0 ;
for i = 1:simulation.N_Inputs
arcsfrominputs = arcsfrominputs + length(inputneuron(i).targets) ;
end
for i = 1 :simulation.N_TPNs
arcsfromTPNs = arcsfromTPNs + length(neuron(i).targets) ;
end
for i = 1 :simulation.N_IIs
arcsfromIIs = arcsfromIIs + length(IIneuron(i).targets) ;
end
arcs = arcsfrominputs + arcsfromTPNs + arcsfromIIs ;
% from_ntype from_nno to_ntype to_nno to_syntype to_synno delay
% initialise the entities to be in table
from_ntype = strings(arcs, 1) ;
from_nno = zeros(arcs, 1) ;
to_ntype = strings(arcs, 1) ;
to_nno = zeros(arcs, 1) ;
to_syntype = strings(arcs, 1) ;
to_synno = zeros(arcs, 1) ;
delay = zeros(arcs, 1) ;
% fill these arrays
arcno = 1 ;
for i = 1:simulation.N_Inputs
for tno = 1:length(inputneuron(i).targets)
from_ntype(arcno) = "X";
from_nno(arcno) = i ;
to_ntype(arcno) = inputneuron(i).targets(tno).to_ntype ;
to_nno(arcno) = inputneuron(i).targets(tno).to_nno;
to_syntype(arcno) = inputneuron(i).targets(tno).to_syntype ;
to_synno(arcno) = inputneuron(i).targets(tno).to_synno ;
delay(arcno) = inputneuron(i).targets(tno).delay ;
arcno = arcno + 1 ;
end
end
for i = 1:simulation.N_TPNs
for tno = 1:length(neuron(i).targets)
from_ntype(arcno) = "TPN";
from_nno(arcno) = i ;
to_ntype(arcno) = neuron(i).targets(tno).to_ntype ;
to_nno(arcno) = neuron(i).targets(tno).to_nno;
to_syntype(arcno) = neuron(i).targets(tno).to_syntype ;
to_synno(arcno) = neuron(i).targets(tno).to_synno ;
delay(arcno) = neuron(i).targets(tno).delay ;
arcno = arcno + 1 ;
end
end
for i = 1:simulation.N_IIs
for tno = 1:length(IIneuron(i).targets)
from_ntype(arcno) = "II";
from_nno(arcno) = i ;
to_ntype(arcno) = IIneuron(i).targets(tno).to_ntype ;
to_nno(arcno) = IIneuron(i).targets(tno).to_nno;
to_syntype(arcno) = IIneuron(i).targets(tno).to_syntype ;
to_synno(arcno) = IIneuron(i).targets(tno).to_synno ;
delay(arcno) = IIneuron(i).targets(tno).delay ;
arcno = arcno + 1 ;
end
end
% create table and write it
T= table(from_ntype, from_nno, to_ntype, to_nno, to_syntype, to_synno, delay ) ;
writetable(T, fname,"Delimiter", '\t') ;
end