Releases: niivue/ipyniivue
v2.4.2
🚨 Breaking Changes
- Updated Scene class properties to support multiple clip planes - by @AnthonyAndroulakis (c0feec7)
- Removed
clipThick,clipVolumeLow, andclipVolumeHighconfig options - by @neurolabusc (7a45a68)
🚀 Features
New Example Notebooks:
- Added
document.load.ipynb- by @AnthonyAndroulakis (8b1b1f9) - Added
clipplanes.ipynb- by @neurolabusc (7a45a68) - Added
basic.vox.connect.ipynb- by @neurolabusc (27e76b6) - Added
freesurfer.ipynb- by @neurolabusc (d1e3b48) - Added
mesh.atlas.suit.ipynb- by @neurolabusc (6168f4d) - Added
mesh.mosaic.ipynb- by @neurolabusc (2e52eb5)
New Methods:
- Added
load_documentmethod to load .nvd files from URLs or local file paths - by @AnthonyAndroulakis in #211 (9b73018) - Added support for multiple clip planes with enhanced control - by @neurolabusc in #219 (7a45a68)
- Added
set_clip_plane_colormethod - Added
set_clip_planesmethod - Added
set_cutawaymethod
- Added
- Added support for connectomes from .jcon files - by @neurolabusc (27e76b6) in #221
- Added mesh atlas support with per-parcel custom statistics - by @neurolabusc (2e52eb5) in #222
- Added support accessing
draw_bitmapbinary data to enable bitmap drawing operations - by @AnthonyAndroulakis (6f03c60) - Added
update_gl_volumemethod - by @neurolabusc (d1e3b48) - Added
draw_scenemethod - by @neurolabusc (d1e3b48)
Documentation:
- Added architecture documentation - by @christian-oreilly and @AnthonyAndroulakis in #205 (c781a72)
Internal Improvements:
- Added
requires_canvasutility decorator for methods that need an attached canvas - by @AnthonyAndroulakis (9b73018) - Improved frontend-backend data synchronization for volumes and meshes - by @AnthonyAndroulakis in #211
- Added utility method
sph2cart_deg- by @neurolabusc (7a45a68)
Other
- Updated to [email protected] (from 0.62.1) - by @neurolabusc in #219
View changes on GitHub
v2.4.1
🚨 Breaking Changes
- Removed ability to set config options directly on NiiVue object - by @AnthonyAndroulakis in #202 (7108b5f)
- Config options must now be set via the
optstrait (e.g.,nv.opts.pen_value = 1.0)
- Config options must now be set via the
🚀 Features
New Example Notebooks:
- Added
alphathreshold.ipynbnotebook example - by @AnthonyAndroulakis in #196 - Added
denoise.ipynbnotebook example - by @AnthonyAndroulakis in #190 - Added
modulatescalar.ipynbnotebook example - by @AnthonyAndroulakis in #191 - Added
segment.ipynbnotebook example - by @AnthonyAndroulakis in #192 - Added
mosaics1.ipynbandmosaics2.ipynbnotebook examples - by @AnthonyAndroulakis in #197 - Added
worldspace.ipynbandworldspace2.ipynbnotebook examples - by @AnthonyAndroulakis in #198 - Added
sync.bidirectional.ipynbnotebook example - by @AnthonyAndroulakis in #199
New Methods:
- Added
set_opacitymethod toNiiVueclass (a20279f) - Added
set_modulation_imagemethod toNiiVueclass (5af854c) - Added
set_colormap_negativemethod toNiiVueclass (72cdd9e) - Added
set_corner_orientation_textmethod toNiiVueclass (41225e3) - Added
set_mesh_thickness_on_2dmethod toNiiVueclass (41225e3) - Added
set_slice_mosaic_stringmethod toNiiVueclass (75c8309) - Added
set_multiplanar_pad_pixelsmethod toNiiVueclass (4d3f709) - Added
scene_extents_min_maxmethod toNiiVueclass (46afd0b) - Added
mm2fracandfrac2mmmethods toNiiVueclass (4e886a2) - Added
broadcast_toandsyncmethods for syncing multiple NiiVue instances (bb774d3) - Added
convert_frac2mmandconvert_mm2fracmethods toVolumeclass (4e886a2) - Added
save_to_diskmethod toVolumeclass (72cdd9e) - Added
on_canvas_attachedevent handler toNiiVueclass (bb774d3)
New Properties:
- Added
sceneproperty toNiiVueclass for managing scene state (5af854c) - Added
overlay_outline_widthproperty toNiiVueclass (7ff942d) - Added
overlay_alpha_shaderproperty toNiiVueclass (590b9b8) - Added
cal_min_negandcal_max_negproperties toVolumeclass (72cdd9e) - Added
colormap_typeproperty toVolumeclass (72cdd9e) - Added
modulation_imageandmodulate_alphaproperties toVolumeclass (5af854c) - Added
extents_min_ortho,extents_max_ortho,frac2mm,frac2mm_ortho,dims_ras, andmat_rasproperties toVolumeclass (979a72d) - Added
extents_minandextents_maxproperties toMeshclass (83abf11)
New Traits & Classes:
- Added
Scenetrait class for scene configuration (5af854c) - Added
VolumeObject3DDatatrait class for 3D volume object metadata (979a72d) - Added
ColormapTypeenum (72cdd9e) - Added
PenTypeenum (7c65b3c)
Misc
- Updated to [email protected] - by @AnthonyAndroulakis in #195
- Fixed atlas.ipynb example to respond properly to mouse clicks (bd15c31)
- Removed deprecated
DragModePrimaryenum, merged functionality intoDragMode(bd15c31) - Updated enum documentation for new DragMode values (b08821e)
- Added new serializers and deserializers (979a72d)
View changes on GitHub
v2.4.0
Reworked data input/loading in #187 by @AnthonyAndroulakis
- add url and data+name input options for Volumes
- add url and data+name input options for Meshes
- add url and data+name input options for MeshLayers
- save volume hdr info and dim info on image load
- organize serializers/deserializers into their own file
- save volume img data on image load (chunked)
- save mesh data (pts and tris) on mesh load (chunked)
- be able to change binary data (ex: volume.img) from backend/python and have it update on the frontend
View changes on GitHub
In-depth details / Design decisions
Volume, Mesh, and MeshLayer Inputs
The Volume, Mesh, and MeshLayer classes have been updated to support loading from one of three sources:
- Path: Load from a local file path.
- URL: Load from a remote URL.
- Data + Name: Load from binary data with a specified name.
Examples
Loading a Volume from Path, URL, or Data
from ipyniivue import NiiVue, Volume
# Load from a local file path
volume1 = Volume(path="path/to/volume.nii.gz")
# Load from a URL
volume2 = Volume(url="https://example.com/volume.nii.gz")
# Load from binary data with a name
with open("path/to/volume.nii.gz", "rb") as f:
data = f.read()
volume3 = Volume(data=data, name="volume.nii.gz")
# Load volumes into NiiVue
nv = NiiVue()
nv.load_volumes([volume1, volume2, volume3])The same approach can be applied to Mesh and MeshLayer objects.
Using Dictionaries or Objects
In addition to using dictionaries, you can now use Volume, Mesh, or MeshLayer objects directly when loading or adding to NiiVue. This is done for 2 reasons:
- can add on-change handlers or traitlets-specific functions to volumes, meshes, and mesh layer objects before adding them onto the main widget
- can feel more pythonic than interacting with dictionaries. You can still use dictionaries since that mirrors NiiVue JS usage.
# Use Volume objects directly
nv.load_volumes([volume1, volume2, volume3])
# Or use dictionaries
nv.load_volumes([
{"path": "path/to/volume.nii.gz"},
{"url": "https://example.com/volume.nii.gz"},
{"data": data, "name": "volume.nii.gz"}
])
# You can also have a list that contains a mix of dictionaries and Volume objects.Communication Updates
Chunked Communication from Frontend to Backend
ipywidgets uses tornado for websocket communication. Once major limitation is that tornado limits incoming messages to 10 mb. This is a known issue without an official implementation. See:
Of course, one solution would be to just ask users to update their jupyterlab config when using ipyniivue, but this isn't ideal since it requires:
- the user to do extra work
- you can already send data from backend -> frontend that's way over 10 mb, why not allow the opposite (frontend -> backend)
And so, I've made the decision to implement chunking (specifically, thru the state-change communication line). I've tested my implementation in jupyter lab, jupyter notebook, google colab, and marimo. Marimo uses POST requests instead of WebSockets for frontend -> backend communication, so special handling has been implemented for that.
Visualization
Chunked Data Transfer from Frontend to Backend:
Frontend Backend
+------------+ +------------+
| | -- Chunk 1 ----------> | |
| | -- Chunk 2 ----------> | |
| Large Data | -- Chunk 3 ----------> | |
| | ... | Reassemble |
| | -- Chunk N ----------> | |
+------------+ +------------+
- Frontend breaks the large data into smaller chunks.
- Chunks are sent to the backend with index and type information.
- Backend receives chunks and reassembles them into the complete data.
Numpy arrays are used in the backend so that array type information can be properly communicated.
Updates from Backend to Frontend
Instead of sending the entire array, only the differences are sent:
Backend Frontend
+------------+ Only Changes +------------+
| | -- Indices & Values ---> | |
| Large Data | | Large Data |
| (Modified) | | (Updated) |
+------------+ +------------+
- Backend identifies changes (modified indices and new values).
- Changes are sent to the frontend.
- Frontend applies updates to its local copy based on received indices and values.
If the array type is changed, then the entire array along with the new type is sent to the frontend.
View changes on GitHub
v2.3.3
🚨 Breaking Changes
- frame4D: Rename 'frame4D' to 'frame_4d' - by @AnthonyAndroulakis (12467)
View changes on GitHub
v2.3.2
- fix save_html method
- update ConfigOptions to niivue 0.58.0
- add complex.ipynb notebook example
- add test_images.ipynb notebook example
View changes on GitHub
v2.3.1
🚀 Features
- graph: Add afni.ipynb notebook example - by @AnthonyAndroulakis (249d8)
- draw: Add draw2.ipynb notebook example (adds load_drawing method)
View changes on GitHub
v2.3.0
🚨 Breaking Changes
- Rename NiiVue._meshes and NiiVue._volumes - by @AnthonyAndroulakis (9779e)
- Remove NiiVue.id property - by @AnthonyAndroulakis (d01d0)
- opts: Move NiiVue options to 'opts' attribute - by @AnthonyAndroulakis (a87a9)
- it's still possible to directly set options onto the NiiVue object, but doing so will be removed starting version 2.4.1.
Until then, aDeprecationWarningis shown when directly setting options onto NiiVue.
Please usenv.opts.[option name] to get/set option values. Ex:nv.opts.pen_value = 0.0
- it's still possible to directly set options onto the NiiVue object, but doing so will be removed starting version 2.4.1.
Other changes
- Fix pen_value to properly store EraseCluster (-0.0) by @AnthonyAndroulakis (0999790)
View changes on GitHub
v2.2.2
🚀 Features
New Notebooks:
- Add
vox.tradeoffs.ipynbnotebook example - by @AnthonyAndroulakis in #159 - Add
mesh.matcap.ipynbnotebook example - by @AnthonyAndroulakis in #161 - Add
tracts.ipynbnotebook example - by @AnthonyAndroulakis in #162 - Add
atlas.ipynbnotebook example - by @AnthonyAndroulakis in #167 - Add
atlas.sparse.ipynbnotebook example - by @AnthonyAndroulakis in #168 - Add
draw.ui.ipynbnotebook example - by @AnthonyAndroulakis in #169
New Methods:
- Add
set_colormap_labelmethod toVolumeclass - Add
set_volume_render_illuminationmethod toNiiVueclass - Add
set_high_resolution_capablemethod toNiiVueclass - Add
closemethod toNiiVueclass - Add
set_mesh_propertymethod toNiiVueclass - Add
load_mat_cap_texturemethod toNiiVueclass - Add
set_radiological_conventionmethod toNiiVueclass - Add
close_drawingmethod toNiiVueclass - Add
draw_undomethod toNiiVueclass - Add
set_slice_mmmethod toNiiVueclass - Add
remove_hazemethod toNiiVueclass - Add
move_crosshair_in_voxmethod toNiiVueclass - Add
draw_grow_cutmethod toNiiVueclass - Add
draw_otsumethod toNiiVueclass - Add
set_draw_colormapmethod toNiiVueclass - Add
colormap_from_keymethod toNiiVueclass - Add
set_drawing_enabledmethod toNiiVueclass - Add
set_pen_valuemethod toNiiVueclass
New Properties:
- Add
colormap_negativeproperty toVolumeclass - Add
colormap_labelproperty toVolumeclass - Add
mesh_shader_indexproperty toMeshclass - Add
colorbar_visibleproperty toMeshclass - Add
fiber_radius,fiber_length,fiber_dither,fiber_color,fiber_decimation_stride, andcolormapproperties toMeshclass - Add
clip_plane_depth_azi_elevproperty toNiiVueclass - Add
gradient_amount,gradient_opacity, andforce_device_pixel_ratiooptions toNiiVueclass - Add
crosshair_gapandatlas_outlineoptions toNiiVueclass
Documentation Updates:
- Add
closemethod to docs - Add
ColorMapandLUTclasses to docs
Utility Functions:
- Add
make_draw_lut,make_label_lutserialize_options, anddeserialize_optionsutility methods
🐞 Bug Fixes
- Update checks in
set_colormap_label(8c0a11e) - Fix drawing setup(194308a)
- Fix
colormap_labelimplementation - Fix
create_volumecolorbar range - Fix
set_render_azimuth_elevationby adding custom message handler - Fix order of mesh shader names in
build.js - Fix
Mesh.rgba255default value - Fix colormap functions to use
ColorMapclass for structure validation
View changes on GitHub
v2.2.1
🐞 Bug Fixes
- widget: Use anywidget as base class - by @AnthonyAndroulakis (c7de9)
View changes on GitHub
v2.2.0
Core
- Renamed modules (
_widget.py→widget.py, etc.) - by @christian-oreilly and @hanayik in #105 (7812824) - Shifted from name-based to ID-based system for models - by @AnthonyAndroulakis in #139 (e1eae5b)
- Update ipyniivue to use latest niivue version (as of now, 0.57.0) - by @AnthonyAndroulakis in #138 (1ad7e57) and #153 (4d0d0c0)
🚀 Features
- Created documentation site by @bcalford in #99 (4ae99ce) and @AnthonyAndroulakis in #150 (47a5667)
- Added
Drawingmodel and methods - by @bcalford in 04ebe9c - Added download_dataset - by @bcalford in 44487b9
- Add CI testing - by @christian-oreilly and @hanayik in #105 (7812824)
- Added
MeshLayermodel - by @AnthonyAndroulakis in #151 (ba4d21b) - Added event-based synchronization between frontend and backend and all Niivue event hooks - by @AnthonyAndroulakis in #145 (25c9d97)
- Niivue instance and display persistence across cells in Jupyter notebooks (each model points to 1 nv object) - by @AnthonyAndroulakis in #148 (42b36ec)
- Support drag-and-dropped data from frontend (
<fromfrontend>name placeholder) - by @AnthonyAndroulakis in #144 (2181a58) - New methods:
colormaps,add_colormap,set_colormap,set_selection_box_color,set_crosshair_color,set_crosshair_width,set_gamma,set_slice_type,set_clip_plane,set_render_azimuth_elevation,set_mesh_shader,mesh_shader_names- by @AnthonyAndroulakis in #152 (bbc7754)save_document,save_html,save_image, andsave_scene- by @bcalford in #124 (150ff1f)
- New properties:
nameinVolumeandMesh- by @AnthonyAndroulakis in #144 (2181a58)colormap_invertinVolume,Mesh, andMeshLayer- by @AnthonyAndroulakis in #152 (bbc7754)background_masks_overlaysinNiiVue- by @AnthonyAndroulakis in #152 (bbc7754)multiplanar_show_renderoption - by @AnthonyAndroulakis in #152 (bbc7754)frame4DinVolume- by @Jolinda and @christian-oreilly in #119 (70baed9)frame4DinMeshLayer- by @AnthonyAndroulakis in #152 (bbc7754)colorbar_visibleinMeshLayer- by @AnthonyAndroulakis in #154 (e44b1b6)
- New Constants:
ShowRender: Controls when the 3D render view is displayed (NEVER, ALWAYS, AUTO) - by @AnthonyAndroulakis in #152 (bbc7754)
📝 Added new examples
add_from_frontend.ipynb- by @AnthonyAndroulakis in #144 (2181a58)colormaps.ipynb,colormaps.mesh.ipynb,mask.ipynb, andmesh.4d.ipynb- by @AnthonyAndroulakis in #152 (bbc7754)drawing.ipynb- by @bcalford in c100924example_4d.ipynb- by @Jolinda and @christian-oreilly in #119 (70baed9)mesh_and_volume.ipynb- by @kolibril13 in cb6103amosaic.ipynb- by @Jolinda in #143 (13c9d70)on_event.ipynb- by @AnthonyAndroulakis in #145 (25c9d97)prototypes/meshes_(GIfTI, FreeSurfer, MZ3, OBJ, STL, legacy VTK).ipynb- by @kolibril13 in cb6103aprototypes/torso_regions.ipynb- by @kolibril13 in cb6103aprototypes/trajectory.ipynb- by @kolibril13 in cb6103asaving.ipynb- by @bcalford in #124 (150ff1f)