Attention: The EBRAINS IAM will be down Monday, the 21st July 2025, from 17.00 CEST (my timezone) for up to 1 hour. This will any affect services requiring an EBRAINS login, we apologise for any inconvenience caused.


Wiki source code of Widget 3D

Version 5.1 by paulapopa on 2022/03/30 15:20

Show last authors
1 TODO
2
3 == Purpose ==
4
5 It is a Jupyter widget intended for visualization of the 3D data available for a patient:
6
7 * surfaces of different types (cortex, face, skull, etc)
8 * connectivity region centers
9 * sensors locations (SEEG, MEG, EEG)
10
11 == Inputs ==
12
13 It supports the above data in the form of their corresponding TVB datatypes:
14
15 * Surface (CorticalSurface, FaceSurface, etc)
16 * Connectivity
17 * Sensors (SensorsInternal, SensorsMEG, SensorsEEG)
18
19 == Installation ==
20
21 (% class="box" %)
22 (((
23 pip install tvb-widgets
24 )))
25
26 == API usage ==
27
28 We need to first import the widget __API from tvbwidgets__// //package, together with the __TVB API __and the __display__ function:
29
30 (% class="box" %)
31 (((
32 import tvbwidgets.api as api
33
34 from tvb.simulator.lab import *
35
36 from IPython.core.display_functions import display
37 )))
38
39 Then, we instantiate the **ThreeDWidget** and a **FaceSurface** datatype that we want to visualize. Using the //**add_datatype**// method we add the surface to our widget and __display__ the widget:
40
41 (% class="box" %)
42 (((
43 widget_3d = api.ThreeDWidget()
44
45 face = surfaces.FaceSurface().from_file()
46
47 face.configure()
48
49 widget_3d.add_datatype(face)
50 display(widget_3d)
51 )))
52
53 {{html}}
54 <iframe src="https://drive.google.com/file/d/1Egp9Lk-HGMATc9em6Kw_jSHmybTD2vzM/preview" width="840" height="480" allow="autoplay"></iframe>
55 {{/html}}
56
57 Next, we can continue adding other datatypes to this widget, by calling //**add_datatype**// multiple times. A maximum of 10 datatypes are supported by this widget.
58
59 The **Config** object can be used to tweak the display options for each datatype.
60
61 In the code below, we add a **Connectivity** and SEEG **Sensors:**
62
63 (% class="box" %)
64 (((
65 conn = connectivity.Connectivity().from_file()
66
67 conn.configure()
68
69 widget_3d.add_datatype(conn)
70
71
72 seeg = sensors.SensorsInternal().from_file()
73
74 seeg.configure()
75
76 widget_3d.add_datatype(seeg, api.Config(name='SEEG'))
77 )))
78
79 We can also provide a **RegionMapping** to be used as colormap for a surface:
80
81 (% class="box" %)
82 (((
83 reg_map = region_mapping.RegionMapping.from_file()
84
85 config = api.Config(name='Cortex')
86
87 config.add_region_mapping_as_cmap(reg_map)
88
89
90 cortex = surfaces.CorticalSurface().from_file()
91
92 cortex.configure()
93
94 widget_3d.add_datatype(cortex, config)
95
96 {{html}}
97 <iframe src=" https://drive.google.com/file/d/1PXsxLqydNDDORIK85cQaEgGt9QdWLcC7/preview" width="840" height="480" allow="autoplay"></iframe>
98 {{/html}}
99 )))
Public

TVB Widgets