'Interactive jupyter widgets for neuroimaging.'
Neuroimaging Widgets (
This repository is supposed to provide easy and general wrappers to display interactive widgets that visualise standard-format neuroimaging data, using new functions and standard functions from other libraries. It looks like this:
pip install niwidgets
Or, to get the most up-to-date development version from github:
pip install git+git://github.com/nipy/niwidgets/
It requires nibabel and nilearn:
pip install nibabel nilearn
Check out the examples using the code in this notebook here: https://github.com/nipy/niwidgets/blob/master/index.ipynb (you need to run the notebook on your local machine to use the interactive features).
or using binder here: https://mybinder.org/v2/gh/nipy/niwidgets/master?filepath=index.ipynb
There are currently three supported widgets:
Volume widgets. This widget is primarily designed to mimic existing tools such as <add tool here>, but it also allows you to wrap plots from the
nilearnplotting library to make them interactive.
Surface widgets. This widget takes freesurfer-generated volume files and turns them into widgets using the
ipyvolumelibrary. It allows you to add different overlays for the surface files.
Streamline widgets. This widget accepts
.trkfiles and displays the tracts using
To see how to use these widgets, please check the documentation.
As an example of how you might generate a Volume widget:
from niwidgets import NiftiWidget my_widget = NiftiWidget('./path/to/file.nii')
You can then create a plot either with the default nifti plotter:
This will give you sliders to slice through the image, and an option to set the colormap.
You can also provide your own plotting function:
import nilearn.plotting as nip my_widget.nifti_plotter(plotting_func=nip.plot_glass_brain)
By default, this will give you the following interactive features: -
selecting a colormap - if supported by the plotting function, x-y-x
sliders (e.g. for
You can, however, always provide features you would like to have interactive yourself. This follows the normal ipywidgets format. For example, if you provide a list of strings for a keyword argument, this becomes a drop-down menu. If you provide a tuple of two numbers, this becomes a slider. Take a look at some examples we have in this notebook (you need to run the notebook on your local machine to use the interactive features).
Hopefully we will be able to add more default interactive features in the future, as well as plotting of other data (such as surface projections). If you have any suggestions for plot features to be added, please let us know - or add them yourself and create a pull request!
Please contribute! When writing new widgets, please make sure you include example data that allows users to try a widget without having to munge their data into the right format first.
Please also make sure you write a test for your new widget. It's hard to test jupyter widgets, but it would be great if you could at least write a test that "instantiates" a widget. This allows us to maintain a stable release.
As always with pip packages, you can install a "development" version of this
package by cloning the git repository and installing it via
pip install -e /path/to/package.
Updating the documentation
To update the documentation, you can do the following things:
- Make your changes on a separate branch, such as DOC/update-api-documentation.
- Merge your branch into master Make sure you have the packages in
make gh-pagesin the root directory of
- the repository
This should run sphinx to generate the documentation, push it to the gh-pages branch, and then revert to master.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size & hash SHA256 hash help||File type||Python version||Upload date|
|niwidgets-0.2.2-py3-none-any.whl (12.5 MB) Copy SHA256 hash SHA256||Wheel||py3|
|niwidgets-0.2.2.tar.gz (12.5 MB) Copy SHA256 hash SHA256||Source||None|