Dynamic Neural Field Composer 0.0.0
A C++20 library and interactive application for building and simulating Dynamic Neural Field (DNF) architectures.
Loading...
Searching...
No Matches
element_parameters.h
Go to the documentation of this file.
1#pragma once
2
3#include <map>
4#include <string>
5#include <format>
6
7#include "tools/logger.h"
8
10{
46
47 inline const std::map<ElementLabel, std::string> ElementLabelToString = {
48 {UNINITIALIZED, "uninitialized" },
49 {NEURAL_FIELD, "neural field" },
50 {GAUSS_STIMULUS, "gauss stimulus" },
51 {BOOST_STIMULUS, "boost stimulus" },
52 {GAUSS_KERNEL, "gauss kernel" },
53 {MEXICAN_HAT_KERNEL, "mexican hat kernel" },
54 {OSCILLATORY_KERNEL, "oscillatory kernel"},
55 {ASYMMETRIC_GAUSS_KERNEL, "asymmetric gauss kernel"},
56 {NORMAL_NOISE, "normal noise" },
57 {CORRELATED_NORMAL_NOISE, "correlated normal noise"},
58 {GAUSS_FIELD_COUPLING, "gauss field coupling" },
59 {FIELD_COUPLING, "field coupling" },
60 {MEMORY_TRACE, "memory trace" },
61
62 {NEURAL_FIELD_2D, "neural field 2d" },
63 {GAUSS_STIMULUS_2D, "gauss stimulus 2d" },
64 {GAUSS_KERNEL_2D, "gauss kernel 2d" },
65 {MEXICAN_HAT_KERNEL_2D, "mexican hat kernel 2d" },
66 {NORMAL_NOISE_2D, "normal noise 2d" },
67 {OSCILLATORY_KERNEL_2D, "oscillatory kernel 2d" },
68 {TIMED_GAUSS_STIMULUS, "timed gauss stimulus" },
69 {TIMED_GAUSS_STIMULUS_2D, "timed gauss stimulus 2d" },
70 {BOOST_STIMULUS_2D, "boost stimulus 2d" },
71 {CORRELATED_NORMAL_NOISE_2D, "correlated normal noise 2d" },
72 {ASYMMETRIC_GAUSS_KERNEL_2D, "asymmetric gauss kernel 2d" },
73 {MEMORY_TRACE_2D, "memory trace 2d" },
74
75 {RESIZE, "resize" },
76 {RESIZE_2D, "resize 2d" },
77
78 {COLLAPSE, "collapse" },
79 {EXPAND, "expand" },
80 };
81
84 enum class ElementCategory : int
85 {
86 FIELD,
88 KERNEL,
89 NOISE,
91 MEMORY,
92 RESHAPE,
94 };
95
98 {
100 const char* name;
101 unsigned char r, g, b;
102 };
103
107 inline const std::map<ElementLabel, ElementCategoryInfo>& elementCategoryTable()
108 {
109 static const std::map<ElementLabel, ElementCategoryInfo> table = {
110 {NEURAL_FIELD, {ElementCategory::FIELD, "Field", 74, 144, 217}},
111 {NEURAL_FIELD_2D, {ElementCategory::FIELD, "Field", 74, 144, 217}},
112
113 {GAUSS_STIMULUS, {ElementCategory::STIMULUS, "Stimulus", 31, 158, 126}},
114 {TIMED_GAUSS_STIMULUS, {ElementCategory::STIMULUS, "Stimulus", 31, 158, 126}},
115 {GAUSS_STIMULUS_2D, {ElementCategory::STIMULUS, "Stimulus", 31, 158, 126}},
116 {TIMED_GAUSS_STIMULUS_2D, {ElementCategory::STIMULUS, "Stimulus", 31, 158, 126}},
117 {BOOST_STIMULUS, {ElementCategory::STIMULUS, "Stimulus", 31, 158, 126}},
118 {BOOST_STIMULUS_2D, {ElementCategory::STIMULUS, "Stimulus", 31, 158, 126}},
119
120 {GAUSS_KERNEL, {ElementCategory::KERNEL, "Kernel", 192, 57, 43}},
121 {MEXICAN_HAT_KERNEL, {ElementCategory::KERNEL, "Kernel", 192, 57, 43}},
122 {OSCILLATORY_KERNEL, {ElementCategory::KERNEL, "Kernel", 192, 57, 43}},
123 {ASYMMETRIC_GAUSS_KERNEL, {ElementCategory::KERNEL, "Kernel", 192, 57, 43}},
124 {GAUSS_KERNEL_2D, {ElementCategory::KERNEL, "Kernel", 192, 57, 43}},
125 {MEXICAN_HAT_KERNEL_2D, {ElementCategory::KERNEL, "Kernel", 192, 57, 43}},
126 {OSCILLATORY_KERNEL_2D, {ElementCategory::KERNEL, "Kernel", 192, 57, 43}},
127 {ASYMMETRIC_GAUSS_KERNEL_2D, {ElementCategory::KERNEL, "Kernel", 192, 57, 43}},
128
129 {NORMAL_NOISE, {ElementCategory::NOISE, "Noise", 230, 126, 34}},
130 {CORRELATED_NORMAL_NOISE, {ElementCategory::NOISE, "Noise", 230, 126, 34}},
131 {NORMAL_NOISE_2D, {ElementCategory::NOISE, "Noise", 230, 126, 34}},
132 {CORRELATED_NORMAL_NOISE_2D, {ElementCategory::NOISE, "Noise", 230, 126, 34}},
133
134 {FIELD_COUPLING, {ElementCategory::COUPLING, "Coupling", 142, 68, 173}},
135 {GAUSS_FIELD_COUPLING, {ElementCategory::COUPLING, "Coupling", 142, 68, 173}},
136
137 {MEMORY_TRACE, {ElementCategory::MEMORY, "Memory", 127, 140, 141}},
138 {MEMORY_TRACE_2D, {ElementCategory::MEMORY, "Memory", 127, 140, 141}},
139
140 {RESIZE, {ElementCategory::RESHAPE, "Reshape", 128, 153, 179}},
141 {RESIZE_2D, {ElementCategory::RESHAPE, "Reshape", 128, 153, 179}},
142 {COLLAPSE, {ElementCategory::RESHAPE, "Reshape", 128, 153, 179}},
143 {EXPAND, {ElementCategory::RESHAPE, "Reshape", 128, 153, 179}},
144 };
145 return table;
146 }
147
150 {
151 const auto& table = elementCategoryTable();
152 const auto it = table.find(label);
153 if (it != table.end())
154 return it->second;
155 return {ElementCategory::UNKNOWN, "Unknown", 150, 150, 150};
156 }
157
159 {
160 int dimensionality; // 1 or 2 (D)
162 double d_x, d_y;
163 int size_x, size_y, size; // size = size_x * size_y
164
165 explicit ElementDimensions(int dimensionality = 1);
166 explicit ElementDimensions(int x_max, double d_x); // 1D
167 explicit ElementDimensions(int x_max, int y_max, double d_x, double d_y); // 2D
168 bool operator==(const ElementDimensions& other) const;
169 void print() const;
170 [[nodiscard]] std::string toString() const;
171 };
172
174 {
175 static inline int uniqueIdentifierCounter = 0;
177 std::string uniqueName;
179
181 explicit ElementIdentifiers(std::string elementName);
182 bool operator==(const ElementIdentifiers& other) const;
183 void print() const;
184 [[nodiscard]] std::string toString() const;
185 };
186
188 {
191
194 explicit ElementCommonParameters(const std::string& elementName);
195 ElementCommonParameters(const std::string& elementName, int x_max);
196 ElementCommonParameters(const std::string& elementName,
200 bool operator==(const ElementCommonParameters& other) const;
201 void print() const;
202 [[nodiscard]] std::string toString() const;
203 };
204
206 {
208 virtual ~ElementSpecificParameters() = default;
209 [[nodiscard]] virtual std::string toString() const = 0;
210 void print() const;
211 };
212}
Definition element_parameters.h:10
const std::map< ElementLabel, std::string > ElementLabelToString
Definition element_parameters.h:47
ElementCategoryInfo getElementCategoryInfo(const ElementLabel label)
Category info for a label, or an UNKNOWN/grey fallback.
Definition element_parameters.h:149
ElementCategory
Coarse functional grouping of an element, independent of dimensionality. Single source of truth for t...
Definition element_parameters.h:85
@ RESHAPE
Dimension/size-bridging elements: resize, collapse, expand.
ElementLabel
Definition element_parameters.h:12
@ NORMAL_NOISE_2D
Definition element_parameters.h:31
@ ASYMMETRIC_GAUSS_KERNEL
Definition element_parameters.h:20
@ BOOST_STIMULUS_2D
Definition element_parameters.h:35
@ CORRELATED_NORMAL_NOISE_2D
Definition element_parameters.h:36
@ GAUSS_KERNEL_2D
Definition element_parameters.h:29
@ ASYMMETRIC_GAUSS_KERNEL_2D
Definition element_parameters.h:37
@ UNINITIALIZED
Definition element_parameters.h:13
@ MEXICAN_HAT_KERNEL_2D
Definition element_parameters.h:30
@ OSCILLATORY_KERNEL
Definition element_parameters.h:19
@ GAUSS_KERNEL
Definition element_parameters.h:17
@ NORMAL_NOISE
Definition element_parameters.h:21
@ MEXICAN_HAT_KERNEL
Definition element_parameters.h:18
@ TIMED_GAUSS_STIMULUS_2D
Definition element_parameters.h:34
@ MEMORY_TRACE_2D
Definition element_parameters.h:38
@ MEMORY_TRACE
Definition element_parameters.h:25
@ RESIZE_2D
Definition element_parameters.h:41
@ GAUSS_STIMULUS
Definition element_parameters.h:15
@ RESIZE
Definition element_parameters.h:40
@ NEURAL_FIELD_2D
Definition element_parameters.h:27
@ BOOST_STIMULUS
Definition element_parameters.h:16
@ FIELD_COUPLING
Definition element_parameters.h:23
@ NEURAL_FIELD
Definition element_parameters.h:14
@ OSCILLATORY_KERNEL_2D
Definition element_parameters.h:32
@ TIMED_GAUSS_STIMULUS
Definition element_parameters.h:33
@ CORRELATED_NORMAL_NOISE
Definition element_parameters.h:22
@ GAUSS_STIMULUS_2D
Definition element_parameters.h:28
@ GAUSS_FIELD_COUPLING
Definition element_parameters.h:24
@ EXPAND
Definition element_parameters.h:44
@ COLLAPSE
Definition element_parameters.h:43
const std::map< ElementLabel, ElementCategoryInfo > & elementCategoryTable()
Maps every ElementLabel to its category info. The one place UI panels resolve an element's type/categ...
Definition element_parameters.h:107
Category + RGBA colour (0..255) used to render an element's type chip.
Definition element_parameters.h:98
unsigned char g
Definition element_parameters.h:101
unsigned char r
Definition element_parameters.h:101
const char * name
Definition element_parameters.h:100
unsigned char b
Definition element_parameters.h:101
ElementCategory category
Definition element_parameters.h:99
Definition element_parameters.h:188
void print() const
Definition element_parameters.cpp:135
ElementDimensions dimensionParameters
Definition element_parameters.h:190
std::string toString() const
Definition element_parameters.cpp:140
ElementCommonParameters()
Definition element_parameters.cpp:102
bool operator==(const ElementCommonParameters &other) const
Definition element_parameters.cpp:130
ElementIdentifiers identifiers
Definition element_parameters.h:189
Definition element_parameters.h:159
double d_y
Definition element_parameters.h:162
int size
Definition element_parameters.h:163
int size_x
Definition element_parameters.h:163
std::string toString() const
Definition element_parameters.cpp:55
int y_max
Definition element_parameters.h:161
int dimensionality
Definition element_parameters.h:160
void print() const
Definition element_parameters.cpp:50
int size_y
Definition element_parameters.h:163
int x_max
Definition element_parameters.h:161
double d_x
Definition element_parameters.h:162
bool operator==(const ElementDimensions &other) const
Definition element_parameters.cpp:43
Definition element_parameters.h:174
bool operator==(const ElementIdentifiers &other) const
Definition element_parameters.cpp:80
std::string toString() const
Definition element_parameters.cpp:91
std::string uniqueName
Definition element_parameters.h:177
int uniqueIdentifier
Definition element_parameters.h:176
void print() const
Definition element_parameters.cpp:86
static int uniqueIdentifierCounter
Definition element_parameters.h:175
ElementLabel label
Definition element_parameters.h:178
Definition element_parameters.h:206
void print() const
Definition element_parameters.cpp:149
virtual std::string toString() const =0