From 1af2e662202671c97dd80ec6354858ffd12f33d6 Mon Sep 17 00:00:00 2001 From: ncguilbeault Date: Wed, 20 Nov 2024 11:06:55 +0000 Subject: [PATCH 1/8] Add scripts for bonsai linux environment --- .bonsai/Setup.sh | 41 ++++++++++++++++++++++++++++++++ .bonsai/activate | 15 ++++++++++++ .bonsai/deactivate | 8 +++++++ .bonsai/run | 58 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 122 insertions(+) create mode 100644 .bonsai/Setup.sh create mode 100644 .bonsai/activate create mode 100644 .bonsai/deactivate create mode 100644 .bonsai/run diff --git a/.bonsai/Setup.sh b/.bonsai/Setup.sh new file mode 100644 index 00000000..941d8505 --- /dev/null +++ b/.bonsai/Setup.sh @@ -0,0 +1,41 @@ +#! /bin/bash + +SETUP_SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd)" + +DEFAULT_VERSION="latest" +VERSION="$DEFAULT_VERSION" + +while [[ "$#" -gt 0 ]]; do + case $1 in + --version) VERSION="$2"; shift ;; + *) echo "Unknown parameter passed: $1"; exit 1 ;; + esac + shift +done + +echo "Setting up Bonsai v=$VERSION environment..." + +if [ ! -f "$SETUP_SCRIPT_DIR/Bonsai.exe" ]; then + CONFIG="$SETUP_SCRIPT_DIR/Bonsai.config" + if [ -f "$CONFIG" ]; then + DETECTED=$(xmllint --xpath '//PackageConfiguration/Packages/Package[@id="Bonsai"]/@version' "$CONFIG" | sed -e 's/^[^"]*"//' -e 's/"$//') + echo "Version detected v=$DETECTED." + RELEASE="https://github.com/bonsai-rx/bonsai/releases/download/$DETECTED/Bonsai.zip" + else + if [ $VERSION = "latest" ]; then + RELEASE="https://github.com/bonsai-rx/bonsai/releases/latest/download/Bonsai.zip" + else + RELEASE="https://github.com/bonsai-rx/bonsai/releases/download/$VERSION/Bonsai.zip" + fi + fi + echo "Download URL: $RELEASE" + wget $RELEASE -O "$SETUP_SCRIPT_DIR/temp.zip" + mv -f "$SETUP_SCRIPT_DIR/NuGet.config" "$SETUP_SCRIPT_DIR/temp.config" + unzip -d "$SETUP_SCRIPT_DIR" -o "$SETUP_SCRIPT_DIR/temp.zip" + mv -f "$SETUP_SCRIPT_DIR/temp.config" "$SETUP_SCRIPT_DIR/NuGet.config" + rm -rf "$SETUP_SCRIPT_DIR/temp.zip" + rm -rf "$SETUP_SCRIPT_DIR/Bonsai32.exe" +fi + +source "$SETUP_SCRIPT_DIR/activate" +source "$SETUP_SCRIPT_DIR/run" --no-editor diff --git a/.bonsai/activate b/.bonsai/activate new file mode 100644 index 00000000..ddf75f3b --- /dev/null +++ b/.bonsai/activate @@ -0,0 +1,15 @@ +#!/bin/bash +# activate.sh +if [[ -v BONSAI_EXE_PATH ]]; then + echo "Error! Cannot have multiple bonsai environments activated at the same time. Please deactivate the current environment before activating the new one." + return +fi +BONSAI_ENV_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd)" +export BONSAI_ENV_DIR +export BONSAI_EXE_PATH="$BONSAI_ENV_DIR/Bonsai.exe" +export ORIGINAL_PS1="$PS1" +export PS1="($(basename "$BONSAI_ENV_DIR")) $PS1" +alias bonsai='source "$BONSAI_ENV_DIR"/run' +alias bonsai-clean='GTK_DATA_PREFIX= source "$BONSAI_ENV_DIR"/run' +alias deactivate='source "$BONSAI_ENV_DIR"/deactivate' +echo "Activated bonsai environment in $BONSAI_ENV_DIR" \ No newline at end of file diff --git a/.bonsai/deactivate b/.bonsai/deactivate new file mode 100644 index 00000000..43233d92 --- /dev/null +++ b/.bonsai/deactivate @@ -0,0 +1,8 @@ +#!/bin/bash +unset BONSAI_EXE_PATH +export PS1="$ORIGINAL_PS1" +unset ORIGINAL_PS1 +unalias bonsai +unalias bonsai-clean +unalias deactivate +echo "Deactivated bonsai environment." \ No newline at end of file diff --git a/.bonsai/run b/.bonsai/run new file mode 100644 index 00000000..bffd6cff --- /dev/null +++ b/.bonsai/run @@ -0,0 +1,58 @@ +#!/bin/bash +# run.sh + +SETUP_SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd)" +CONFIG="$SETUP_SCRIPT_DIR/Bonsai.config" + +cleanup() { + update_paths_to_windows +} + +update_paths_to_linux() { + ASSEMBLYLOCATIONS=$(xmllint --xpath '//PackageConfiguration/AssemblyLocations/AssemblyLocation/@location' "$CONFIG" | sed -e 's/^[^"]*"//' -e 's/"$//') + for ASSEMBLYLOCATION in $ASSEMBLYLOCATIONS; do + NEWASSEMBLYLOCATION="${ASSEMBLYLOCATION//\\/\/}" + xmlstarlet edit --inplace --update "/PackageConfiguration/AssemblyLocations/AssemblyLocation[@location='$ASSEMBLYLOCATION']/@location" --value "$NEWASSEMBLYLOCATION" "$CONFIG" + done + + LIBRARYFOLDERS=$(xmllint --xpath '//PackageConfiguration/LibraryFolders/LibraryFolder/@path' "$CONFIG" | sed -e 's/^[^"]*"//' -e 's/"$//') + for LIBRARYFOLDER in $LIBRARYFOLDERS; do + NEWLIBRARYFOLDER="${LIBRARYFOLDER//\\/\/}" + xmlstarlet edit --inplace --update "//PackageConfiguration/LibraryFolders/LibraryFolder[@path='$LIBRARYFOLDER']/@path" --value "$NEWLIBRARYFOLDER" "$CONFIG" + done +} + +update_paths_to_windows() { + ASSEMBLYLOCATIONS=$(xmllint --xpath '//PackageConfiguration/AssemblyLocations/AssemblyLocation/@location' "$CONFIG" | sed -e 's/^[^"]*"//' -e 's/"$//') + for ASSEMBLYLOCATION in $ASSEMBLYLOCATIONS; do + NEWASSEMBLYLOCATION="${ASSEMBLYLOCATION//\//\\}" + xmlstarlet edit --inplace --update "/PackageConfiguration/AssemblyLocations/AssemblyLocation[@location='$ASSEMBLYLOCATION']/@location" --value "$NEWASSEMBLYLOCATION" "$CONFIG" + done + + LIBRARYFOLDERS=$(xmllint --xpath '//PackageConfiguration/LibraryFolders/LibraryFolder/@path' "$CONFIG" | sed -e 's/^[^"]*"//' -e 's/"$//') + for LIBRARYFOLDER in $LIBRARYFOLDERS; do + NEWLIBRARYFOLDER="${LIBRARYFOLDER//\//\\}" + xmlstarlet edit --inplace --update "//PackageConfiguration/LibraryFolders/LibraryFolder[@path='$LIBRARYFOLDER']/@path" --value "$NEWLIBRARYFOLDER" "$CONFIG" + done +} + +if [[ -v BONSAI_EXE_PATH ]]; then + if [ ! -f "$BONSAI_EXE_PATH" ]; then + bash "$BONSAI_ENV_DIR"/Setup.sh + bash "$BONSAI_ENV_DIR"/run "$@" + else + BONSAI_VERSION=$(xmllint --xpath "//PackageConfiguration/Packages/Package[@id='Bonsai']/@version" "$CONFIG" | sed -e 's/^[^"]*"//' -e 's/"$//') + if [[ -z ${BONSAI_VERSION+x} ]] && [ "$BONSAI_VERSION" \< "2.8.4" ]; then + echo "Updating paths to Linux format..." + trap cleanup EXIT INT TERM + update_paths_to_linux + mono "$BONSAI_EXE_PATH" "$@" + cleanup + else + mono "$BONSAI_EXE_PATH" "$@" + fi + fi +else + echo "BONSAI_EXE_PATH is not set. Please set the path to the Bonsai executable." + return +fi \ No newline at end of file From c5e73e58c782e07bb9885e1a10793f5afd72b50d Mon Sep 17 00:00:00 2001 From: ncguilbeault Date: Wed, 20 Nov 2024 11:30:29 +0000 Subject: [PATCH 2/8] Added description to the include workflow and description to the Name property --- src/Bonsai.ML.HiddenMarkovModels/CheckFitFinished.bonsai | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Bonsai.ML.HiddenMarkovModels/CheckFitFinished.bonsai b/src/Bonsai.ML.HiddenMarkovModels/CheckFitFinished.bonsai index caef8d29..3c87281f 100644 --- a/src/Bonsai.ML.HiddenMarkovModels/CheckFitFinished.bonsai +++ b/src/Bonsai.ML.HiddenMarkovModels/CheckFitFinished.bonsai @@ -6,13 +6,14 @@ xmlns:p1="clr-namespace:Bonsai.ML;assembly=Bonsai.ML" xmlns:scr="clr-namespace:Bonsai.Scripting.Expressions;assembly=Bonsai.Scripting.Expressions" xmlns="https://bonsai-rx.org/2018/workflow"> + Periodically evaluates the `get_fit_finished` function of the HMM. Returns a boolean value representing the objects `fit_finished` attribute. This should onle be used in a state after the `RunFitAsync` function has already been started. Source1 - + From 77458edc8966c1acb1e71b0b08a66b31959f6548 Mon Sep 17 00:00:00 2001 From: ncguilbeault Date: Wed, 20 Nov 2024 11:43:50 +0000 Subject: [PATCH 3/8] Added descriptions to include workflows and properties --- src/Bonsai.ML.HiddenMarkovModels/CreateHMM.bonsai | 13 +++++++------ .../GetGaussianObservationsStatistics.bonsai | 3 ++- .../InferState.bonsai | 3 ++- .../LoadHMMModule.bonsai | 1 + .../RunFitAsync.bonsai | 15 ++++++++------- 5 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/Bonsai.ML.HiddenMarkovModels/CreateHMM.bonsai b/src/Bonsai.ML.HiddenMarkovModels/CreateHMM.bonsai index 83cce5b3..7205de19 100644 --- a/src/Bonsai.ML.HiddenMarkovModels/CreateHMM.bonsai +++ b/src/Bonsai.ML.HiddenMarkovModels/CreateHMM.bonsai @@ -6,10 +6,11 @@ xmlns:p2="clr-namespace:Bonsai.ML.HiddenMarkovModels;assembly=Bonsai.ML.HiddenMarkovModels" xmlns:py="clr-namespace:Bonsai.Scripting.Python;assembly=Bonsai.Scripting.Python" xmlns="https://bonsai-rx.org/2018/workflow"> + Creates a new HMM python object inside of the HMM module and assigns it to a named python variable. - + @@ -26,11 +27,11 @@ Source1 - - - - - + + + + + diff --git a/src/Bonsai.ML.HiddenMarkovModels/GetGaussianObservationsStatistics.bonsai b/src/Bonsai.ML.HiddenMarkovModels/GetGaussianObservationsStatistics.bonsai index 5dc43d91..d58d30fe 100644 --- a/src/Bonsai.ML.HiddenMarkovModels/GetGaussianObservationsStatistics.bonsai +++ b/src/Bonsai.ML.HiddenMarkovModels/GetGaussianObservationsStatistics.bonsai @@ -6,6 +6,7 @@ xmlns:rx="clr-namespace:Bonsai.Reactive;assembly=Bonsai.Core" xmlns:p2="clr-namespace:Bonsai.ML.HiddenMarkovModels.Observations;assembly=Bonsai.ML.HiddenMarkovModels" xmlns="https://bonsai-rx.org/2018/workflow"> + Computes the statistics of the Gaussian observations in the HMM model. Only works for models with Gaussian observations. @@ -16,7 +17,7 @@ - + hmm diff --git a/src/Bonsai.ML.HiddenMarkovModels/InferState.bonsai b/src/Bonsai.ML.HiddenMarkovModels/InferState.bonsai index 3cad8001..b9b5ce7b 100644 --- a/src/Bonsai.ML.HiddenMarkovModels/InferState.bonsai +++ b/src/Bonsai.ML.HiddenMarkovModels/InferState.bonsai @@ -6,6 +6,7 @@ xmlns:rx="clr-namespace:Bonsai.Reactive;assembly=Bonsai.Core" xmlns:p2="clr-namespace:Bonsai.ML.HiddenMarkovModels;assembly=Bonsai.ML.HiddenMarkovModels" xmlns="https://bonsai-rx.org/2018/workflow"> + Infers the state of the HMM model given the observations. @@ -15,7 +16,7 @@ - + hmm diff --git a/src/Bonsai.ML.HiddenMarkovModels/LoadHMMModule.bonsai b/src/Bonsai.ML.HiddenMarkovModels/LoadHMMModule.bonsai index 632b53bc..a7ca4baa 100644 --- a/src/Bonsai.ML.HiddenMarkovModels/LoadHMMModule.bonsai +++ b/src/Bonsai.ML.HiddenMarkovModels/LoadHMMModule.bonsai @@ -4,6 +4,7 @@ xmlns:rx="clr-namespace:Bonsai.Reactive;assembly=Bonsai.Core" xmlns:py="clr-namespace:Bonsai.Scripting.Python;assembly=Bonsai.Scripting.Python" xmlns="https://bonsai-rx.org/2018/workflow"> + Loads the HMM module into the workflow. diff --git a/src/Bonsai.ML.HiddenMarkovModels/RunFitAsync.bonsai b/src/Bonsai.ML.HiddenMarkovModels/RunFitAsync.bonsai index 8087ea1a..a99e5fe3 100644 --- a/src/Bonsai.ML.HiddenMarkovModels/RunFitAsync.bonsai +++ b/src/Bonsai.ML.HiddenMarkovModels/RunFitAsync.bonsai @@ -6,13 +6,14 @@ xmlns:p1="clr-namespace:Bonsai.ML;assembly=Bonsai.ML" xmlns:scr="clr-namespace:Bonsai.Scripting.Expressions;assembly=Bonsai.Scripting.Expressions" xmlns="https://bonsai-rx.org/2018/workflow"> + Runs the asynchronous fit loop of the HMM model. Source1 - + @@ -47,7 +48,7 @@ - + hmm @@ -64,7 +65,7 @@ - + @@ -72,7 +73,7 @@ - + @@ -80,7 +81,7 @@ - + @@ -88,7 +89,7 @@ - + @@ -96,7 +97,7 @@ - + From 896da8fb6ad917bd0efd486cfaf8582b6b84a734 Mon Sep 17 00:00:00 2001 From: ncguilbeault Date: Wed, 20 Nov 2024 11:44:07 +0000 Subject: [PATCH 4/8] Added periods to the end of descriptions. --- src/Bonsai.ML.HiddenMarkovModels/ModelParameters.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Bonsai.ML.HiddenMarkovModels/ModelParameters.cs b/src/Bonsai.ML.HiddenMarkovModels/ModelParameters.cs index e2a446ec..a661c314 100644 --- a/src/Bonsai.ML.HiddenMarkovModels/ModelParameters.cs +++ b/src/Bonsai.ML.HiddenMarkovModels/ModelParameters.cs @@ -31,7 +31,7 @@ public class ModelParameters : PythonStringBuilder /// /// The number of states of the HMM model. /// - [Description("The number of discrete latent states of the HMM model")] + [Description("The number of discrete latent states of the HMM model.")] [Category("ModelSpecification")] public int NumStates { @@ -46,7 +46,7 @@ public int NumStates /// /// The dimensionality of the observations into the HMM model. /// - [Description("The dimensionality of the observations into the HMM model")] + [Description("The dimensionality of the observations into the HMM model.")] [Category("ModelSpecification")] public int Dimensions { From 547f406f9c9a7b4be1591e8712d9fce8adc84f98 Mon Sep 17 00:00:00 2001 From: ncguilbeault Date: Wed, 20 Nov 2024 13:44:53 +0000 Subject: [PATCH 5/8] Added descriptions to workflows and properties --- .../CheckFitFinished.bonsai | 4 +-- .../CreateHMM.bonsai | 14 +++++------ .../GetGaussianObservationsStatistics.bonsai | 4 +-- .../InferState.bonsai | 4 +-- .../ModelParameters.cs | 8 +++--- .../RunFitAsync.bonsai | 8 +++--- .../Kinematics/CreateKFModel.bonsai | 25 ++++++++++--------- .../Kinematics/CreateObservation2D.bonsai | 1 + .../Kinematics/PerformForecasting.bonsai | 5 ++-- .../Kinematics/PerformInference.bonsai | 3 ++- .../Learning/CheckOptimizationFinished.bonsai | 3 ++- .../Learning/RunOptimizationAsync.bonsai | 15 +++++------ .../LinearRegression/CreateKFModel.bonsai | 13 +++++----- .../CreateMultivariatePDF.bonsai | 15 +++++------ .../LinearRegression/PerformInference.bonsai | 3 ++- .../LoadLDSModule.bonsai | 1 + 16 files changed, 68 insertions(+), 58 deletions(-) diff --git a/src/Bonsai.ML.HiddenMarkovModels/CheckFitFinished.bonsai b/src/Bonsai.ML.HiddenMarkovModels/CheckFitFinished.bonsai index 3c87281f..efac3a88 100644 --- a/src/Bonsai.ML.HiddenMarkovModels/CheckFitFinished.bonsai +++ b/src/Bonsai.ML.HiddenMarkovModels/CheckFitFinished.bonsai @@ -6,14 +6,14 @@ xmlns:p1="clr-namespace:Bonsai.ML;assembly=Bonsai.ML" xmlns:scr="clr-namespace:Bonsai.Scripting.Expressions;assembly=Bonsai.Scripting.Expressions" xmlns="https://bonsai-rx.org/2018/workflow"> - Periodically evaluates the `get_fit_finished` function of the HMM. Returns a boolean value representing the objects `fit_finished` attribute. This should onle be used in a state after the `RunFitAsync` function has already been started. + Periodically evaluates the `get_fit_finished` function of the HMM. Returns whether the `fit_finished` attribute is true. This should only be used after the `RunFitAsync` function has already been started. Source1 - + diff --git a/src/Bonsai.ML.HiddenMarkovModels/CreateHMM.bonsai b/src/Bonsai.ML.HiddenMarkovModels/CreateHMM.bonsai index 7205de19..a48c4b64 100644 --- a/src/Bonsai.ML.HiddenMarkovModels/CreateHMM.bonsai +++ b/src/Bonsai.ML.HiddenMarkovModels/CreateHMM.bonsai @@ -6,11 +6,11 @@ xmlns:p2="clr-namespace:Bonsai.ML.HiddenMarkovModels;assembly=Bonsai.ML.HiddenMarkovModels" xmlns:py="clr-namespace:Bonsai.Scripting.Python;assembly=Bonsai.Scripting.Python" xmlns="https://bonsai-rx.org/2018/workflow"> - Creates a new HMM python object inside of the HMM module and assigns it to a named python variable. + Creates a new HMM Python object inside of the HMM module and assigns it to a named Python variable. - + @@ -27,11 +27,11 @@ Source1 - - - - - + + + + + diff --git a/src/Bonsai.ML.HiddenMarkovModels/GetGaussianObservationsStatistics.bonsai b/src/Bonsai.ML.HiddenMarkovModels/GetGaussianObservationsStatistics.bonsai index d58d30fe..b31e6c70 100644 --- a/src/Bonsai.ML.HiddenMarkovModels/GetGaussianObservationsStatistics.bonsai +++ b/src/Bonsai.ML.HiddenMarkovModels/GetGaussianObservationsStatistics.bonsai @@ -6,7 +6,7 @@ xmlns:rx="clr-namespace:Bonsai.Reactive;assembly=Bonsai.Core" xmlns:p2="clr-namespace:Bonsai.ML.HiddenMarkovModels.Observations;assembly=Bonsai.ML.HiddenMarkovModels" xmlns="https://bonsai-rx.org/2018/workflow"> - Computes the statistics of the Gaussian observations in the HMM model. Only works for models with Gaussian observations. + Computes the statistics of the Gaussian observations in the HMM. Only works for models with Gaussian observations. @@ -17,7 +17,7 @@ - + hmm diff --git a/src/Bonsai.ML.HiddenMarkovModels/InferState.bonsai b/src/Bonsai.ML.HiddenMarkovModels/InferState.bonsai index b9b5ce7b..f59363ff 100644 --- a/src/Bonsai.ML.HiddenMarkovModels/InferState.bonsai +++ b/src/Bonsai.ML.HiddenMarkovModels/InferState.bonsai @@ -6,7 +6,7 @@ xmlns:rx="clr-namespace:Bonsai.Reactive;assembly=Bonsai.Core" xmlns:p2="clr-namespace:Bonsai.ML.HiddenMarkovModels;assembly=Bonsai.ML.HiddenMarkovModels" xmlns="https://bonsai-rx.org/2018/workflow"> - Infers the state of the HMM model given the observations. + Infers the state of the HMM given the observations. @@ -16,7 +16,7 @@ - + hmm diff --git a/src/Bonsai.ML.HiddenMarkovModels/ModelParameters.cs b/src/Bonsai.ML.HiddenMarkovModels/ModelParameters.cs index a661c314..dc0a7f54 100644 --- a/src/Bonsai.ML.HiddenMarkovModels/ModelParameters.cs +++ b/src/Bonsai.ML.HiddenMarkovModels/ModelParameters.cs @@ -29,9 +29,9 @@ public class ModelParameters : PythonStringBuilder private StateParameters stateParameters = null; /// - /// The number of states of the HMM model. + /// The number of discrete latent states in the HMM model. /// - [Description("The number of discrete latent states of the HMM model.")] + [Description("The number of discrete latent states in the HMM.")] [Category("ModelSpecification")] public int NumStates { @@ -44,9 +44,9 @@ public int NumStates } /// - /// The dimensionality of the observations into the HMM model. + /// The dimensionality of the observations going into the HMM. /// - [Description("The dimensionality of the observations into the HMM model.")] + [Description("The dimensionality of the observations going into the HMM.")] [Category("ModelSpecification")] public int Dimensions { diff --git a/src/Bonsai.ML.HiddenMarkovModels/RunFitAsync.bonsai b/src/Bonsai.ML.HiddenMarkovModels/RunFitAsync.bonsai index a99e5fe3..9dbbd314 100644 --- a/src/Bonsai.ML.HiddenMarkovModels/RunFitAsync.bonsai +++ b/src/Bonsai.ML.HiddenMarkovModels/RunFitAsync.bonsai @@ -6,14 +6,14 @@ xmlns:p1="clr-namespace:Bonsai.ML;assembly=Bonsai.ML" xmlns:scr="clr-namespace:Bonsai.Scripting.Expressions;assembly=Bonsai.Scripting.Expressions" xmlns="https://bonsai-rx.org/2018/workflow"> - Runs the asynchronous fit loop of the HMM model. + Runs the asynchronous fit loop of the HMM. Source1 - + @@ -48,7 +48,7 @@ - + hmm @@ -65,7 +65,7 @@ - + diff --git a/src/Bonsai.ML.LinearDynamicalSystems/Kinematics/CreateKFModel.bonsai b/src/Bonsai.ML.LinearDynamicalSystems/Kinematics/CreateKFModel.bonsai index 863927ef..5fd72098 100644 --- a/src/Bonsai.ML.LinearDynamicalSystems/Kinematics/CreateKFModel.bonsai +++ b/src/Bonsai.ML.LinearDynamicalSystems/Kinematics/CreateKFModel.bonsai @@ -6,10 +6,11 @@ xmlns:p2="clr-namespace:Bonsai.ML.LinearDynamicalSystems.Kinematics;assembly=Bonsai.ML.LinearDynamicalSystems" xmlns:py="clr-namespace:Bonsai.Scripting.Python;assembly=Bonsai.Scripting.Python" xmlns="https://bonsai-rx.org/2018/workflow"> + Creates a Kalman filter model for kinematics estimation based on the discrete Weiner process acceleration model. - + @@ -24,17 +25,17 @@ Source1 - - - - - - - - - - - + + + + + + + + + + + diff --git a/src/Bonsai.ML.LinearDynamicalSystems/Kinematics/CreateObservation2D.bonsai b/src/Bonsai.ML.LinearDynamicalSystems/Kinematics/CreateObservation2D.bonsai index dba139c6..86dbeb1e 100644 --- a/src/Bonsai.ML.LinearDynamicalSystems/Kinematics/CreateObservation2D.bonsai +++ b/src/Bonsai.ML.LinearDynamicalSystems/Kinematics/CreateObservation2D.bonsai @@ -3,6 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p1="clr-namespace:Bonsai.ML.LinearDynamicalSystems.Kinematics;assembly=Bonsai.ML.LinearDynamicalSystems" xmlns="https://bonsai-rx.org/2018/workflow"> + Creates a 2 dimensional object with the properties X and Y from the input. diff --git a/src/Bonsai.ML.LinearDynamicalSystems/Kinematics/PerformForecasting.bonsai b/src/Bonsai.ML.LinearDynamicalSystems/Kinematics/PerformForecasting.bonsai index d20e379e..8392736a 100644 --- a/src/Bonsai.ML.LinearDynamicalSystems/Kinematics/PerformForecasting.bonsai +++ b/src/Bonsai.ML.LinearDynamicalSystems/Kinematics/PerformForecasting.bonsai @@ -6,6 +6,7 @@ xmlns:rx="clr-namespace:Bonsai.Reactive;assembly=Bonsai.Core" xmlns:p2="clr-namespace:Bonsai.ML.LinearDynamicalSystems.Kinematics;assembly=Bonsai.ML.LinearDynamicalSystems" xmlns="https://bonsai-rx.org/2018/workflow"> + Performs forecasting on the LDS kinematics model. @@ -15,7 +16,7 @@ - + model @@ -24,7 +25,7 @@ Name - + diff --git a/src/Bonsai.ML.LinearDynamicalSystems/Kinematics/PerformInference.bonsai b/src/Bonsai.ML.LinearDynamicalSystems/Kinematics/PerformInference.bonsai index 56d7c108..128fbe8d 100644 --- a/src/Bonsai.ML.LinearDynamicalSystems/Kinematics/PerformInference.bonsai +++ b/src/Bonsai.ML.LinearDynamicalSystems/Kinematics/PerformInference.bonsai @@ -7,6 +7,7 @@ xmlns:p2="clr-namespace:Bonsai.ML.LinearDynamicalSystems;assembly=Bonsai.ML.LinearDynamicalSystems" xmlns:p3="clr-namespace:Bonsai.ML.LinearDynamicalSystems.Kinematics;assembly=Bonsai.ML.LinearDynamicalSystems" xmlns="https://bonsai-rx.org/2018/workflow"> + Performs inference on the LDS kinematics model. @@ -16,7 +17,7 @@ - + model diff --git a/src/Bonsai.ML.LinearDynamicalSystems/Learning/CheckOptimizationFinished.bonsai b/src/Bonsai.ML.LinearDynamicalSystems/Learning/CheckOptimizationFinished.bonsai index 4dc4a4aa..3f9d82ef 100644 --- a/src/Bonsai.ML.LinearDynamicalSystems/Learning/CheckOptimizationFinished.bonsai +++ b/src/Bonsai.ML.LinearDynamicalSystems/Learning/CheckOptimizationFinished.bonsai @@ -6,6 +6,7 @@ xmlns:rx="clr-namespace:Bonsai.Reactive;assembly=Bonsai.Core" xmlns:scr="clr-namespace:Bonsai.Scripting.Expressions;assembly=Bonsai.Scripting.Expressions" xmlns="https://bonsai-rx.org/2018/workflow"> + Periodically evaluates the `get_optimization_finished` function of the LDS model. Returns whether the `optimization_finished` attribute is true. This should only be used after the `RunOptimizationAsync` function has already been started. @@ -15,7 +16,7 @@ - + model diff --git a/src/Bonsai.ML.LinearDynamicalSystems/Learning/RunOptimizationAsync.bonsai b/src/Bonsai.ML.LinearDynamicalSystems/Learning/RunOptimizationAsync.bonsai index 8f17f17e..7dd9bd36 100644 --- a/src/Bonsai.ML.LinearDynamicalSystems/Learning/RunOptimizationAsync.bonsai +++ b/src/Bonsai.ML.LinearDynamicalSystems/Learning/RunOptimizationAsync.bonsai @@ -6,13 +6,14 @@ xmlns:p1="clr-namespace:Bonsai.ML;assembly=Bonsai.ML" xmlns:scr="clr-namespace:Bonsai.Scripting.Expressions;assembly=Bonsai.Scripting.Expressions" xmlns="https://bonsai-rx.org/2018/workflow"> + Runs the asynchronous optimization loop of the LDS model. Source1 - + @@ -47,7 +48,7 @@ - + model @@ -59,7 +60,7 @@ - + @@ -75,7 +76,7 @@ - + @@ -83,7 +84,7 @@ - + @@ -96,7 +97,7 @@ - + @@ -104,7 +105,7 @@ - + diff --git a/src/Bonsai.ML.LinearDynamicalSystems/LinearRegression/CreateKFModel.bonsai b/src/Bonsai.ML.LinearDynamicalSystems/LinearRegression/CreateKFModel.bonsai index 5c476c65..3672c014 100644 --- a/src/Bonsai.ML.LinearDynamicalSystems/LinearRegression/CreateKFModel.bonsai +++ b/src/Bonsai.ML.LinearDynamicalSystems/LinearRegression/CreateKFModel.bonsai @@ -6,19 +6,20 @@ xmlns:rx="clr-namespace:Bonsai.Reactive;assembly=Bonsai.Core" xmlns:py="clr-namespace:Bonsai.Scripting.Python;assembly=Bonsai.Scripting.Python" xmlns="https://bonsai-rx.org/2018/workflow"> + Creates a Kalman Filter model for linear regression. Source1 - - - + + + - - + + @@ -28,7 +29,7 @@ - + diff --git a/src/Bonsai.ML.LinearDynamicalSystems/LinearRegression/CreateMultivariatePDF.bonsai b/src/Bonsai.ML.LinearDynamicalSystems/LinearRegression/CreateMultivariatePDF.bonsai index 41e2ad52..e7d5efc1 100644 --- a/src/Bonsai.ML.LinearDynamicalSystems/LinearRegression/CreateMultivariatePDF.bonsai +++ b/src/Bonsai.ML.LinearDynamicalSystems/LinearRegression/CreateMultivariatePDF.bonsai @@ -6,6 +6,7 @@ xmlns:rx="clr-namespace:Bonsai.Reactive;assembly=Bonsai.Core" xmlns:p2="clr-namespace:Bonsai.ML.LinearDynamicalSystems.LinearRegression;assembly=Bonsai.ML.LinearDynamicalSystems" xmlns="https://bonsai-rx.org/2018/workflow"> + Creates a multivariate PDF object for the LDS model. @@ -15,7 +16,7 @@ - + model @@ -30,12 +31,12 @@ Item2 - - - - - - + + + + + + diff --git a/src/Bonsai.ML.LinearDynamicalSystems/LinearRegression/PerformInference.bonsai b/src/Bonsai.ML.LinearDynamicalSystems/LinearRegression/PerformInference.bonsai index e3fa230b..dc81a12d 100644 --- a/src/Bonsai.ML.LinearDynamicalSystems/LinearRegression/PerformInference.bonsai +++ b/src/Bonsai.ML.LinearDynamicalSystems/LinearRegression/PerformInference.bonsai @@ -6,6 +6,7 @@ xmlns:rx="clr-namespace:Bonsai.Reactive;assembly=Bonsai.Core" xmlns:p2="clr-namespace:Bonsai.ML.LinearDynamicalSystems;assembly=Bonsai.ML.LinearDynamicalSystems" xmlns="https://bonsai-rx.org/2018/workflow"> + Performs inference using the LDS linear regression model. @@ -15,7 +16,7 @@ - + model diff --git a/src/Bonsai.ML.LinearDynamicalSystems/LoadLDSModule.bonsai b/src/Bonsai.ML.LinearDynamicalSystems/LoadLDSModule.bonsai index 955ff023..64b5f7c7 100644 --- a/src/Bonsai.ML.LinearDynamicalSystems/LoadLDSModule.bonsai +++ b/src/Bonsai.ML.LinearDynamicalSystems/LoadLDSModule.bonsai @@ -4,6 +4,7 @@ xmlns:rx="clr-namespace:Bonsai.Reactive;assembly=Bonsai.Core" xmlns:py="clr-namespace:Bonsai.Scripting.Python;assembly=Bonsai.Scripting.Python" xmlns="https://bonsai-rx.org/2018/workflow"> + Loads the LDS module into the workflow. From 3a1630b0fb1d7b0b403390532d23f27ec9936b4d Mon Sep 17 00:00:00 2001 From: ncguilbeault Date: Wed, 20 Nov 2024 13:49:49 +0000 Subject: [PATCH 6/8] Improved documentation strings --- .../Kinematics/KFModelParameters.cs | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/Bonsai.ML.LinearDynamicalSystems/Kinematics/KFModelParameters.cs b/src/Bonsai.ML.LinearDynamicalSystems/Kinematics/KFModelParameters.cs index 32a80d31..e363f345 100644 --- a/src/Bonsai.ML.LinearDynamicalSystems/Kinematics/KFModelParameters.cs +++ b/src/Bonsai.ML.LinearDynamicalSystems/Kinematics/KFModelParameters.cs @@ -51,10 +51,10 @@ public class KFModelParameters private string fpsString; /// - /// x position at time 0 + /// The initial x position. /// [JsonProperty("pos_x0")] - [Description("x position at time 0")] + [Description("The initial x position.")] public double Pos_x0 { get @@ -69,10 +69,10 @@ public double Pos_x0 } /// - /// y position at time 0 + /// The initial y position. /// [JsonProperty("pos_y0")] - [Description("y position at time 0")] + [Description("The initial y position.")] public double Pos_y0 { get @@ -87,10 +87,10 @@ public double Pos_y0 } /// - /// x velocity at time 0 + /// The initial x velocity. /// [JsonProperty("vel_x0")] - [Description("x velocity at time 0")] + [Description("The initial x velocity.")] public double Vel_x0 { get @@ -105,10 +105,10 @@ public double Vel_x0 } /// - /// y velocity at time 0 + /// The initial y velocity. /// [JsonProperty("vel_y0")] - [Description("y velocity at time 0")] + [Description("The initial y velocity.")] public double Vel_y0 { get @@ -123,10 +123,10 @@ public double Vel_y0 } /// - /// x acceleration at time 0 + /// The initial x acceleration. /// [JsonProperty("acc_x0")] - [Description("x acceleration at time 0")] + [Description("The initial x acceleration.")] public double Acc_x0 { get @@ -141,10 +141,10 @@ public double Acc_x0 } /// - /// x velocity at time 0 + /// The initial y acceleration. /// [JsonProperty("acc_y0")] - [Description("x velocity at time 0")] + [Description("The initial y acceleration.")] public double Acc_y0 { get @@ -159,10 +159,10 @@ public double Acc_y0 } /// - /// covariance of a + /// A scalar value representing the measurement noise. /// [JsonProperty("sigma_a")] - [Description("covariance of a")] + [Description("A scalar value representing the measurement noise.")] public double Sigma_a { get @@ -177,10 +177,10 @@ public double Sigma_a } /// - /// covariance of x + /// A scalar value representing the prediction noise along the x axis. /// [JsonProperty("sigma_x")] - [Description("covariance of x")] + [Description("A scalar value representing the prediction noise along the x axis.")] public double Sigma_x { get @@ -195,10 +195,10 @@ public double Sigma_x } /// - /// covariance of y + /// A scalar value representing the prediction noise along the y axis. /// [JsonProperty("sigma_y")] - [Description("covariance of y")] + [Description("A scalar value representing the prediction noise along the y axis.")] public double Sigma_y { get @@ -213,10 +213,10 @@ public double Sigma_y } /// - /// v0 + /// The initial value of the diagonal of the state covariance matrix. /// [JsonProperty("sqrt_diag_V0_value")] - [Description("v0")] + [Description("The initial value of the diagonal of the state covariance matrix.")] public double Sqrt_diag_V0_value { get @@ -231,10 +231,10 @@ public double Sqrt_diag_V0_value } /// - /// frames per second + /// The frames per second of the observations. /// [JsonProperty("fps")] - [Description("frames per second")] + [Description("The frames per second of the observations.")] public int Fps { get From 5266131a52e08aa6b244703aad8b8898f0869e22 Mon Sep 17 00:00:00 2001 From: ncguilbeault Date: Wed, 20 Nov 2024 13:50:03 +0000 Subject: [PATCH 7/8] Removed unused parameters --- .../LinearRegression/GridParameters.cs | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/Bonsai.ML.LinearDynamicalSystems/LinearRegression/GridParameters.cs b/src/Bonsai.ML.LinearDynamicalSystems/LinearRegression/GridParameters.cs index 1cf1e9db..4793120a 100644 --- a/src/Bonsai.ML.LinearDynamicalSystems/LinearRegression/GridParameters.cs +++ b/src/Bonsai.ML.LinearDynamicalSystems/LinearRegression/GridParameters.cs @@ -25,14 +25,6 @@ public class GridParameters private double _y1 = 1; private int _ysteps = 100; - private string _x0String; - private string _x1String; - private string _xstepsString; - - private string _y0String; - private string _y1String; - private string _ystepsString; - /// /// Gets or sets the lower bound of the X axis. /// @@ -47,8 +39,6 @@ public double X0 set { _x0 = value; - _x0String = double.IsNaN(_x0) ? "None" : _x0.ToString(); - } } @@ -66,7 +56,6 @@ public double X1 set { _x1 = value; - _x1String = double.IsNaN(_x1) ? "None" : _x1.ToString(); } } @@ -84,7 +73,6 @@ public int XSteps set { _xsteps = value >= 0 ? value : _xsteps; - _xstepsString = _xsteps.ToString(); } } @@ -102,7 +90,6 @@ public double Y0 set { _y0 = value; - _y0String = double.IsNaN(_y0) ? "None" : _y0.ToString(); } } @@ -120,7 +107,6 @@ public double Y1 set { _y1 = value; - _y1String = double.IsNaN(_y1) ? "None" : _y1.ToString(); } } @@ -138,7 +124,6 @@ public int YSteps set { _ysteps = value; - _ystepsString = _ysteps.ToString(); } } From 40d7133e70c6607e79af5b5e210be21a82a59da8 Mon Sep 17 00:00:00 2001 From: ncguilbeault Date: Fri, 7 Mar 2025 13:07:07 +0000 Subject: [PATCH 8/8] Updated variable naming to Python instead of python in node --- .../Learning/CheckOptimizationFinished.bonsai | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bonsai.ML.LinearDynamicalSystems/Learning/CheckOptimizationFinished.bonsai b/src/Bonsai.ML.LinearDynamicalSystems/Learning/CheckOptimizationFinished.bonsai index 3f9d82ef..68601a76 100644 --- a/src/Bonsai.ML.LinearDynamicalSystems/Learning/CheckOptimizationFinished.bonsai +++ b/src/Bonsai.ML.LinearDynamicalSystems/Learning/CheckOptimizationFinished.bonsai @@ -16,7 +16,7 @@ - + model