Skip to main content

Neuroimaging Widgets (niwidgets)

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:

Install via:

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

Usage:

There are currently three supported widgets:

  1. Volume widgets. This widget is primarily designed to mimic existing tools such as , but it also allows you to wrap plots from the nilearn plotting library to make them interactive.

  2. Surface widgets. This widget takes freesurfer-generated volume files and turns them into widgets using the ipyvolume library. It allows you to add different overlays for the surface files.

  3. Streamline widgets. This widget accepts .trk files and displays the tracts using ipyvolume.

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:

my_widget.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 nip.plot_img)

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!

Development

Contributing

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.

Development installation

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
  • doc-requirements.txt installed Run make gh-pages in 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.


Developed by Jan Freyberg, Bjoern Soergel, Satrajit Ghosh, Melanie Ganz, Murat Bilgel, Ariel Rokem, and elyb01.

Release files for niwidgets 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for niwidgets 0.2.2
File Size Uploaded
niwidgets-0.2.2.tar.gz 12.5 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for niwidgets 0.2.2
File Interpreter ABI Platform
niwidgets-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size:25.0 MB

Release files / niwidgets-0.2.2.tar.gz

Download URL niwidgets-0.2.2.tar.gz
Size 12.5 MB
Tags Source
SHA-256 checksum
How to use checksums
42af7c72b18d68d97835c8c05b5b857fc0b3413cd427fdba9125b346c2d2736a
BLAKE2b-256 checksum
How to use checksums
a7e63fe2f13c85bdccc7dbf1a259d03cd8b2604aadfc1b2093877107a4f54d34
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/0.12.12 CPython/3.7.1 Linux/4.15.0-1028-gcp

Release files / niwidgets-0.2.2-py3-none-any.whl

Download URL niwidgets-0.2.2-py3-none-any.whl
Size 12.5 MB
Tags Python 3
SHA-256 checksum
How to use checksums
f7473ab8bb4ab0f5110ca2c336b0583af5e48b8e5b882e75e49e99b4dfd438c3
BLAKE2b-256 checksum
How to use checksums
b8d8a3f7b9a295670bf7ea4ef1dd421867751b93582ebf8c57777aa9b3f83462
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/0.12.12 CPython/3.7.1 Linux/4.15.0-1028-gcp

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 release files

0.2.1

1 release file

0.2.0

1 release file

0.1.4

1 release file

0.1.3

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page