-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #60 from the-virtual-brain/WID-223-new
WID-223: Add ConnectivityWidget
- Loading branch information
Showing
17 changed files
with
1,223 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.