Skip to main content

OHBA Software Library: Dynamics Toolbox

Project description

OHBA Software Library: Dynamics Toolbox

osl-dynamics is a Python toolbox for studying brain dynamics using neuroimaging data (M/EEG and fMRI).

See the readthedocs page for a description of this project: https://osl-dynamics.readthedocs.io.

Citation

If you find this toolbox useful, please cite the paper:

Gohil, C., Huang, R., Roberts, E., van Es, M. W., Quinn, A. J., Vidaurre, D., & Woolrich, M. W. (2024). osl-dynamics, a toolbox for modeling fast dynamic brain activity. Elife, 12, RP91949.

Installation

We recommend installing osl-dynamics using the conda environment files in /envs, which can be installed using Miniforge.

conda / mamba installation

Miniforge (conda/mamba) can be installed with:

curl -LO "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh"
bash Miniforge3-$(uname)-$(uname -m).sh
rm Miniforge3-$(uname)-$(uname -m).sh

osl-dynamics installation

Different computers have their own environment files. For more information see the envs readme.

Linux

curl -LO https://raw.githubusercontent.com/OHBA-analysis/osl-dynamics/refs/heads/main/envs/osld-tf.yml
mamba env create -f osld-tf.yml
rm osld-tf.yml

If you have a GPU, then use the osld-tf-cuda.yml environment instead:

curl -LO https://raw.githubusercontent.com/OHBA-analysis/osl-dynamics/refs/heads/main/envs/osld-tf-cuda.yml
mamba env create -f osld-tf-cuda.yml
rm osld-tf-cuda.yml

Mac

If you have an M-series (M1, M2, M3) chip use:

curl -LO https://raw.githubusercontent.com/OHBA-analysis/osl-dynamics/refs/heads/main/envs/osld-tf.yml
mamba env create -f osld-tf.yml
rm osld-tf.yml

Otherwise, if you have an Intel chip use:

curl -LO https://raw.githubusercontent.com/OHBA-analysis/osl-dynamics/refs/heads/main/envs/osld-tf-macos.yml
mamba env create -f osld-tf-macos.yml
rm osld-tf-macos.yml

Windows

If you are using a Windows computer, we recommend first installing Linux (Ubuntu) as a Windows Subsystem by following the instructions here. Then follow the instructions for Linux above in the Ubuntu terminal.

hbaws (Oxford)

On the OHBA workstation (hbaws), install Miniforge and Mamba using the instructions above and install osl-dynamics using:

curl -LO https://raw.githubusercontent.com/OHBA-analysis/osl-dynamics/refs/heads/main/envs/hbaws.yml
mamba env create -f hbaws.yml
rm hbaws.yml

BMRC (Oxford)

On the Biomedical Research Computing (BMRC) cluster, conda and mamba are available as a software module:

module load Miniforge3

and osl-dynamics can be installed with:

curl -LO https://raw.githubusercontent.com/OHBA-analysis/osl-dynamics/refs/heads/main/envs/bmrc.yml
mamba env create -f bmrc.yml
rm bmrc.yml

The above can be run on the login nodes (clusterX.bmrc.ox.ac.uk). On compg017 you will need to set the following to use conda:

unset https_proxy http_proxy no_proxy HTTPS_PROXY HTTP_PROXY NO_PROXY

See here for useful information regarding how to use the BMRC cluster.

Install the latest code from the GitHub repository (optional)

You should only need to do this if you need a feature or fix that has not been released on pip yet.

After you have created an osld environment you can install the latest code (development version) from the GitHub repository with:

conda activate osld
pip install git+https://github.com/OHBA-analysis/osl-dynamics.git

Install the source code (optional)

After you have created an osld environment you can install an editable local copy of the source code on your computer with:

git clone https://github.com/OHBA-analysis/osl-dynamics.git
conda activate osld
cd osl-dynamics
pip install -e .

You will run your local copy of the code when you import osl_dynamics.

If you are a developer, you may wish to clone the repository using SSH rather than HTTPS to make pushing branches/commits easier:

git clone git@github.com:OHBA-analysis/osl-dynamics.git

Test GPUs are working

You can use the following to check if TensorFlow is using any GPUs you have available:

python -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"

This should return a list of GPUs.

Removing osl-dynamics

Simply delete the conda environment:

conda env remove -n osld
conda clean --all

And remove the GitHub repository if you have cloned it:

rm -rf osl-dynamics

Documentation

The read the docs page should be automatically updated whenever there's a new commit on the main branch.

The documentation is included as docstrings in the source code. The API reference documentation will only be automatically generated if the docstrings are written correctly. The documentation directory /doc also contains .rst files that provide additional info regarding installation, development, the models, etc.

To compile the documentation locally you need to install the required packages (sphinx, etc) in your conda environment:

cd osl-dynamics
conda activate osld
pip install -r doc/requirements.txt

To compile the documentation locally use:

sphinx-build -b html doc build

The local build of the documentation webpage can be found in build/sphinx/html/index.html.

To skip building the tutorials, comment out "sphinx_gallery.gen_gallery" here.

Releases

A couple packages are needed to build and upload a project to PyPI, these can be installed in your conda environment with:

pip install build twine

The following steps can be used to release a new version:

  1. Update the version on line 10 of pyproject.toml by removing dev from the version number.

  2. Commit the updated pyproject.toml to the main branch of the GitHub repo.

  3. Check the latest branch has compiled successfully on readthedocs.

  4. Delete any old distributions that have been built (if there are any):

rm -r dist
  1. Build a distribution in the osl-dynamics root directory with:
python -m build

This will create a new directory called dist.

  1. Test the build by installing with
pip install dist/<build>.whl
  1. Upload the distribution to PyPI with
twine upload dist/*

You will need to enter the username and password that you used to register with https://pypi.org. You may need to setup 2FA and/or an API token, see API token instructions in your PyPI account settings.

  1. Tag the commit uploaded to PyPI with the version number using the 'Create a new release' link on the right of the GitHub repo webpage. You will need to untick 'Set as a pre-release' and tick 'Set as the latest release'.

  2. Change the version to X.Y.devZ in pyproject.toml and commit the new dev version to main.

  3. Reinstall your editable development version in your osld conda environment:

pip install -e .
  1. Draft a new release (click 'Releases' on the right panel on the GitHub homepage, then 'Draft a new release') to help keep note of changes for the next release.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

osl_dynamics-3.0.0.tar.gz (22.0 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

osl_dynamics-3.0.0-py3-none-any.whl (22.1 MB view details)

Uploaded Python 3

File details

Details for the file osl_dynamics-3.0.0.tar.gz.

File metadata

  • Download URL: osl_dynamics-3.0.0.tar.gz
  • Upload date:
  • Size: 22.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for osl_dynamics-3.0.0.tar.gz
Algorithm Hash digest
SHA256 2b11d15397d143ecfcf03ae6f901b23dd2f4729b2a702a0b0f08b127bf09886a
MD5 f3e6d5b7c85a010b1a0371eadf366767
BLAKE2b-256 ad52a8d1df9321950db8d69667deba7c32df922dbb6fffc66a1cf07d0ee195ff

See more details on using hashes here.

File details

Details for the file osl_dynamics-3.0.0-py3-none-any.whl.

File metadata

  • Download URL: osl_dynamics-3.0.0-py3-none-any.whl
  • Upload date:
  • Size: 22.1 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for osl_dynamics-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2046330a65f816f5034efdbe3b8cc35eb16ad74eb6388020a05b1d2588434530
MD5 16ad604ef9ca611fde88f60d571e7afe
BLAKE2b-256 635fd40aba38cf242b612c8f1f722ec4f42164b0a8ace0537e37973c26d82689

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page