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
timed_gauss_stimulus_2d.h
Go to the documentation of this file.
1#pragma once
2
3#include <vector>
4#include <utility>
5#include <sstream>
6#include <iomanip>
7
8#include "tools/math.h"
9#include "element.h"
10
12{
14 {
15 double width;
16 double amplitude;
17 double position_x;
18 double position_y;
19 std::vector<std::pair<double, double>> onTimes;
22
23 explicit TimedGaussStimulus2DParameters(double width = 5.0, double amplitude = 15.0,
24 double position_x = 25.0, double position_y = 25.0,
25 std::vector<std::pair<double, double>> onTimes = {},
26 bool circular = true, bool normalized = false)
30 {}
31
33 {
34 constexpr double epsilon = 1e-6;
35 return std::abs(width - other.width) < epsilon &&
36 std::abs(amplitude - other.amplitude) < epsilon &&
37 std::abs(position_x - other.position_x) < epsilon &&
38 std::abs(position_y - other.position_y) < epsilon &&
39 onTimes == other.onTimes &&
40 circular == other.circular &&
41 normalized == other.normalized;
42 }
43
44 [[nodiscard]] std::string toString() const override
45 {
46 std::ostringstream result;
47 result << std::fixed << std::setprecision(2);
48 result << "Parameters: ["
49 << "Width: " << width << ", "
50 << "Amplitude: " << amplitude << ", "
51 << "Position x: " << position_x << ", "
52 << "Position y: " << position_y << ", "
53 << "OnTimes: [";
54 for (size_t i = 0; i < onTimes.size(); ++i)
55 {
56 if (i > 0) result << "; ";
57 result << onTimes[i].first << "-" << onTimes[i].second;
58 }
59 result << "], "
60 << "Circular: " << (circular ? "true" : "false") << ", "
61 << "Normalized: " << (normalized ? "true" : "false") << "]";
62 return result.str();
63 }
64 };
65
76 class TimedGaussStimulus2D final : public Element
77 {
78 private:
80 std::vector<double> stimulusPattern;
81 public:
82 TimedGaussStimulus2D(const ElementCommonParameters& elementCommonParameters,
83 const TimedGaussStimulus2DParameters& parameters);
84
85 void init() override;
86 void step(double t, double deltaT) override;
87 [[nodiscard]] std::string toString() const override;
88 [[nodiscard]] std::shared_ptr<Element> clone() const override;
89
90 void setParameters(const TimedGaussStimulus2DParameters& parameters);
92 };
93}
Abstract base class for all simulation elements.
Definition element.h:28
2D Gaussian stimulus that is active only during specified time intervals.
Definition timed_gauss_stimulus_2d.h:77
TimedGaussStimulus2DParameters getParameters() const
Definition timed_gauss_stimulus_2d.cpp:119
void step(double t, double deltaT) override
Advance the element by one time step.
Definition timed_gauss_stimulus_2d.cpp:80
void init() override
Initialize the element (called once before the simulation loop).
Definition timed_gauss_stimulus_2d.cpp:26
void setParameters(const TimedGaussStimulus2DParameters &parameters)
Definition timed_gauss_stimulus_2d.cpp:105
std::shared_ptr< Element > clone() const override
Definition timed_gauss_stimulus_2d.cpp:100
std::string toString() const override
Definition timed_gauss_stimulus_2d.cpp:92
Definition element_parameters.h:10
Definition element_parameters.h:188
Definition element_parameters.h:206
Definition timed_gauss_stimulus_2d.h:14
double position_x
Definition timed_gauss_stimulus_2d.h:17
double position_y
Definition timed_gauss_stimulus_2d.h:18
double width
Definition timed_gauss_stimulus_2d.h:15
std::vector< std::pair< double, double > > onTimes
Definition timed_gauss_stimulus_2d.h:19
double amplitude
Definition timed_gauss_stimulus_2d.h:16
TimedGaussStimulus2DParameters(double width=5.0, double amplitude=15.0, double position_x=25.0, double position_y=25.0, std::vector< std::pair< double, double > > onTimes={}, bool circular=true, bool normalized=false)
Definition timed_gauss_stimulus_2d.h:23
bool circular
Definition timed_gauss_stimulus_2d.h:20
std::string toString() const override
Definition timed_gauss_stimulus_2d.h:44
bool normalized
Definition timed_gauss_stimulus_2d.h:21
bool operator==(const TimedGaussStimulus2DParameters &other) const
Definition timed_gauss_stimulus_2d.h:32