ipyniivue provides interactive visualization of medical volumes, meshes, streamlines, and connectomes in Jupyter. This repository includes recipes for ipyniivue that can be run on the cloud using binder or locally from a jupyter notebook. See the ipyniivue documentation for more features.
Open the live demos with a web browser using binder. This is a zero-footprint solution: no files are downloaded to your computer. However, it does tend to be slow.
You can also paste notebook scripts into Google Colab. You will want to make sure to clone the repository and install the requirements. While this is less elegant than binder, the performance is typically better. Here is a basic example:
!git clone https://github.com/niivue/jupyter-notebooks
%cd niivue-binder
!pip install -q -r requirements.txt
#copy and paste a notebook, e.g. basic.ipynb
from ipyniivue import NiiVue
nv = NiiVue()
nv.load_volumes([{'path': './images/mni152.nii.gz'}])
nv
You can work locally, and this typically provides optimal performance. However, this does require considerable disk space:
git clone https://github.com/niivue/jupyter-notebooks
cd jupyter-notebooks
pip install -r requirements.txt
jupyter lab ./notebooks/basic.ipynb
# press the 'run' button for the basic.ipynb notebookAlternatively, you can install in a Python environment, to isolate it from other dependencies.
git clone https://github.com/niivue/jupyter-notebooks
cd jupyter-notebooks
conda env create -n ipyniivue -f environment.yml
conda activate ipyniivue
jupyter lab ./notebooks/basic.ipynbgit clone https://github.com/niivue/jupyter-notebooks
cd jupyter-notebooks
pip install -r requirements-dev.txt
pre-commit installPre-commit hooks automate code style and strip notebook outputs and metadata for cleaner commits. They run upon committing changes or manually with:
pre-commit run --all-files