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.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;
18 std::vector<std::pair<double, double>> onTimes;
21
22 explicit TimedGaussStimulusParameters(double width = 5.0, double amplitude = 15.0,
23 double position = 50.0,
24 std::vector<std::pair<double, double>> onTimes = {},
25 bool circular = true, bool normalized = false)
28 {}
29
31 {
32 constexpr double epsilon = 1e-6;
33 return std::abs(width - other.width) < epsilon &&
34 std::abs(amplitude - other.amplitude) < epsilon &&
35 std::abs(position - other.position) < epsilon &&
36 onTimes == other.onTimes &&
37 circular == other.circular &&
38 normalized == other.normalized;
39 }
40
41 [[nodiscard]] std::string toString() const override
42 {
43 std::ostringstream result;
44 result << std::fixed << std::setprecision(2);
45 result << "Parameters: ["
46 << "Width: " << width << ", "
47 << "Amplitude: " << amplitude << ", "
48 << "Position: " << position << ", "
49 << "OnTimes: [";
50 for (size_t i = 0; i < onTimes.size(); ++i)
51 {
52 if (i > 0) result << "; ";
53 result << onTimes[i].first << "-" << onTimes[i].second;
54 }
55 result << "], "
56 << "Circular: " << (circular ? "true" : "false") << ", "
57 << "Normalized: " << (normalized ? "true" : "false") << "]";
58 return result.str();
59 }
60 };
61
72 class TimedGaussStimulus final : public Element
73 {
74 private:
76 std::vector<double> stimulusPattern;
77 public:
78 TimedGaussStimulus(const ElementCommonParameters& elementCommonParameters,
79 const TimedGaussStimulusParameters& parameters);
80
81 void init() override;
82 void step(double t, double deltaT) override;
83 [[nodiscard]] std::string toString() const override;
84 [[nodiscard]] std::shared_ptr<Element> clone() const override;
85
86 void setParameters(const TimedGaussStimulusParameters& parameters);
87 [[nodiscard]] TimedGaussStimulusParameters getParameters() const;
88 };
89}
Abstract base class for all simulation elements.
Definition element.h:28
Gaussian stimulus that is active only during specified time intervals.
Definition timed_gauss_stimulus.h:73
std::shared_ptr< Element > clone() const override
Definition timed_gauss_stimulus.cpp:76
void init() override
Initialize the element (called once before the simulation loop).
Definition timed_gauss_stimulus.cpp:20
TimedGaussStimulusParameters getParameters() const
Definition timed_gauss_stimulus.cpp:90
void step(double t, double deltaT) override
Advance the element by one time step.
Definition timed_gauss_stimulus.cpp:56
void setParameters(const TimedGaussStimulusParameters &parameters)
Definition timed_gauss_stimulus.cpp:81
std::string toString() const override
Definition timed_gauss_stimulus.cpp:68
Definition element_parameters.h:10
Definition element_parameters.h:188
Definition element_parameters.h:206
Definition timed_gauss_stimulus.h:14
std::vector< std::pair< double, double > > onTimes
Definition timed_gauss_stimulus.h:18
std::string toString() const override
Definition timed_gauss_stimulus.h:41
bool operator==(const TimedGaussStimulusParameters &other) const
Definition timed_gauss_stimulus.h:30
bool normalized
Definition timed_gauss_stimulus.h:20
double width
Definition timed_gauss_stimulus.h:15
double position
Definition timed_gauss_stimulus.h:17
double amplitude
Definition timed_gauss_stimulus.h:16
TimedGaussStimulusParameters(double width=5.0, double amplitude=15.0, double position=50.0, std::vector< std::pair< double, double > > onTimes={}, bool circular=true, bool normalized=false)
Definition timed_gauss_stimulus.h:22
bool circular
Definition timed_gauss_stimulus.h:19