Skip to content

Commit

Permalink
Merge pull request #100 from bcalford/main
Browse files Browse the repository at this point in the history
Added back pre commit
  • Loading branch information
bcalford authored Dec 2, 2024
2 parents 9d70d23 + dc9c08d commit 3b9247e
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 65 deletions.
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
repos:
- repo: https://github.com/srstevenson/nb-clean
rev: 4.0.1
hooks:
- id: nb-clean
args:
- --remove-empty-cells
- --
4 changes: 2 additions & 2 deletions examples/additive_voxels.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"outputs": [],
"source": [
"!mkdir -p ../images/\n",
"path=\"https://github.com/niivue/niivue/raw/main/demos/images/\"\n",
"path = \"https://github.com/niivue/niivue/raw/main/demos/images/\"\n",
"!wget {path}narps-4735_50GV-hypo1_unthresh.nii.gz -P ../images/\n",
"!wget {path}narps-4965_9U7M-hypo1_unthresh.nii.gz -P ../images/\n",
"!wget {path}mni152.nii.gz -P ../images/"
Expand All @@ -24,7 +24,7 @@
"# based on https://niivue.github.io/niivue/features/additive.voxels.html\n",
"\n",
"volumes = [\n",
" { \"path\": \"../images/mni152.nii.gz\" },\n",
" {\"path\": \"../images/mni152.nii.gz\"},\n",
" {\n",
" \"path\": \"../images/narps-4965_9U7M-hypo1_unthresh.nii.gz\",\n",
" \"colormap\": \"red\",\n",
Expand Down
25 changes: 16 additions & 9 deletions examples/basic_multiplanar.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"outputs": [],
"source": [
"!mkdir -p ../images/\n",
"path=\"https://github.com/niivue/niivue/raw/main/demos/images/\"\n",
"path = \"https://github.com/niivue/niivue/raw/main/demos/images/\"\n",
"!wget {path}mni152.nii.gz -P ../images/\n",
"!wget {path}hippo.nii.gz -P ../images/"
]
Expand All @@ -23,11 +23,18 @@
"# based on https://niivue.github.io/niivue/features/basic.multiplanar.html\n",
"\n",
"volumes = [\n",
" { \"path\": \"../images/mni152.nii.gz\", \"colormap\": \"gray\",\n",
" \"visible\": True, \"opacity\": 1.0 },\n",
" { \"path\": \"../images/hippo.nii.gz\", \"colormap\": \"red\",\n",
" \"visible\": True, \"opacity\": 1 },\n",
"\n",
" {\n",
" \"path\": \"../images/mni152.nii.gz\",\n",
" \"colormap\": \"gray\",\n",
" \"visible\": True,\n",
" \"opacity\": 1.0,\n",
" },\n",
" {\n",
" \"path\": \"../images/hippo.nii.gz\",\n",
" \"colormap\": \"red\",\n",
" \"visible\": True,\n",
" \"opacity\": 1,\n",
" },\n",
"]\n",
"nv = NiiVue(slice_type=SliceType.MULTIPLANAR)\n",
"nv.load_volumes(volumes)\n",
Expand All @@ -51,9 +58,9 @@
"outputs": [],
"source": [
"nv.show_3d_crosshair = True\n",
"nv.crosshair_color = [0,1,1,1]\n",
"nv.back_color = [1,1,1,1]\n",
"nv.clip_plane_color = [0,1,1,1]\n",
"nv.crosshair_color = [0, 1, 1, 1]\n",
"nv.back_color = [1, 1, 1, 1]\n",
"nv.clip_plane_color = [0, 1, 1, 1]\n",
"nv.is_colorbar = True\n",
"nv.view_mode_hot_key = \"KeyN\""
]
Expand Down
26 changes: 16 additions & 10 deletions examples/example_sideview.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
],
"source": [
"!mkdir -p ../images/\n",
"path=\"https://github.com/niivue/niivue/raw/main/demos/images/\"\n",
"path = \"https://github.com/niivue/niivue/raw/main/demos/images/\"\n",
"!wget {path}mni152.nii.gz -P ../images/\n",
"!wget {path}hippo.nii.gz -P ../images/"
]
Expand All @@ -158,27 +158,33 @@
"from ipyniivue import NiiVue, SliceType\n",
"\n",
"volumes = [\n",
" { \"path\": \"../images/mni152.nii.gz\", \"colormap\": \"gray\",\n",
" \"visible\": True, \"opacity\": 1.0 },\n",
" { \"path\": \"../images/hippo.nii.gz\", \"colormap\": \"red\",\n",
" \"visible\": True, \"opacity\": 1 },\n",
"\n",
" {\n",
" \"path\": \"../images/mni152.nii.gz\",\n",
" \"colormap\": \"gray\",\n",
" \"visible\": True,\n",
" \"opacity\": 1.0,\n",
" },\n",
" {\n",
" \"path\": \"../images/hippo.nii.gz\",\n",
" \"colormap\": \"red\",\n",
" \"visible\": True,\n",
" \"opacity\": 1,\n",
" },\n",
"]\n",
"nv = NiiVue(slice_type=SliceType.MULTIPLANAR)\n",
"nv.load_volumes(volumes)\n",
"\n",
"\n",
"\n",
"app = JupyterFrontEnd()\n",
"split_panel = SplitPanel()\n",
"\n",
"# add the widgets to the split panel\n",
"split_panel.children = [nv]\n",
"\n",
"split_panel.title.label = 'NiiVue SplitPanel'\n",
"split_panel.title.icon_class = 'jp-PythonIcon'\n",
"split_panel.title.label = \"NiiVue SplitPanel\"\n",
"split_panel.title.icon_class = \"jp-PythonIcon\"\n",
"split_panel.title.closable = True\n",
"app.shell.add(split_panel, 'main', { 'mode': 'split-right' })\n",
"app.shell.add(split_panel, \"main\", {\"mode\": \"split-right\"})\n",
"print(\"Split panel created!\")"
]
},
Expand Down
5 changes: 2 additions & 3 deletions examples/mesh_layers.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"outputs": [],
"source": [
"!mkdir -p ../images/\n",
"path=\"https://github.com/niivue/niivue/raw/main/demos/images/\"\n",
"path = \"https://github.com/niivue/niivue/raw/main/demos/images/\"\n",
"!wget {path}BrainMesh_ICBM152.lh.mz3 -P ../images/\n",
"!wget {path}CIT168.mz3 -P ../images/\n",
"!wget {path}BrainMesh_ICBM152.lh.motor.mz3 -P ../images/"
Expand All @@ -24,8 +24,7 @@
"from ipyniivue import NiiVue\n",
"\n",
"nv = NiiVue(\n",
" show_3d_crosshair=True, back_color=(1, 1, 1, 1),\n",
" mesh_x_ray=0.3, is_colorbar=True\n",
" show_3d_crosshair=True, back_color=(1, 1, 1, 1), mesh_x_ray=0.3, is_colorbar=True\n",
")\n",
"\n",
"mesh_layer = {\n",
Expand Down
79 changes: 41 additions & 38 deletions examples/widgets.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"outputs": [],
"source": [
"!mkdir -p ../images/\n",
"path=\"https://github.com/niivue/niivue/raw/main/demos/images/\"\n",
"path = \"https://github.com/niivue/niivue/raw/main/demos/images/\"\n",
"!wget {path}mni152.nii.gz -P ../images/\n",
"!wget {path}hippo.nii.gz -P ../images/"
]
Expand All @@ -25,10 +25,18 @@
"from ipyniivue import NiiVue, SliceType, WidgetObserver\n",
"\n",
"volumes = [\n",
" { \"path\": \"../images/mni152.nii.gz\", \"colormap\": \"gray\",\n",
" \"visible\": True, \"opacity\": 1.0 },\n",
" { \"path\": \"../images/hippo.nii.gz\", \"colormap\": \"red\",\n",
" \"visible\": True, \"opacity\": 1.0 },\n",
" {\n",
" \"path\": \"../images/mni152.nii.gz\",\n",
" \"colormap\": \"gray\",\n",
" \"visible\": True,\n",
" \"opacity\": 1.0,\n",
" },\n",
" {\n",
" \"path\": \"../images/hippo.nii.gz\",\n",
" \"colormap\": \"red\",\n",
" \"visible\": True,\n",
" \"opacity\": 1.0,\n",
" },\n",
"]\n",
"\n",
"nv = NiiVue(slice_type=SliceType.MULTIPLANAR)\n",
Expand All @@ -37,74 +45,69 @@
"widgetArray = []\n",
"\n",
"widget_slice_type = {\n",
"\n",
" \"widget\": ipywidgets.RadioButtons(\n",
" options=[('Axial', 0), ('Coronal', 1), ('Sagittal', 2),\n",
" ('Multiplanar', 3), ('Render', 4)],\n",
" options=[\n",
" (\"Axial\", 0),\n",
" (\"Coronal\", 1),\n",
" (\"Sagittal\", 2),\n",
" (\"Multiplanar\", 3),\n",
" (\"Render\", 4),\n",
" ],\n",
" value=3,\n",
" description='Slice Type:'),\n",
"\n",
" description=\"Slice Type:\",\n",
" ),\n",
" \"object\": nv,\n",
"\n",
" \"attribute\": \"slice_type\"\n",
" \"attribute\": \"slice_type\",\n",
"}\n",
"widgetArray.append(widget_slice_type)\n",
"\n",
"widget_scan_opacity = {\n",
"\n",
" \"widget\": ipywidgets.FloatSlider(\n",
" value=1.0,\n",
" min=0.0,\n",
" max=1.0,\n",
" step=0.1,\n",
" description='Scan Opacity:',\n",
" orientation='horizontal'),\n",
"\n",
" description=\"Scan Opacity:\",\n",
" orientation=\"horizontal\",\n",
" ),\n",
" \"object\": nv.volumes[0],\n",
"\n",
" \"attribute\": \"opacity\"\n",
" \"attribute\": \"opacity\",\n",
"}\n",
"widgetArray.append(widget_scan_opacity)\n",
"\n",
"widget_hippo_opacity = {\n",
"\n",
" \"widget\": ipywidgets.FloatSlider(\n",
" value=1.0,\n",
" min=0.0,\n",
" max=1.0,\n",
" step=0.1,\n",
" description='Hippocampus Opacity:',\n",
" orientation='horizontal'),\n",
"\n",
" description=\"Hippocampus Opacity:\",\n",
" orientation=\"horizontal\",\n",
" ),\n",
" \"object\": nv.volumes[1],\n",
"\n",
" \"attribute\": \"opacity\"\n",
" \"attribute\": \"opacity\",\n",
"}\n",
"widgetArray.append(widget_hippo_opacity)\n",
"\n",
"widget_scan_colormap = {\n",
"\n",
" \"widget\": ipywidgets.Select(\n",
" options=['Gray', 'Red', 'Blue', 'Green'],\n",
" value='Gray',\n",
" description='Scan Colormap:'),\n",
"\n",
" options=[\"Gray\", \"Red\", \"Blue\", \"Green\"],\n",
" value=\"Gray\",\n",
" description=\"Scan Colormap:\",\n",
" ),\n",
" \"object\": nv.volumes[0],\n",
"\n",
" \"attribute\": \"colormap\"\n",
" \"attribute\": \"colormap\",\n",
"}\n",
"widgetArray.append(widget_scan_colormap)\n",
"\n",
"widget_hippo_colormap = {\n",
"\n",
" \"widget\": ipywidgets.Select(\n",
" options=['Red', 'Blue', 'Green', 'Gray'],\n",
" value='Red',\n",
" description='Hippocampus Colormap:'),\n",
"\n",
" options=[\"Red\", \"Blue\", \"Green\", \"Gray\"],\n",
" value=\"Red\",\n",
" description=\"Hippocampus Colormap:\",\n",
" ),\n",
" \"object\": nv.volumes[1],\n",
"\n",
" \"attribute\": \"colormap\"\n",
" \"attribute\": \"colormap\",\n",
"}\n",
"widgetArray.append(widget_hippo_colormap)\n",
"\n",
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion scripts/generate_options_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def get_value(value: typing.Any):
return repr(value)


def generate_mixin(options: typing.Dict[str, typing.Any]):
def generate_mixin(options: typing.dict[str, typing.Any]):
lines = [
"# This file is automatically generated by scripts/generate_options_mixin.py",
"# Do not edit this file directly",
Expand Down
2 changes: 1 addition & 1 deletion src/ipyniivue/_constants.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import enum

__all__ = [
"SliceType",
"DragMode",
"MuliplanarType",
"SliceType",
]


Expand Down
1 change: 1 addition & 0 deletions src/ipyniivue/_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ def meshes(self):
"""Returns the list of meshes."""
return list(self._meshes)


class WidgetObserver:
"""Sets an observed for `widget` on the `attribute` of `object`."""

Expand Down

0 comments on commit 3b9247e

Please sign in to comment.