Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SimulationConfig: Adds "represents_physical_electrode" field in "inputs" section #354

Merged
merged 4 commits into from
Apr 29, 2024
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
3 changes: 1 addition & 2 deletions .github/workflows/publish-sdist-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ jobs:
path: src-cache/
key: ${{ runner.os }}-build-${{ env.cache-name }}


- name: Build wheels on Linux
if: runner.os == 'Linux'
env:
Expand All @@ -60,7 +59,7 @@ jobs:
run: |
# used by setup.py to decide if to set `FindHDF5` to use static hdf5 libraries
export STATIC_HDF5=True
export CMAKE_PREFIX_PATH=/opt/hdf5-static/install-/install/
export CMAKE_PREFIX_PATH=/opt/hdf5-static/install-x86_64/install/

CIBW_MANYLINUX_X86_64_IMAGE=manylinux2014 python -m cibuildwheel --output-dir dist
CIBW_MANYLINUX_X86_64_IMAGE=manylinux_2_28 python -m cibuildwheel --output-dir dist
Expand Down
13 changes: 9 additions & 4 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,7 @@ jobs:
name: Run tests on macos
runs-on: macos-latest
env:
CIBW_ARCHS_MACOS: "x86_64"
CMAKE_OSX_ARCHITECTURES: "x86_64"
UNIXY_HDF5_VERSION: 1.14.3
MACOSX_DEPLOYMENT_TARGET: "11.0"

steps:
- name: Checkout repository
Expand All @@ -124,10 +121,18 @@ jobs:
ln -s $PWD/src-cache /Users/runner/work/src-cache
bash ci/hdf5-build.sh /Users/runner/work/src-cache

- name: Build and run unittests
- name: Build and run unittests C++ tests
run: |
: "${CIBW_ARCHS_MACOS:=$(uname -m)}"
export CMAKE_PREFIX_PATH=/Users/runner/work/src-cache/install-$CIBW_ARCHS_MACOS/install
export STATIC_HDF5=True

./ci/cpp_test.sh

- name: Build and run unittests python tests
run: |
: "${CIBW_ARCHS_MACOS:=$(uname -m)}"
export CMAKE_PREFIX_PATH=/Users/runner/work/src-cache/install-$CIBW_ARCHS_MACOS/install
export STATIC_HDF5=True

./ci/python_test.sh
3 changes: 2 additions & 1 deletion ci/hdf5-build.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#!/bin/bash
set -e -x

: "${UNIXY_HDF5_VERSION:=1.14.3}"
: "${CIBW_ARCHS_MACOS:=$(uname -m)}"

export INPUT=$(cd $(dirname "$1") && pwd -P)/$(basename "$1")
export OUTPUT="$INPUT/install-$CIBW_ARCHS_MACOS"

: "${UNIXY_HDF5_VERSION:=1.14.3}"

function download_unpack_hdf5 {
pushd "$INPUT"
Expand Down
7 changes: 6 additions & 1 deletion ci/python_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,13 @@ source $BIN/activate
set -u

$BIN/pip -v install --upgrade pip setuptools wheel

which python
which pip
pip debug

$BIN/pip -v install --force .

pushd python/tests
$BIN/python -m unittest -v
$BIN/python -m unittest -v
popd
25 changes: 24 additions & 1 deletion include/bbp/sonata/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -460,13 +460,17 @@ class SONATA_API SimulationConfig
double ampStart{};
/// The final current when a stimulus concludes (nA)
double ampEnd{};
/// Whether this input represents a physical electrode. Default is false
bool representsPhysicalElectrode = false;
mgeplf marked this conversation as resolved.
Show resolved Hide resolved
};

struct InputRelativeLinear: public InputBase {
/// The percentage of a cell's threshold current to inject
double percentStart{};
/// The percentage of a cell's threshold current to inject at the end
double percentEnd{};
/// Whether this input represents a physical electrode. Default is false
bool representsPhysicalElectrode = false;
};

struct InputPulse: public InputBase {
Expand All @@ -478,14 +482,21 @@ class SONATA_API SimulationConfig
double width{};
/// The frequency of pulse trains (Hz)
double frequency{};
/// Whether this input represents a physical electrode. Default is false
bool representsPhysicalElectrode = false;
};

struct InputSubthreshold: public InputBase {
/// A percentage adjusted from 100 of a cell's threshold current
double percentLess{};
/// Whether this input represents a physical electrode. Default is false
bool representsPhysicalElectrode = false;
};

struct InputHyperpolarizing: public InputBase {};
struct InputHyperpolarizing: public InputBase {
/// Whether this input represents a physical electrode. Default is false
bool representsPhysicalElectrode = false;
};

struct InputSynapseReplay: public InputBase {
/// The location of the file with the spike info for injection, file extension must be .h5
Expand All @@ -507,6 +518,8 @@ class SONATA_API SimulationConfig
/// State var to track whether the value of injected noise current is mean or
/// mean_percent
double variance{};
/// Whether this input represents a physical electrode. Default is false
bool representsPhysicalElectrode = false;
};

struct InputShotNoise: public InputBase {
Expand All @@ -527,6 +540,8 @@ class SONATA_API SimulationConfig
/// The variance of gamma-distributed amplitudes in nA^2 (current_clamp) or uS^2
/// (conductance)
double ampVar{};
/// Whether this input represents a physical electrode. Default is false
bool representsPhysicalElectrode = false;
};

struct InputRelativeShotNoise: public InputBase {
Expand All @@ -548,6 +563,8 @@ class SONATA_API SimulationConfig
/// signal std dev as percentage of a cell’s threshold current (current_clamp) or inverse
/// input resistance (conductance).
double sdPercent{};
/// Whether this input represents a physical electrode. Default is false
bool representsPhysicalElectrode = false;
};

struct InputAbsoluteShotNoise: public InputBase {
Expand All @@ -567,6 +584,8 @@ class SONATA_API SimulationConfig
double mean{};
/// signal std dev in nA (current_clamp) or uS (conductance).
double sigma{};
/// Whether this input represents a physical electrode. Default is false
bool representsPhysicalElectrode = false;
};

struct InputOrnsteinUhlenbeck: public InputBase {
Expand All @@ -582,6 +601,8 @@ class SONATA_API SimulationConfig
double mean{};
/// Signal std dev in nA (current_clamp) or uS (conductance)
double sigma{};
/// Whether this input represents a physical electrode. Default is false
bool representsPhysicalElectrode = false;
};

struct InputRelativeOrnsteinUhlenbeck: public InputBase {
Expand All @@ -599,6 +620,8 @@ class SONATA_API SimulationConfig
/// Signal std dev as percentage of a cell’s threshold current (current_clamp) or inverse
/// input resistance (conductance)
double sdPercent{};
/// Whether this input represents a physical electrode. Default is false
bool representsPhysicalElectrode = false;
};

using Input = nonstd::variant<InputLinear,
Expand Down
56 changes: 45 additions & 11 deletions python/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,10 @@ PYBIND11_MODULE(_libsonata, m) {
DOC_SIMULATIONCONFIG(InputLinear, ampStart))
.def_readonly("amp_end",
&SimulationConfig::InputLinear::ampEnd,
DOC_SIMULATIONCONFIG(InputLinear, ampEnd));
DOC_SIMULATIONCONFIG(InputLinear, ampEnd))
.def_readonly("represents_physical_electrode",
&SimulationConfig::InputLinear::representsPhysicalElectrode,
DOC_SIMULATIONCONFIG(InputLinear, representsPhysicalElectrode));

py::class_<SimulationConfig::InputRelativeLinear, SimulationConfig::InputBase>(simConf,
"RelativeLinear")
Expand All @@ -832,7 +835,10 @@ PYBIND11_MODULE(_libsonata, m) {
DOC_SIMULATIONCONFIG(InputRelativeLinear, percentStart))
.def_readonly("percent_end",
&SimulationConfig::InputRelativeLinear::percentEnd,
DOC_SIMULATIONCONFIG(InputRelativeLinear, percentEnd));
DOC_SIMULATIONCONFIG(InputRelativeLinear, percentEnd))
.def_readonly("represents_physical_electrode",
&SimulationConfig::InputRelativeLinear::representsPhysicalElectrode,
DOC_SIMULATIONCONFIG(InputRelativeLinear, representsPhysicalElectrode));

py::class_<SimulationConfig::InputPulse, SimulationConfig::InputBase>(simConf, "Pulse")
.def_readonly("amp_start",
Expand All @@ -846,16 +852,25 @@ PYBIND11_MODULE(_libsonata, m) {
DOC_SIMULATIONCONFIG(InputPulse, width))
.def_readonly("frequency",
&SimulationConfig::InputPulse::frequency,
DOC_SIMULATIONCONFIG(InputPulse, frequency));
DOC_SIMULATIONCONFIG(InputPulse, frequency))
.def_readonly("represents_physical_electrode",
&SimulationConfig::InputPulse::representsPhysicalElectrode,
DOC_SIMULATIONCONFIG(InputPulse, representsPhysicalElectrode));

py::class_<SimulationConfig::InputSubthreshold, SimulationConfig::InputBase>(simConf,
"Subthreshold")
.def_readonly("percent_less",
&SimulationConfig::InputSubthreshold::percentLess,
DOC_SIMULATIONCONFIG(InputSubthreshold, percentLess));
DOC_SIMULATIONCONFIG(InputSubthreshold, percentLess))
.def_readonly("represents_physical_electrode",
&SimulationConfig::InputSubthreshold::representsPhysicalElectrode,
DOC_SIMULATIONCONFIG(InputSubthreshold, representsPhysicalElectrode));

py::class_<SimulationConfig::InputHyperpolarizing, SimulationConfig::InputBase>(
simConf, "Hyperpolarizing");
simConf, "Hyperpolarizing")
.def_readonly("represents_physical_electrode",
&SimulationConfig::InputHyperpolarizing::representsPhysicalElectrode,
DOC_SIMULATIONCONFIG(InputHyperpolarizing, representsPhysicalElectrode));

py::class_<SimulationConfig::InputSynapseReplay, SimulationConfig::InputBase>(simConf,
"SynapseReplay")
Expand All @@ -880,7 +895,10 @@ PYBIND11_MODULE(_libsonata, m) {
DOC_SIMULATIONCONFIG(InputNoise, meanPercent))
.def_readonly("variance",
&SimulationConfig::InputNoise::variance,
DOC_SIMULATIONCONFIG(InputNoise, variance));
DOC_SIMULATIONCONFIG(InputNoise, variance))
.def_readonly("represents_physical_electrode",
&SimulationConfig::InputNoise::representsPhysicalElectrode,
DOC_SIMULATIONCONFIG(InputNoise, representsPhysicalElectrode));

py::class_<SimulationConfig::InputShotNoise, SimulationConfig::InputBase>(simConf, "ShotNoise")
.def_readonly("rise_time",
Expand All @@ -906,7 +924,10 @@ PYBIND11_MODULE(_libsonata, m) {
DOC_SIMULATIONCONFIG(InputShotNoise, ampMean))
.def_readonly("amp_var",
&SimulationConfig::InputShotNoise::ampVar,
DOC_SIMULATIONCONFIG(InputShotNoise, ampVar));
DOC_SIMULATIONCONFIG(InputShotNoise, ampVar))
.def_readonly("represents_physical_electrode",
&SimulationConfig::InputShotNoise::representsPhysicalElectrode,
DOC_SIMULATIONCONFIG(InputShotNoise, representsPhysicalElectrode));

py::class_<SimulationConfig::InputRelativeShotNoise, SimulationConfig::InputBase>(
simConf, "RelativeShotNoise")
Expand All @@ -933,7 +954,10 @@ PYBIND11_MODULE(_libsonata, m) {
DOC_SIMULATIONCONFIG(InputRelativeShotNoise, sdPercent))
.def_readonly("mean_percent",
&SimulationConfig::InputRelativeShotNoise::meanPercent,
DOC_SIMULATIONCONFIG(InputRelativeShotNoise, meanPercent));
DOC_SIMULATIONCONFIG(InputRelativeShotNoise, meanPercent))
.def_readonly("represents_physical_electrode",
&SimulationConfig::InputRelativeShotNoise::representsPhysicalElectrode,
DOC_SIMULATIONCONFIG(InputRelativeShotNoise, representsPhysicalElectrode));

py::class_<SimulationConfig::InputAbsoluteShotNoise, SimulationConfig::InputBase>(
simConf, "AbsoluteShotNoise")
Expand All @@ -960,7 +984,10 @@ PYBIND11_MODULE(_libsonata, m) {
DOC_SIMULATIONCONFIG(InputAbsoluteShotNoise, mean))
.def_readonly("sigma",
&SimulationConfig::InputAbsoluteShotNoise::sigma,
DOC_SIMULATIONCONFIG(InputAbsoluteShotNoise, sigma));
DOC_SIMULATIONCONFIG(InputAbsoluteShotNoise, sigma))
.def_readonly("represents_physical_electrode",
&SimulationConfig::InputAbsoluteShotNoise::representsPhysicalElectrode,
DOC_SIMULATIONCONFIG(InputAbsoluteShotNoise, representsPhysicalElectrode));

py::class_<SimulationConfig::InputOrnsteinUhlenbeck, SimulationConfig::InputBase>(
simConf, "OrnsteinUhlenbeck")
Expand All @@ -981,7 +1008,10 @@ PYBIND11_MODULE(_libsonata, m) {
DOC_SIMULATIONCONFIG(InputOrnsteinUhlenbeck, mean))
.def_readonly("sigma",
&SimulationConfig::InputOrnsteinUhlenbeck::sigma,
DOC_SIMULATIONCONFIG(InputOrnsteinUhlenbeck, sigma));
DOC_SIMULATIONCONFIG(InputOrnsteinUhlenbeck, sigma))
.def_readonly("represents_physical_electrode",
&SimulationConfig::InputOrnsteinUhlenbeck::representsPhysicalElectrode,
DOC_SIMULATIONCONFIG(InputOrnsteinUhlenbeck, representsPhysicalElectrode));

py::class_<SimulationConfig::InputRelativeOrnsteinUhlenbeck, SimulationConfig::InputBase>(
simConf, "RelativeOrnsteinUhlenbeck")
Expand All @@ -1002,7 +1032,11 @@ PYBIND11_MODULE(_libsonata, m) {
DOC_SIMULATIONCONFIG(InputRelativeOrnsteinUhlenbeck, meanPercent))
.def_readonly("sd_percent",
&SimulationConfig::InputRelativeOrnsteinUhlenbeck::sdPercent,
DOC_SIMULATIONCONFIG(InputRelativeOrnsteinUhlenbeck, sdPercent));
DOC_SIMULATIONCONFIG(InputRelativeOrnsteinUhlenbeck, sdPercent))
.def_readonly(
"represents_physical_electrode",
&SimulationConfig::InputRelativeOrnsteinUhlenbeck::representsPhysicalElectrode,
DOC_SIMULATIONCONFIG(InputRelativeOrnsteinUhlenbeck, representsPhysicalElectrode));

py::enum_<SimulationConfig::InputBase::Module>(inputBase, "Module")
.value("linear", SimulationConfig::InputBase::Module::linear)
Expand Down
Loading
Loading