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
gauss_stimulus.h
Go to the documentation of this file.
1#pragma once
2
3#include <iostream>
4
5#include "tools/math.h"
6#include "element.h"
7
8
10{
13 struct GaussStimulusParameters final : ElementSpecificParameters
14 {
15 double width;
16 double amplitude;
17 double position;
18 bool circular;
19 bool normalized;
20
27 explicit GaussStimulusParameters(const double width = 5.0, const double amplitude = 15.0,
28 const double position = 50.0, const bool circular = true, const bool normalized = false)
31 {}
32
33 bool operator==(const GaussStimulusParameters& other) const
34 {
35 constexpr double epsilon = 1e-6;
36
37 return std::abs(width - other.width) < epsilon &&
38 std::abs(position - other.position) < epsilon &&
39 std::abs(amplitude - other.amplitude) < epsilon &&
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); // Ensures numbers have 2 decimal places
48 result << "Parameters: ["
49 << "Width: " << width << ", "
50 << "Amplitude: " << amplitude << ", "
51 << "Position: " << position << ", "
52 << "Circular: " << (circular ? "true" : "false") << ", "
53 << "Normalized: " << (normalized ? "true" : "false")
54 << "]";
55 return result.str();
56 }
57 };
58
67 class GaussStimulus final : public Element
68 {
69 private:
70 GaussStimulusParameters parameters;
71 public:
75 GaussStimulus(const ElementCommonParameters& elementCommonParameters,
76 const GaussStimulusParameters& parameters);
77
78 void init() override;
79 void step(double t, double deltaT) override;
80 std::string toString() const override;
81 std::shared_ptr<Element> clone() const override;
82
83 void setParameters(const GaussStimulusParameters& parameters);
85 };
86}
Abstract base class for all simulation elements.
Definition element.h:28
Localized Gaussian input stimulus applied to a neural field.
Definition gauss_stimulus.h:68
void step(double t, double deltaT) override
Advance the element by one time step.
Definition gauss_stimulus.cpp:54
std::string toString() const override
Definition gauss_stimulus.cpp:58
void init() override
Initialize the element (called once before the simulation loop).
Definition gauss_stimulus.cpp:18
GaussStimulusParameters getParameters() const
Definition gauss_stimulus.cpp:78
std::shared_ptr< Element > clone() const override
Definition gauss_stimulus.cpp:66
void setParameters(const GaussStimulusParameters &parameters)
Definition gauss_stimulus.cpp:72
Definition element_parameters.h:10
Definition element_parameters.h:188
Parameters for a Gaussian-shaped external stimulus.
Definition gauss_stimulus_parameters.h:10
GaussStimulusParameters(const double width=5.0, const double amplitude=15.0, const double position=50.0, const bool circular=true, const bool normalized=false)
Construct a GaussStimulus parameter set.
Definition gauss_stimulus.h:27
std::string toString() const override
Definition gauss_stimulus.h:44
double position
Spatial position (centre) of the Gaussian.
Definition gauss_stimulus_parameters.h:13
double width
Standard deviation (σ) of the Gaussian bump.
Definition gauss_stimulus_parameters.h:11
bool circular
If true, the stimulus wraps at the field boundary.
Definition gauss_stimulus_parameters.h:14
bool operator==(const GaussStimulusParameters &other) const
Definition gauss_stimulus.h:33
double amplitude
Peak amplitude.
Definition gauss_stimulus_parameters.h:12
bool normalized
If true, the Gaussian is area-normalised.
Definition gauss_stimulus_parameters.h:15