A Jupyter Widget for Niivue based on anywidget.
Project description
ipyniivue
A Jupyter Widget for Niivue based on anywidget.
Installation
Install ipyniivue using pip
:
pip install ipyniivue
Usage
In a Jupyter environment:
from ipyniivue import NiiVue
nv = NiiVue()
nv.load_volumes([{"path": "images/mni152.nii.gz"}])
nv
This will render an interactive Niivue widget within your notebook.
See the basic demo to learn more.
Documentation
See the Documentation for usage.
Development
ipyniivue uses the recommended hatchling
build system, which is convenient to use via the hatch
CLI. We recommend installing hatch
globally (e.g., via pipx
) and running the various commands defined within pyproject.toml
. hatch
will take care of creating and synchronizing a virtual environment with all dependencies defined in pyproject.toml
.
Command Cheat Sheet
Run these commands from the root of the project:
Command | Description |
---|---|
hatch run format |
Format the project with ruff format . and apply linting with ruff --fix . |
hatch run lint |
Lint the project with ruff check . |
hatch run test |
Run unit tests with pytest |
hatch run docs |
Build docs with Sphinx |
Alternatively, you can manually create a virtual environment and manage installation and dependencies with pip
:
python3 -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
Making Changes to the JavaScript Code
This is an anywidget project, meaning the codebase is a hybrid of Python and JavaScript. The JavaScript code resides under the js/
directory and uses esbuild for bundling. Whenever you make changes to the JavaScript code, you need to rebuild the files under src/ipyniivue/static
.
You have two options:
-
Build Once: Build the JavaScript code one time:
npm run build
-
Start Development Server: Start a development server that automatically rebuilds the code as you make changes:
npm run dev
We recommend this approach for a smoother development experience.
Working with Jupyter
Once the development server is running, you can start JupyterLab or Visual Studio Code to develop the widget. When you're finished, stop the development server with Ctrl+C
.
Note: To have
anywidget
automatically apply changes as you work, set the environment variableANYWIDGET_HMR=1
. You can set this directly in a notebook cell:%env ANYWIDGET_HMR=1or in the shell:
export ANYWIDGET_HMR=1
Release Process
Releases are automated using GitHub Actions via the release.yml
workflow.
Steps to Create a New Release
-
Commit Changes: Ensure all your changes are committed.
-
Create a Tag: Create a new tag matching the pattern
v*
:git tag -a vX.X.X -m "vX.X.X" git push --follow-tags
-
Workflow Actions: When triggered, the workflow will:
- Publish the package to PyPI with the tag version.
- Generate a changelog based on conventional commits.
- Create a GitHub Release with the changelog.
Changelog Generation
- We generate a changelog for GitHub releases with
antfu/changelogithub
. - Each changelog entry is grouped and rendered based on conventional commits.
- It's recommended to follow the Conventional Commits specification.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file ipyniivue-2.3.0.tar.gz
.
File metadata
- Download URL: ipyniivue-2.3.0.tar.gz
- Upload date:
- Size: 791.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
b69e4af2776468bb20daeaea7d8618c5d704d1dffff57fbbd14524d3c8faaa44
|
|
MD5 |
0dbbf1ce085e155051c614cb0c0c55ec
|
|
BLAKE2b-256 |
553ac91bd3320e40b77a8bdac3a7831957960ee8899fc609edc6c309e638b1f8
|
Provenance
The following attestation bundles were made for ipyniivue-2.3.0.tar.gz
:
Publisher:
release.yml
on niivue/ipyniivue
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1
-
Predicate type:
https://docs.pypi.org/attestations/publish/v1
-
Subject name:
ipyniivue-2.3.0.tar.gz
-
Subject digest:
b69e4af2776468bb20daeaea7d8618c5d704d1dffff57fbbd14524d3c8faaa44
- Sigstore transparency entry: 254695056
- Sigstore integration time:
-
Permalink:
niivue/ipyniivue@3d31240de6c1184aa5f4a501844fc0fa0b5ed94a
-
Branch / Tag:
refs/tags/v2.3.0
- Owner: https://github.com/niivue
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com
-
Runner Environment:
github-hosted
-
Publication workflow:
release.yml@3d31240de6c1184aa5f4a501844fc0fa0b5ed94a
-
Trigger Event:
push
-
Statement type:
File details
Details for the file ipyniivue-2.3.0-py3-none-any.whl
.
File metadata
- Download URL: ipyniivue-2.3.0-py3-none-any.whl
- Upload date:
- Size: 811.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
a0e078971e3a598cecc3007042bbc94a695b113233cf535336348e9531e38a36
|
|
MD5 |
17d9976eb381c49afab45a0d0866f828
|
|
BLAKE2b-256 |
8de3b2c1c38765d8bd02a69732052f78801b35b992a7f4c426b84068467c2131
|
Provenance
The following attestation bundles were made for ipyniivue-2.3.0-py3-none-any.whl
:
Publisher:
release.yml
on niivue/ipyniivue
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1
-
Predicate type:
https://docs.pypi.org/attestations/publish/v1
-
Subject name:
ipyniivue-2.3.0-py3-none-any.whl
-
Subject digest:
a0e078971e3a598cecc3007042bbc94a695b113233cf535336348e9531e38a36
- Sigstore transparency entry: 254695065
- Sigstore integration time:
-
Permalink:
niivue/ipyniivue@3d31240de6c1184aa5f4a501844fc0fa0b5ed94a
-
Branch / Tag:
refs/tags/v2.3.0
- Owner: https://github.com/niivue
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com
-
Runner Environment:
github-hosted
-
Publication workflow:
release.yml@3d31240de6c1184aa5f4a501844fc0fa0b5ed94a
-
Trigger Event:
push
-
Statement type: