Skip to content
This repository was archived by the owner on Feb 26, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions include/bbp/sonata/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -464,8 +464,8 @@ class SONATA_API SimulationConfig
double riseTime{};
/// The decay time of the bi-exponential shots (ms)
double decayTime{};
/// Override the random seed to introduce correlations between cells
int randomSeed{};
/// Override the random seed to introduce correlations between cells, default = None
nonstd::optional<int> randomSeed{nonstd::nullopt};
/// Timestep of generated signal in ms. Default is 0.25 ms
double dt{};
/// Rate of Poisson events (Hz)
Expand All @@ -482,8 +482,8 @@ class SONATA_API SimulationConfig
double riseTime{};
/// The decay time of the bi-exponential shots (ms)
double decayTime{};
/// Override the random seed to introduce correlations between cells
int randomSeed{};
/// Override the random seed to introduce correlations between cells, default = None
nonstd::optional<int> randomSeed{nonstd::nullopt};
/// Timestep of generated signal in ms. Default is 0.25 ms
double dt{};
/// The coefficient of variation (sd/mean) of gamma-distributed amplitudes
Expand All @@ -501,8 +501,8 @@ class SONATA_API SimulationConfig
double riseTime{};
/// The decay time of the bi-exponential shots (ms)
double decayTime{};
/// Override the random seed to introduce correlations between cells
int randomSeed{};
/// Override the random seed to introduce correlations between cells, default = None
nonstd::optional<int> randomSeed{nonstd::nullopt};
/// Timestep of generated signal in ms. Default is 0.25 ms
double dt{};
/// The coefficient of variation (sd/mean) of gamma-distributed amplitudes
Expand All @@ -520,8 +520,8 @@ class SONATA_API SimulationConfig
double reversal{};
/// Timestep of generated signal in ms. Default is 0.25 ms
double dt{};
/// Override the random seed to introduce correlations between cells
int randomSeed{};
/// Override the random seed to introduce correlations between cells, default = None
nonstd::optional<int> randomSeed{nonstd::nullopt};
/// Signal mean in nA (current_clamp) or uS (conductance)
double mean{};
/// Signal std dev in nA (current_clamp) or uS (conductance)
Expand All @@ -535,8 +535,8 @@ class SONATA_API SimulationConfig
double reversal{};
/// Timestep of generated signal in ms. Default is 0.25 ms
double dt{};
/// Override the random seed to introduce correlations between cells
int randomSeed{};
/// Override the random seed to introduce correlations between cells, default = None
nonstd::optional<int> randomSeed{nonstd::nullopt};
/// Signal mean as percentage of a cell’s threshold current (current_clamp) or inverse input
/// resistance (conductance)
double meanPercent{};
Expand Down
22 changes: 17 additions & 5 deletions python/generated/docstrings.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ static const char *__doc_bbp_sonata_NodeSets_NodeSets_2 = R"doc()doc";

static const char *__doc_bbp_sonata_NodeSets_NodeSets_3 = R"doc()doc";

static const char *__doc_bbp_sonata_NodeSets_NodeSets_4 = R"doc()doc";

static const char *__doc_bbp_sonata_NodeSets_fromFile = R"doc(Open a SONATA `node sets` file from a path */)doc";

static const char *__doc_bbp_sonata_NodeSets_impl = R"doc()doc";
Expand Down Expand Up @@ -652,7 +654,9 @@ static const char *__doc_bbp_sonata_SimulationConfig_InputAbsoluteShotNoise_dt =

static const char *__doc_bbp_sonata_SimulationConfig_InputAbsoluteShotNoise_mean = R"doc(Signal mean in nA (current_clamp) or uS (conductance).)doc";

static const char *__doc_bbp_sonata_SimulationConfig_InputAbsoluteShotNoise_randomSeed = R"doc(Override the random seed to introduce correlations between cells)doc";
static const char *__doc_bbp_sonata_SimulationConfig_InputAbsoluteShotNoise_randomSeed =
R"doc(Override the random seed to introduce correlations between cells,
default = None)doc";

static const char *__doc_bbp_sonata_SimulationConfig_InputAbsoluteShotNoise_riseTime = R"doc(The rise time of the bi-exponential shots (ms))doc";

Expand Down Expand Up @@ -740,7 +744,9 @@ static const char *__doc_bbp_sonata_SimulationConfig_InputOrnsteinUhlenbeck_dt =

static const char *__doc_bbp_sonata_SimulationConfig_InputOrnsteinUhlenbeck_mean = R"doc(Signal mean in nA (current_clamp) or uS (conductance))doc";

static const char *__doc_bbp_sonata_SimulationConfig_InputOrnsteinUhlenbeck_randomSeed = R"doc(Override the random seed to introduce correlations between cells)doc";
static const char *__doc_bbp_sonata_SimulationConfig_InputOrnsteinUhlenbeck_randomSeed =
R"doc(Override the random seed to introduce correlations between cells,
default = None)doc";

static const char *__doc_bbp_sonata_SimulationConfig_InputOrnsteinUhlenbeck_reversal = R"doc(Reversal potential for conductance injection in mV. Default is 0)doc";

Expand Down Expand Up @@ -772,7 +778,9 @@ static const char *__doc_bbp_sonata_SimulationConfig_InputRelativeOrnsteinUhlenb
R"doc(Signal mean as percentage of a cell’s threshold current
(current_clamp) or inverse input resistance (conductance))doc";

static const char *__doc_bbp_sonata_SimulationConfig_InputRelativeOrnsteinUhlenbeck_randomSeed = R"doc(Override the random seed to introduce correlations between cells)doc";
static const char *__doc_bbp_sonata_SimulationConfig_InputRelativeOrnsteinUhlenbeck_randomSeed =
R"doc(Override the random seed to introduce correlations between cells,
default = None)doc";

static const char *__doc_bbp_sonata_SimulationConfig_InputRelativeOrnsteinUhlenbeck_reversal = R"doc(Reversal potential for conductance injection in mV. Default is 0)doc";

Expand All @@ -794,7 +802,9 @@ static const char *__doc_bbp_sonata_SimulationConfig_InputRelativeShotNoise_mean
R"doc(Signal mean as percentage of a cell’s threshold current
(current_clamp) or inverse input resistance (conductance))doc";

static const char *__doc_bbp_sonata_SimulationConfig_InputRelativeShotNoise_randomSeed = R"doc(Override the random seed to introduce correlations between cells)doc";
static const char *__doc_bbp_sonata_SimulationConfig_InputRelativeShotNoise_randomSeed =
R"doc(Override the random seed to introduce correlations between cells,
default = None)doc";

static const char *__doc_bbp_sonata_SimulationConfig_InputRelativeShotNoise_riseTime = R"doc(The rise time of the bi-exponential shots (ms))doc";

Expand Down Expand Up @@ -822,7 +832,9 @@ static const char *__doc_bbp_sonata_SimulationConfig_InputShotNoise_decayTime =

static const char *__doc_bbp_sonata_SimulationConfig_InputShotNoise_dt = R"doc(Timestep of generated signal in ms. Default is 0.25 ms)doc";

static const char *__doc_bbp_sonata_SimulationConfig_InputShotNoise_randomSeed = R"doc(Override the random seed to introduce correlations between cells)doc";
static const char *__doc_bbp_sonata_SimulationConfig_InputShotNoise_randomSeed =
R"doc(Override the random seed to introduce correlations between cells,
default = None)doc";

static const char *__doc_bbp_sonata_SimulationConfig_InputShotNoise_rate = R"doc(Rate of Poisson events (Hz))doc";

Expand Down
6 changes: 5 additions & 1 deletion python/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@ def test_basic(self):
self.assertEqual(self.config.input('ex_subthreshold').percent_less, 80)
self.assertEqual(self.config.input('ex_shotnoise').rise_time, 0.4)
self.assertEqual(self.config.input('ex_shotnoise').amp_mean, 70)
self.assertEqual(self.config.input('ex_shotnoise').random_seed, None)

self.assertEqual(self.config.input('ex_hyperpolarizing').duration, 1000)

Expand All @@ -468,7 +469,7 @@ def test_basic(self):
self.assertEqual(self.config.input('ex_rel_shotnoise').delay, 0)
self.assertEqual(self.config.input('ex_rel_shotnoise').duration, 1000)
self.assertEqual(self.config.input('ex_rel_shotnoise').node_set, "L5E")
self.assertEqual(self.config.input('ex_rel_shotnoise').random_seed, self.config.run.random_seed)
self.assertEqual(self.config.input('ex_rel_shotnoise').random_seed, 230522)
self.assertEqual(self.config.input('ex_rel_shotnoise').dt, 0.25)

self.assertEqual(self.config.input('ex_replay').input_type.name, 'spikes')
Expand All @@ -485,19 +486,22 @@ def test_basic(self):
self.assertEqual(self.config.input('ex_abs_shotnoise').amp_cv, 0.63)
self.assertEqual(self.config.input('ex_abs_shotnoise').mean, 50)
self.assertEqual(self.config.input('ex_abs_shotnoise').sigma, 5)
self.assertEqual(self.config.input('ex_abs_shotnoise').random_seed, None)

self.assertEqual(self.config.input('ex_OU').module.name, "ornstein_uhlenbeck")
self.assertEqual(self.config.input('ex_OU').input_type.name, "conductance")
self.assertEqual(self.config.input('ex_OU').tau, 2.8)
self.assertEqual(self.config.input('ex_OU').reversal, 10)
self.assertEqual(self.config.input('ex_OU').mean, 50)
self.assertEqual(self.config.input('ex_OU').sigma, 5)
self.assertEqual(self.config.input('ex_OU').random_seed, None)

self.assertEqual(self.config.input('ex_rel_OU').input_type.name, "current_clamp")
self.assertEqual(self.config.input('ex_rel_OU').tau, 2.8)
self.assertEqual(self.config.input('ex_rel_OU').reversal, 0)
self.assertEqual(self.config.input('ex_rel_OU').mean_percent, 70)
self.assertEqual(self.config.input('ex_rel_OU').sd_percent, 10)
self.assertEqual(self.config.input('ex_rel_OU').random_seed, 230522)

self.assertEqual(self.config.input('ex_seclamp').voltage, 1.1)
self.assertEqual(self.config.input('ex_seclamp').series_resistance, 0.5)
Expand Down
14 changes: 6 additions & 8 deletions src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,6 @@ void parseVariantType(const nlohmann::json& it, variantValueType& var) {
SimulationConfig::Input parseInputModule(const nlohmann::json& valueIt,
const SimulationConfig::InputBase::Module module,
const std::string& basePath,
int randomSeed,
const std::string& debugStr) {
using Module = SimulationConfig::InputBase::Module;

Expand Down Expand Up @@ -415,7 +414,7 @@ SimulationConfig::Input parseInputModule(const nlohmann::json& valueIt,
parseCommon(ret);
parseMandatory(valueIt, "rise_time", debugStr, ret.riseTime);
parseMandatory(valueIt, "decay_time", debugStr, ret.decayTime);
parseOptional(valueIt, "random_seed", ret.randomSeed, {randomSeed});
parseOptional(valueIt, "random_seed", ret.randomSeed);
parseOptional(valueIt, "dt", ret.dt, {0.25});
parseMandatory(valueIt, "rate", debugStr, ret.rate);
parseMandatory(valueIt, "amp_mean", debugStr, ret.ampMean);
Expand All @@ -428,7 +427,7 @@ SimulationConfig::Input parseInputModule(const nlohmann::json& valueIt,

parseMandatory(valueIt, "rise_time", debugStr, ret.riseTime);
parseMandatory(valueIt, "decay_time", debugStr, ret.decayTime);
parseOptional(valueIt, "random_seed", ret.randomSeed, {randomSeed});
parseOptional(valueIt, "random_seed", ret.randomSeed);
parseOptional(valueIt, "dt", ret.dt, {0.25});
parseMandatory(valueIt, "amp_cv", debugStr, ret.ampCv);
parseMandatory(valueIt, "mean_percent", debugStr, ret.meanPercent);
Expand All @@ -441,7 +440,7 @@ SimulationConfig::Input parseInputModule(const nlohmann::json& valueIt,

parseMandatory(valueIt, "rise_time", debugStr, ret.riseTime);
parseMandatory(valueIt, "decay_time", debugStr, ret.decayTime);
parseOptional(valueIt, "random_seed", ret.randomSeed, {randomSeed});
parseOptional(valueIt, "random_seed", ret.randomSeed);
parseOptional(valueIt, "dt", ret.dt, {0.25});
parseMandatory(valueIt, "amp_cv", debugStr, ret.ampCv);
parseMandatory(valueIt, "mean", debugStr, ret.mean);
Expand Down Expand Up @@ -473,7 +472,7 @@ SimulationConfig::Input parseInputModule(const nlohmann::json& valueIt,
parseCommon(ret);
parseMandatory(valueIt, "tau", debugStr, ret.tau);
parseOptional(valueIt, "reversal", ret.reversal);
parseOptional(valueIt, "random_seed", ret.randomSeed, {randomSeed});
parseOptional(valueIt, "random_seed", ret.randomSeed);
parseOptional(valueIt, "dt", ret.dt, {0.25});

parseMandatory(valueIt, "mean", debugStr, ret.mean);
Expand All @@ -485,7 +484,7 @@ SimulationConfig::Input parseInputModule(const nlohmann::json& valueIt,
parseCommon(ret);
parseMandatory(valueIt, "tau", debugStr, ret.tau);
parseOptional(valueIt, "reversal", ret.reversal);
parseOptional(valueIt, "random_seed", ret.randomSeed, {randomSeed});
parseOptional(valueIt, "random_seed", ret.randomSeed);
parseOptional(valueIt, "dt", ret.dt, {0.25});

parseMandatory(valueIt, "mean_percent", debugStr, ret.meanPercent);
Expand Down Expand Up @@ -1016,8 +1015,7 @@ class SimulationConfig::Parser
InputBase::Module module;
parseMandatory(valueIt, "module", debugStr, module);

const auto input =
parseInputModule(valueIt, module, _basePath, parseRun().randomSeed, debugStr);
const auto input = parseInputModule(valueIt, module, _basePath, debugStr);
result[it.key()] = input;

auto mismatchingModuleInputType = [&it]() {
Expand Down
6 changes: 4 additions & 2 deletions tests/data/config/simulation_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@
"amp_cv": 0.63,
"mean_percent": 70,
"sd_percent": 40,
"node_set": "L5E"
"node_set": "L5E",
"random_seed": 230522
},
"ex_abs_shotnoise": {
"input_type": "conductance",
Expand Down Expand Up @@ -198,7 +199,8 @@
"tau": 2.8,
"mean_percent": 70,
"sd_percent": 10,
"node_set": "Column"
"node_set": "Column",
"random_seed": 230522
}
},
"connection_overrides": [
Expand Down
7 changes: 5 additions & 2 deletions tests/test_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ TEST_CASE("SimulationConfig") {
CHECK(input.ampMean == 70);
CHECK(input.ampVar == 40);
CHECK(input.rate == 4);
CHECK(input.randomSeed == 201506);
CHECK(input.randomSeed == nonstd::nullopt);
CHECK(input.riseTime == 0.4);
CHECK(input.decayTime == 4);
}
Expand All @@ -480,7 +480,7 @@ TEST_CASE("SimulationConfig") {
CHECK(input.ampCv == 0.63);
CHECK(input.meanPercent == 70);
CHECK(input.sdPercent == 40);
CHECK(input.randomSeed == 201506);
CHECK(input.randomSeed == 230522);
CHECK(input.riseTime == 0.4);
CHECK(input.decayTime == 4);
}
Expand Down Expand Up @@ -520,6 +520,7 @@ TEST_CASE("SimulationConfig") {
CHECK(input.ampCv == 0.63);
CHECK(input.mean == 50);
CHECK(input.sigma == 5);
CHECK(input.randomSeed == nonstd::nullopt);
}
{
const auto input = nonstd::get<SimulationConfig::InputOrnsteinUhlenbeck>(
Expand All @@ -530,6 +531,7 @@ TEST_CASE("SimulationConfig") {
CHECK(input.reversal == 10);
CHECK(input.mean == 50);
CHECK(input.sigma == 5);
CHECK(input.randomSeed == nonstd::nullopt);
}
{
const auto input = nonstd::get<SimulationConfig::InputRelativeOrnsteinUhlenbeck>(
Expand All @@ -540,6 +542,7 @@ TEST_CASE("SimulationConfig") {
CHECK(input.reversal == 0);
CHECK(input.meanPercent == 70);
CHECK(input.sdPercent == 10);
CHECK(input.randomSeed == 230522);
}

CHECK(config.listInputNames() == std::set<std::string>{"ex_abs_shotnoise",
Expand Down