Skip to content

Commit

Permalink
Merge pull request #60 from the-virtual-brain/WID-223-new
Browse files Browse the repository at this point in the history
WID-223: Add ConnectivityWidget
  • Loading branch information
davidbacter01 authored Sep 19, 2023
2 parents a3cec0e + eeb6f56 commit 2437928
Show file tree
Hide file tree
Showing 17 changed files with 1,223 additions and 11 deletions.
138 changes: 138 additions & 0 deletions notebooks/Connectivity.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Demonstrate Connectivity Widget "
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"# from tvbwidgets.ui.connectivity_react.connectivity_widget import ConnectivityWidgetReact\n",
"# from tvb.datatypes.connectivity import Connectivity\n",
"\n",
"# connectivity = Connectivity.from_file() # defaults to connectivy_76.zip\n",
"\n",
"\n",
"# wid = ConnectivityWidgetReact(connectivity=connectivity)\n",
"# wid"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"19-09-2023 10:57:09 - DEBUG - tvbwidgets - Package is not fully installed\n",
"19-09-2023 10:57:09 - DEBUG - tvbwidgets - Version read from the internal package.json file\n",
"19-09-2023 10:57:09 - INFO - tvbwidgets - Version: 1.5.0\n",
"2023-09-19 10:57:15,882 - INFO - tvb.storage.h5.encryption.data_encryption_handler - Cannot import syncrypto library.\n",
"19-09-2023 10:57:15 - INFO - tvbwidgets.core.pse.parameters - ImportError: Dask dependency is not included, so this functionality won't be available\n",
"2023-09-19 10:57:16,010 - WARNING - tvb.basic.readers - File 'hemispheres' not found in ZIP.\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "b3a81813058645ecbe8abedd7dd6d17f",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"ConnectivityWidget(children=(VBox(children=(HTML(value='<h1>Connectivity - 76</h1>'), HBox(children=(Checkbox(…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"from tvbwidgets.api import ConnectivityWidget\n",
"from tvb.datatypes.connectivity import Connectivity\n",
"import pyvista as pv\n",
"import numpy as np\n",
"pv.set_jupyter_backend('pythreejs')\n",
"\n",
"conn = Connectivity.from_file() # defaults to connectivy_76.zip\n",
"conn.configure()\n",
"\n",
"wid = ConnectivityWidget(conn, default_active_tab='viewers') # default_active_tab can be any value between 'viewers'|'operations'|'both'\n",
"\n",
"display(wid)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<table>\n",
"<thead><h3>Connectivity</h3></thead>\n",
"<tbody>\n",
"\n",
"<tr><th></th><th style=\"text-align:left;width:80%\">value</th></tr>\n",
"<tr><td>Number of connections</td><td style=\"text-align:left;\"><pre>1560</pre></td></tr>\n",
"<tr><td>Number of regions</td><td style=\"text-align:left;\"><pre>76</pre></td></tr>\n",
"<tr><td>Undirected</td><td style=\"text-align:left;\"><pre>False</pre></td></tr>\n",
"<tr><td>areas</td><td style=\"text-align:left;\"><pre> [min, median, max] = [0, 2580.89, 10338.2] dtype = float64 shape = (76,)</pre></td></tr>\n",
"<tr><td>tract_lengths</td><td style=\"text-align:left;\"><pre> [min, median, max] = [0, 71.6635, 153.486] dtype = float64 shape = (76, 76)</pre></td></tr>\n",
"<tr><td>tract_lengths (connections)</td><td style=\"text-align:left;\"><pre> [min, median, max] = [0, 55.8574, 138.454] dtype = float64 shape = (1560,)</pre></td></tr>\n",
"<tr><td>tract_lengths-non-zero</td><td style=\"text-align:left;\"><pre> [min, median, max] = [4.93328, 74.0646, 153.486] dtype = float64 shape = (5402,)</pre></td></tr>\n",
"<tr><td>weights</td><td style=\"text-align:left;\"><pre> [min, median, max] = [0, 0, 3] dtype = float64 shape = (76, 76)</pre></td></tr>\n",
"<tr><td>weights-non-zero</td><td style=\"text-align:left;\"><pre> [min, median, max] = [0.00462632, 2, 3] dtype = float64 shape = (1560,)</pre></td></tr>\n",
"</tbody></table>"
],
"text/plain": [
"<tvb.datatypes.connectivity.Connectivity at 0x2f09c20e410>"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# replace None in the method below with the gid of the connectivity you wish to export\n",
"# if no gid is provided it will export the connectivity currently viewed\n",
"\n",
"new_connectivity = wid.get_connectivity(gid=None) \n",
"new_connectivity"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
2 changes: 1 addition & 1 deletion notebooks/HeadWidget.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
"version": "3.8.16"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tvb-widgets",
"version": "1.5.0",
"version": "1.6.0",
"description": "GUI widgets for EBRAINS showcases",
"homepage": "https://github.com/the-virtual-brain/tvb-widgets",
"license": "GPL-3.0-or-later",
Expand Down
20 changes: 11 additions & 9 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
colorcet
ebrains_drive
ipympl > 0.8.5
ipywidgets == 7.7.2
IPython <= 8.12
ipympl>0.8.5
ipywidgets==7.7.2
IPython<=8.12
joblib
mne >= 1.0
numpy <1.24
plotly == 5.14.0
mne>=1.0
numpy<1.24
plotly==5.14.0
pythreejs
pyvista == 0.37.0
tvb-library >= 2.5
pyvista==0.37.0
ipyreact==0.3.0
tvb-library>=2.5
tvb-framework
plotly-resampler
pyunicore
toml
traitlets>=5.7.1
toml
1 change: 1 addition & 0 deletions tvbwidgets/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# (c) 2022-2023, TVB Widgets Team
#

from .ui.connectivity_ipy.connectivity_widget import ConnectivityWidget
from .ui.phase_plane_widget import PhasePlaneWidget
from .ui.storage_widget import StorageWidget
from .ui.head_widget import HeadBrowser, HeadWidget, HeadWidgetConfig
Expand Down
Empty file.
19 changes: 19 additions & 0 deletions tvbwidgets/ui/connectivity_ipy/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
#
# "TheVirtualBrain - Widgets" package
#
# (c) 2022-2023, TVB Widgets Team
#
from dataclasses import dataclass
from numpy import ndarray


@dataclass
class ConnectivityConfig:
name: str = 'Connectivity'
style: str = 'Points'
points_color: str = 'Green'
edge_color: str = 'White'
light: bool = True
size = [500, 500] # [width, height]
point_size: int = 20
Loading

0 comments on commit 2437928

Please sign in to comment.