Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
4ef34c9
Added bonsai environment
ncguilbeault Nov 4, 2024
dd06f6d
Added decoder python library
ncguilbeault Nov 4, 2024
32491db
Added workflow with extensions
ncguilbeault Nov 4, 2024
034fd52
Added README
ncguilbeault Nov 5, 2024
3d01197
Added clusterless spike decoder model
ncguilbeault Nov 5, 2024
99e1bfe
Changed name to sorted spikes
ncguilbeault Nov 5, 2024
501a622
Added clusterless spikes bonsai workflow
ncguilbeault Nov 5, 2024
dcd18b5
Updated data iterator to handle outputting position bins
ncguilbeault Nov 5, 2024
02f8cc0
Changed name of core to decoder
ncguilbeault Nov 6, 2024
8ad156c
Added likelihood module
ncguilbeault Nov 6, 2024
4d5d5e0
Updated model loader to use decoder module
ncguilbeault Nov 6, 2024
ebd1f6c
Updated init file
ncguilbeault Nov 6, 2024
6cb45dc
Add bonsai shaders package
ncguilbeault Nov 7, 2024
e4d0545
Updated to use shaders render frequency for timing
ncguilbeault Nov 7, 2024
8fce417
Renamed folders more appropriately to NeuralDecoding/PositionDecoding…
ncguilbeault Nov 7, 2024
d95ef63
Updated to remove cuda path declaration and copy of decoder class
ncguilbeault Nov 7, 2024
97b7531
Updated to have filename declarations at top
ncguilbeault Nov 7, 2024
0b53a4a
Updated
ncguilbeault Nov 7, 2024
9bc727f
Added README to example
ncguilbeault Nov 8, 2024
c022daa
Added requirements.txt file
ncguilbeault Nov 8, 2024
8a775f7
Updated notebook for 50Hz down sampling
ncguilbeault Nov 8, 2024
031c46d
Added cell for plotting
ncguilbeault Nov 14, 2024
c8ee1a4
Added online FPS estimate
ncguilbeault Nov 14, 2024
b62ad61
Updated to properly use 50 Hz
ncguilbeault Nov 14, 2024
2c9cfda
Remove exensions and use new Bonsai.ML.NeuralDecoding package
ncguilbeault Nov 15, 2024
ffd1014
Updated to use Bonsai.ML package
ncguilbeault Nov 18, 2024
5cae1d2
Removed requirements.txt file in favor of installing from git repo
ncguilbeault Nov 18, 2024
7f6b754
Updated notebooks for new package
ncguilbeault Nov 18, 2024
82b92bd
Added new dataset to README
ncguilbeault Nov 18, 2024
1060fee
Updated example README
ncguilbeault Nov 18, 2024
1043f16
Removed python package from inside example folder
ncguilbeault Nov 18, 2024
ee9def4
Renamed workflows
ncguilbeault Nov 19, 2024
d3bd578
Updated notebooks and removed redundant loading from file
ncguilbeault Nov 19, 2024
b0f1ca8
Updated package version correctly
ncguilbeault Nov 19, 2024
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
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ All of the datasets used in these examples can be found by going to: [https://do

ZebrafishExampleVid.avi - provided by Nicholas Guilbeault in the Thiele lab at the University of Toronto. If you would like to refer to this data, please cite Guilbeault, N.C., Guerguiev, J., Martin, M. et al. (2021). BonZeb: open-source, modular software tools for high-resolution zebrafish tracking and analysis. *Scientific Reports* *11*, 8148, [https://doi.org/10.1038/s41598-021-85896-x](https://doi.org/10.1038/s41598-021-85896-x).

ForagingMouseExampleVid.avi - provided by the Sainsbury Wellcome Centre Foraging Behaviour Working Group. (2023). Aeon: An open-source platform to study the neural basis of ethological behaviours over naturalistic timescales, [https://doi.org/10.5281/zenodo.8413142](https://doi.org/10.5281/zenodo.8413142)
ForagingMouseExampleVid.avi - provided by the Sainsbury Wellcome Centre Foraging Behaviour Working Group. (2023). Aeon: An open-source platform to study the neural basis of ethological behaviours over naturalistic timescales, [https://doi.org/10.5281/zenodo.8413142](https://doi.org/10.5281/zenodo.8413142).

ReceptiveFieldSimpleCell.zip - provided by the authors of "Touryan, J., Felsen, G., & Dan, Y. (2005). Spatial structure of complex cell receptive fields measured with natural images. Neuron, 45(5), 781-791." [https://doi.org/10.1016/j.neuron.2005.01.029](https://doi.org/10.1016/j.neuron.2005.01.029)
ReceptiveFieldSimpleCell.zip - provided by the authors of "Touryan, J., Felsen, G., & Dan, Y. (2005). Spatial structure of complex cell receptive fields measured with natural images. Neuron, 45(5), 781-791." [https://doi.org/10.1016/j.neuron.2005.01.029](https://doi.org/10.1016/j.neuron.2005.01.029).

HippocampalTetrodeRecording.zip - provided by the authors of Joshi, A., Denovellis, E.L., Mankili, A. et al. (2023). Dynamic synchronization between hippocampal representations and stepping. Nature 617, 125–131. [https://doi.org/10.1038/s41586-023-05928-6](https://doi.org/10.1038/s41586-023-05928-6).

### Acknowledgements

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
<?xml version="1.0" encoding="utf-8"?>
<PackageConfiguration xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Packages>
<Package id="Bonsai" version="2.8.5" />
Copy link
Contributor

@PathogenDavid PathogenDavid Jun 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Edit: Ah, I didn't realize this was a stale PR already covered by #19 in this regard.

Please ensure to update this PR to Bonsai 2.9.0 prior to merging, similar to #18 or #19

The easiest way to do this is to put the 2.9.0 Bonsai.exe here and launch it and everything else should be automatic. (Don't do it manually, 2.9.0 has new core dependencies it'll need to add.)

(Worth noting that I did not review any other files, just wanted to make this note.)

<Package id="Bonsai.Core" version="2.8.5" />
<Package id="Bonsai.Design" version="2.8.5" />
<Package id="Bonsai.Design.Visualizers" version="2.8.0" />
<Package id="Bonsai.Editor" version="2.8.5" />
<Package id="Bonsai.Gui" version="0.1.0" />
<Package id="Bonsai.Gui.ZedGraph" version="0.1.0" />
<Package id="Bonsai.ML" version="0.4.0" />
<Package id="Bonsai.ML.Design" version="0.4.0" />
<Package id="Bonsai.ML.NeuralDecoder" version="0.4.0" />
<Package id="Bonsai.ML.NeuralDecoder.Design" version="0.4.0" />
<Package id="Bonsai.ML.Python" version="0.4.0" />
<Package id="Bonsai.Scripting.Expressions" version="2.8.0" />
<Package id="Bonsai.Scripting.Expressions.Design" version="2.8.0" />
<Package id="Bonsai.Scripting.Python" version="0.2.1" />
<Package id="Bonsai.Shaders" version="0.27.1" />
<Package id="Bonsai.System" version="2.8.1" />
<Package id="jacobslusser.ScintillaNET" version="3.6.3" />
<Package id="Markdig" version="0.18.1" />
<Package id="MathNet.Numerics" version="5.0.0" />
<Package id="Microsoft.CSharp" version="4.7.0" />
<Package id="Microsoft.Web.WebView2" version="1.0.1823.32" />
<Package id="OpenCV.Net" version="3.4.2" />
<Package id="OpenTK" version="3.1.0" />
<Package id="OxyPlot.Core" version="2.1.2" />
<Package id="OxyPlot.WindowsForms" version="2.1.2" />
<Package id="pythonnet" version="3.0.3" />
<Package id="Rx-Core" version="2.2.5" />
<Package id="Rx-Interfaces" version="2.2.5" />
<Package id="Rx-Linq" version="2.2.5" />
<Package id="Rx-PlatformServices" version="2.2.5" />
<Package id="SvgNet" version="3.3.3" />
<Package id="System.Buffers" version="4.5.1" />
<Package id="System.Linq.Dynamic" version="1.0.7" />
<Package id="System.Memory" version="4.5.5" />
<Package id="System.Numerics.Vectors" version="4.5.0" />
<Package id="System.Reflection.Emit" version="4.3.0" />
<Package id="System.Resources.Extensions" version="8.0.0" />
<Package id="System.Runtime.CompilerServices.Unsafe" version="4.5.3" />
<Package id="YamlDotNet" version="13.1.1" />
<Package id="ZedGraph" version="5.1.7" />
</Packages>
<AssemblyReferences>
<AssemblyReference assemblyName="Bonsai" />
<AssemblyReference assemblyName="Bonsai.Core" />
<AssemblyReference assemblyName="Bonsai.Design" />
<AssemblyReference assemblyName="Bonsai.Design.Visualizers" />
<AssemblyReference assemblyName="Bonsai.Editor" />
<AssemblyReference assemblyName="Bonsai.Gui" />
<AssemblyReference assemblyName="Bonsai.Gui.ZedGraph" />
<AssemblyReference assemblyName="Bonsai.ML" />
<AssemblyReference assemblyName="Bonsai.ML.Design" />
<AssemblyReference assemblyName="Bonsai.ML.NeuralDecoder" />
<AssemblyReference assemblyName="Bonsai.ML.NeuralDecoder.Design" />
<AssemblyReference assemblyName="Bonsai.ML.Python" />
<AssemblyReference assemblyName="Bonsai.Scripting.Expressions" />
<AssemblyReference assemblyName="Bonsai.Scripting.Expressions.Design" />
<AssemblyReference assemblyName="Bonsai.Scripting.Python" />
<AssemblyReference assemblyName="Bonsai.Shaders" />
<AssemblyReference assemblyName="Bonsai.System" />
</AssemblyReferences>
<AssemblyLocations>
<AssemblyLocation assemblyName="Bonsai" processorArchitecture="MSIL" location="Packages/Bonsai.2.8.5/lib/net48/Bonsai.exe" />
<AssemblyLocation assemblyName="Bonsai.Core" processorArchitecture="MSIL" location="Packages/Bonsai.Core.2.8.5/lib/net462/Bonsai.Core.dll" />
<AssemblyLocation assemblyName="Bonsai.Design" processorArchitecture="MSIL" location="Packages/Bonsai.Design.2.8.5/lib/net462/Bonsai.Design.dll" />
<AssemblyLocation assemblyName="Bonsai.Design.Visualizers" processorArchitecture="MSIL" location="Packages/Bonsai.Design.Visualizers.2.8.0/lib/net462/Bonsai.Design.Visualizers.dll" />
<AssemblyLocation assemblyName="Bonsai.Editor" processorArchitecture="MSIL" location="Packages/Bonsai.Editor.2.8.5/lib/net472/Bonsai.Editor.dll" />
<AssemblyLocation assemblyName="Bonsai.Gui" processorArchitecture="MSIL" location="Packages/Bonsai.Gui.0.1.0/lib/net472/Bonsai.Gui.dll" />
<AssemblyLocation assemblyName="Bonsai.Gui.ZedGraph" processorArchitecture="MSIL" location="Packages/Bonsai.Gui.ZedGraph.0.1.0/lib/net472/Bonsai.Gui.ZedGraph.dll" />
<AssemblyLocation assemblyName="Bonsai.ML" processorArchitecture="MSIL" location="Packages/Bonsai.ML.0.4.0/lib/net472/Bonsai.ML.dll" />
<AssemblyLocation assemblyName="Bonsai.ML.Design" processorArchitecture="MSIL" location="Packages/Bonsai.ML.Design.0.4.0/lib/net472/Bonsai.ML.Design.dll" />
<AssemblyLocation assemblyName="Bonsai.ML.NeuralDecoder" processorArchitecture="MSIL" location="Packages/Bonsai.ML.NeuralDecoder.0.4.0/lib/net472/Bonsai.ML.NeuralDecoder.dll" />
<AssemblyLocation assemblyName="Bonsai.ML.NeuralDecoder.Design" processorArchitecture="MSIL" location="Packages/Bonsai.ML.NeuralDecoder.Design.0.4.0/lib/net472/Bonsai.ML.NeuralDecoder.Design.dll" />
<AssemblyLocation assemblyName="Bonsai.ML.Python" processorArchitecture="MSIL" location="Packages/Bonsai.ML.Python.0.4.0/lib/net472/Bonsai.ML.Python.dll" />
<AssemblyLocation assemblyName="Bonsai.Scripting.Expressions" processorArchitecture="MSIL" location="Packages/Bonsai.Scripting.Expressions.2.8.0/lib/net462/Bonsai.Scripting.Expressions.dll" />
<AssemblyLocation assemblyName="Bonsai.Scripting.Expressions.Design" processorArchitecture="MSIL" location="Packages/Bonsai.Scripting.Expressions.Design.2.8.0/lib/net462/Bonsai.Scripting.Expressions.Design.dll" />
<AssemblyLocation assemblyName="Bonsai.Scripting.Python" processorArchitecture="MSIL" location="Packages/Bonsai.Scripting.Python.0.2.1/lib/net472/Bonsai.Scripting.Python.dll" />
<AssemblyLocation assemblyName="Bonsai.Shaders" processorArchitecture="MSIL" location="Packages/Bonsai.Shaders.0.27.1/lib/net462/Bonsai.Shaders.dll" />
<AssemblyLocation assemblyName="Bonsai.System" processorArchitecture="MSIL" location="Packages/Bonsai.System.2.8.1/lib/net462/Bonsai.System.dll" />
<AssemblyLocation assemblyName="Markdig" processorArchitecture="MSIL" location="Packages/Markdig.0.18.1/lib/net40/Markdig.dll" />
<AssemblyLocation assemblyName="MathNet.Numerics" processorArchitecture="MSIL" location="Packages/MathNet.Numerics.5.0.0/lib/net48/MathNet.Numerics.dll" />
<AssemblyLocation assemblyName="Microsoft.Web.WebView2.Core" processorArchitecture="MSIL" location="Packages/Microsoft.Web.WebView2.1.0.1823.32/lib/net45/Microsoft.Web.WebView2.Core.dll" />
<AssemblyLocation assemblyName="Microsoft.Web.WebView2.WinForms" processorArchitecture="MSIL" location="Packages/Microsoft.Web.WebView2.1.0.1823.32/lib/net45/Microsoft.Web.WebView2.WinForms.dll" />
<AssemblyLocation assemblyName="Microsoft.Web.WebView2.Wpf" processorArchitecture="MSIL" location="Packages/Microsoft.Web.WebView2.1.0.1823.32/lib/net45/Microsoft.Web.WebView2.Wpf.dll" />
<AssemblyLocation assemblyName="OpenCV.Net" processorArchitecture="MSIL" location="Packages/OpenCV.Net.3.4.2/lib/net462/OpenCV.Net.dll" />
<AssemblyLocation assemblyName="OpenTK" processorArchitecture="MSIL" location="Packages/OpenTK.3.1.0/lib/net20/OpenTK.dll" />
<AssemblyLocation assemblyName="OxyPlot" processorArchitecture="MSIL" location="Packages/OxyPlot.Core.2.1.2/lib/net45/OxyPlot.dll" />
<AssemblyLocation assemblyName="OxyPlot.WindowsForms" processorArchitecture="MSIL" location="Packages/OxyPlot.WindowsForms.2.1.2/lib/net45/OxyPlot.WindowsForms.dll" />
<AssemblyLocation assemblyName="Python.Runtime" processorArchitecture="MSIL" location="Packages/pythonnet.3.0.3/lib/netstandard2.0/Python.Runtime.dll" />
<AssemblyLocation assemblyName="ScintillaNET" processorArchitecture="MSIL" location="Packages/jacobslusser.ScintillaNET.3.6.3/lib/net40/ScintillaNET.dll" />
<AssemblyLocation assemblyName="SVG" processorArchitecture="MSIL" location="Packages/SvgNet.3.3.3/lib/net462/SVG.dll" />
<AssemblyLocation assemblyName="System.Buffers" processorArchitecture="MSIL" location="Packages/System.Buffers.4.5.1/lib/net461/System.Buffers.dll" />
<AssemblyLocation assemblyName="System.Linq.Dynamic" processorArchitecture="MSIL" location="Packages/System.Linq.Dynamic.1.0.7/lib/net40/System.Linq.Dynamic.dll" />
<AssemblyLocation assemblyName="System.Memory" processorArchitecture="MSIL" location="Packages/System.Memory.4.5.5/lib/net461/System.Memory.dll" />
<AssemblyLocation assemblyName="System.Numerics.Vectors" processorArchitecture="MSIL" location="Packages/System.Numerics.Vectors.4.5.0/lib/net46/System.Numerics.Vectors.dll" />
<AssemblyLocation assemblyName="System.Reactive.Core" processorArchitecture="MSIL" location="Packages/Rx-Core.2.2.5/lib/net45/System.Reactive.Core.dll" />
<AssemblyLocation assemblyName="System.Reactive.Interfaces" processorArchitecture="MSIL" location="Packages/Rx-Interfaces.2.2.5/lib/net45/System.Reactive.Interfaces.dll" />
<AssemblyLocation assemblyName="System.Reactive.Linq" processorArchitecture="MSIL" location="Packages/Rx-Linq.2.2.5/lib/net45/System.Reactive.Linq.dll" />
<AssemblyLocation assemblyName="System.Reactive.PlatformServices" processorArchitecture="MSIL" location="Packages/Rx-PlatformServices.2.2.5/lib/net45/System.Reactive.PlatformServices.dll" />
<AssemblyLocation assemblyName="System.Resources.Extensions" processorArchitecture="MSIL" location="Packages/System.Resources.Extensions.8.0.0/lib/net462/System.Resources.Extensions.dll" />
<AssemblyLocation assemblyName="System.Runtime.CompilerServices.Unsafe" processorArchitecture="MSIL" location="Packages/System.Runtime.CompilerServices.Unsafe.4.5.3/lib/net461/System.Runtime.CompilerServices.Unsafe.dll" />
<AssemblyLocation assemblyName="YamlDotNet" processorArchitecture="MSIL" location="Packages/YamlDotNet.13.1.1/lib/net47/YamlDotNet.dll" />
<AssemblyLocation assemblyName="ZedGraph" processorArchitecture="MSIL" location="Packages/ZedGraph.5.1.7/lib/net35-Client/ZedGraph.dll" />
</AssemblyLocations>
<LibraryFolders>
<LibraryFolder path="Packages/Microsoft.Web.WebView2.1.0.1823.32/runtimes/win-arm64/native" platform="arm64" />
<LibraryFolder path="Packages/Microsoft.Web.WebView2.1.0.1823.32/runtimes/win-arm64/native_uap" platform="arm64" />
<LibraryFolder path="Packages/Microsoft.Web.WebView2.1.0.1823.32/runtimes/win-x64/native" platform="x64" />
<LibraryFolder path="Packages/Microsoft.Web.WebView2.1.0.1823.32/runtimes/win-x64/native_uap" platform="x64" />
<LibraryFolder path="Packages/Microsoft.Web.WebView2.1.0.1823.32/runtimes/win-x86/native" platform="x86" />
<LibraryFolder path="Packages/Microsoft.Web.WebView2.1.0.1823.32/runtimes/win-x86/native_uap" platform="x86" />
</LibraryFolders>
</PackageConfiguration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="Gallery" value="Gallery" />
<add key="Bonsai Packages" value="https://www.myget.org/F/bonsai/api/v3/index.json" />
<add key="Community Packages" value="https://www.myget.org/F/bonsai-community/api/v3/index.json" />
</packageSources>
</configuration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Push-Location $PSScriptRoot
if (!(Test-Path "./Bonsai.exe")) {
$release = "https://github.com/bonsai-rx/bonsai/releases/latest/download/Bonsai.zip"
$configPath = "./Bonsai.config"
if (Test-Path $configPath) {
[xml]$config = Get-Content $configPath
$bootstrapper = $config.PackageConfiguration.Packages.Package.where{$_.id -eq 'Bonsai'}
if ($bootstrapper) {
$version = $bootstrapper.version
$release = "https://github.com/bonsai-rx/bonsai/releases/download/$version/Bonsai.zip"
}
}
Invoke-WebRequest $release -OutFile "temp.zip"
Move-Item -Path "NuGet.config" "temp.config" -ErrorAction SilentlyContinue
Expand-Archive "temp.zip" -DestinationPath "." -Force
Move-Item -Path "temp.config" "NuGet.config" -Force -ErrorAction SilentlyContinue
Remove-Item -Path "temp.zip"
Remove-Item -Path "Bonsai32.exe"
}
& .\Bonsai.exe --no-editor
Pop-Location
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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"
Original file line number Diff line number Diff line change
@@ -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."
Original file line number Diff line number Diff line change
@@ -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
Loading