Note
Click here to download the full example code
Visualizing 3D results with Napari
This example demonstrates how to render a steady state result for a 3D scenario using napari.
Running such simulations is computationally expensive and can take a long time to complete. For this reason, we recommend running this simulation on an external machine, store the results in a file and then load them on your local machine for visualization.
Check the gallery example Save and load results to learn how to save and load results.
The following step downloads and loads a simulation executed on an external machine.
import pooch
import neurotechdevkit as ndk
URL = "https://neurotechdevkit.s3.us-west-2.amazonaws.com/result-scenario-2-3d-v4.tz"
known_hash = "919edd0f29bcc956a9c2b3c4c56c28af5495dcdbb93d2d4d7f89078827e6db59"
downloaded_file_path = pooch.retrieve(url=URL, known_hash=known_hash, progressbar=True)
result = ndk.load_result_from_disk(downloaded_file_path)
Out:
0%| | 0.00/451M [00:00<?, ?B/s]
0%| | 52.2k/451M [00:00<18:17, 411kB/s]
0%| | 279k/451M [00:00<06:12, 1.21MB/s]
0%| | 1.20M/451M [00:00<01:53, 3.95MB/s]
1%|▎ | 3.68M/451M [00:00<00:44, 10.0MB/s]
1%|▌ | 6.50M/451M [00:00<00:30, 14.4MB/s]
2%|▊ | 9.40M/451M [00:00<00:25, 17.1MB/s]
3%|█ | 12.3M/451M [00:00<00:23, 18.9MB/s]
3%|█▎ | 15.2M/451M [00:01<00:21, 20.3MB/s]
4%|█▌ | 18.3M/451M [00:01<00:20, 21.4MB/s]
5%|█▊ | 21.4M/451M [00:01<00:19, 22.2MB/s]
5%|██ | 24.5M/451M [00:01<00:18, 22.8MB/s]
6%|██▎ | 27.2M/451M [00:01<00:18, 22.3MB/s]
7%|██▌ | 30.4M/451M [00:01<00:18, 23.1MB/s]
7%|██▊ | 33.6M/451M [00:01<00:17, 23.6MB/s]
8%|███ | 36.6M/451M [00:01<00:17, 23.6MB/s]
9%|███▎ | 39.7M/451M [00:02<00:17, 23.9MB/s]
10%|███▌ | 42.9M/451M [00:02<00:16, 24.1MB/s]
10%|███▉ | 46.1M/451M [00:02<00:16, 24.4MB/s]
11%|████▏ | 49.3M/451M [00:02<00:16, 24.5MB/s]
12%|████▍ | 52.5M/451M [00:02<00:16, 24.6MB/s]
12%|████▋ | 55.7M/451M [00:02<00:16, 24.7MB/s]
13%|████▉ | 58.8M/451M [00:02<00:14, 26.4MB/s]
14%|█████▏ | 61.5M/451M [00:02<00:15, 25.2MB/s]
14%|█████▍ | 64.0M/451M [00:03<00:15, 24.4MB/s]
15%|█████▋ | 66.8M/451M [00:03<00:15, 24.1MB/s]
15%|█████▊ | 69.7M/451M [00:03<00:15, 25.3MB/s]
16%|██████ | 72.2M/451M [00:03<00:15, 24.5MB/s]
17%|██████▎ | 74.8M/451M [00:03<00:15, 24.2MB/s]
17%|██████▌ | 78.0M/451M [00:03<00:15, 24.6MB/s]
18%|██████▊ | 81.2M/451M [00:03<00:13, 26.6MB/s]
19%|███████ | 83.9M/451M [00:03<00:14, 25.0MB/s]
19%|███████▎ | 86.4M/451M [00:03<00:15, 23.8MB/s]
20%|███████▍ | 89.0M/451M [00:04<00:14, 24.4MB/s]
20%|███████▋ | 91.7M/451M [00:04<00:14, 25.0MB/s]
21%|███████▉ | 94.2M/451M [00:04<00:15, 23.7MB/s]
21%|████████▏ | 96.9M/451M [00:04<00:14, 24.5MB/s]
22%|████████▎ | 99.3M/451M [00:04<00:14, 24.6MB/s]
23%|████████▊ | 102M/451M [00:04<00:14, 23.5MB/s]
23%|█████████ | 105M/451M [00:04<00:14, 24.7MB/s]
24%|█████████▎ | 107M/451M [00:04<00:13, 25.4MB/s]
24%|█████████▌ | 110M/451M [00:04<00:14, 23.9MB/s]
25%|█████████▋ | 113M/451M [00:04<00:13, 24.6MB/s]
26%|█████████▉ | 115M/451M [00:05<00:13, 25.1MB/s]
26%|██████████▏ | 118M/451M [00:05<00:14, 23.8MB/s]
27%|██████████▍ | 120M/451M [00:05<00:13, 24.3MB/s]
27%|██████████▋ | 123M/451M [00:05<00:12, 25.3MB/s]
28%|██████████▊ | 126M/451M [00:05<00:13, 23.7MB/s]
28%|███████████ | 128M/451M [00:05<00:13, 24.2MB/s]
29%|███████████▎ | 131M/451M [00:05<00:13, 24.6MB/s]
30%|███████████▌ | 133M/451M [00:05<00:13, 24.0MB/s]
30%|███████████▋ | 136M/451M [00:05<00:12, 24.3MB/s]
31%|███████████▉ | 139M/451M [00:06<00:12, 25.2MB/s]
31%|████████████▏ | 141M/451M [00:06<00:12, 23.9MB/s]
32%|████████████▍ | 144M/451M [00:06<00:12, 24.0MB/s]
32%|████████████▋ | 146M/451M [00:06<00:12, 24.5MB/s]
33%|████████████▊ | 149M/451M [00:06<00:12, 24.3MB/s]
34%|█████████████ | 151M/451M [00:06<00:12, 24.6MB/s]
34%|█████████████▎ | 154M/451M [00:06<00:12, 24.2MB/s]
35%|█████████████▌ | 156M/451M [00:06<00:12, 24.1MB/s]
35%|█████████████▋ | 159M/451M [00:06<00:11, 24.8MB/s]
36%|█████████████▉ | 162M/451M [00:07<00:11, 24.2MB/s]
36%|██████████████▏ | 164M/451M [00:07<00:11, 24.0MB/s]
37%|██████████████▍ | 167M/451M [00:07<00:11, 24.8MB/s]
38%|██████████████▋ | 169M/451M [00:07<00:11, 24.1MB/s]
38%|██████████████▊ | 172M/451M [00:07<00:11, 24.0MB/s]
39%|███████████████ | 175M/451M [00:07<00:11, 24.6MB/s]
39%|███████████████▎ | 177M/451M [00:07<00:11, 24.2MB/s]
40%|███████████████▌ | 179M/451M [00:07<00:11, 24.0MB/s]
40%|███████████████▋ | 182M/451M [00:07<00:10, 24.7MB/s]
41%|███████████████▉ | 185M/451M [00:07<00:10, 24.3MB/s]
41%|████████████████▏ | 187M/451M [00:08<00:10, 24.5MB/s]
42%|████████████████▍ | 190M/451M [00:08<00:10, 24.2MB/s]
43%|████████████████▌ | 192M/451M [00:08<00:10, 24.0MB/s]
43%|████████████████▊ | 195M/451M [00:08<00:10, 24.7MB/s]
44%|█████████████████ | 197M/451M [00:08<00:10, 24.0MB/s]
44%|█████████████████▎ | 200M/451M [00:08<00:10, 23.9MB/s]
45%|█████████████████▍ | 202M/451M [00:08<00:10, 24.6MB/s]
45%|█████████████████▋ | 205M/451M [00:08<00:10, 24.3MB/s]
46%|█████████████████▉ | 207M/451M [00:08<00:10, 23.8MB/s]
47%|██████████████████▏ | 210M/451M [00:09<00:09, 24.9MB/s]
47%|██████████████████▍ | 213M/451M [00:09<00:09, 24.6MB/s]
48%|██████████████████▌ | 215M/451M [00:09<00:09, 24.9MB/s]
48%|██████████████████▊ | 218M/451M [00:09<00:09, 24.9MB/s]
49%|███████████████████ | 220M/451M [00:09<00:09, 24.4MB/s]
49%|███████████████████▎ | 223M/451M [00:09<00:09, 25.2MB/s]
50%|███████████████████▌ | 226M/451M [00:09<00:08, 25.1MB/s]
51%|███████████████████▋ | 228M/451M [00:09<00:08, 25.2MB/s]
51%|███████████████████▉ | 231M/451M [00:09<00:08, 25.0MB/s]
52%|████████████████████▏ | 233M/451M [00:09<00:08, 24.6MB/s]
52%|████████████████████▍ | 236M/451M [00:10<00:08, 25.4MB/s]
53%|████████████████████▌ | 238M/451M [00:10<00:08, 25.2MB/s]
53%|████████████████████▊ | 241M/451M [00:10<00:08, 25.3MB/s]
54%|█████████████████████ | 244M/451M [00:10<00:08, 25.0MB/s]
55%|█████████████████████▎ | 246M/451M [00:10<00:08, 24.6MB/s]
55%|█████████████████████▌ | 249M/451M [00:10<00:07, 25.4MB/s]
56%|█████████████████████▋ | 251M/451M [00:10<00:07, 25.1MB/s]
56%|█████████████████████▉ | 254M/451M [00:10<00:07, 25.2MB/s]
57%|██████████████████████▏ | 256M/451M [00:10<00:07, 25.0MB/s]
57%|██████████████████████▍ | 259M/451M [00:10<00:07, 24.7MB/s]
58%|██████████████████████▌ | 262M/451M [00:11<00:07, 25.5MB/s]
59%|██████████████████████▊ | 264M/451M [00:11<00:07, 25.1MB/s]
59%|███████████████████████ | 267M/451M [00:11<00:07, 25.2MB/s]
60%|███████████████████████▎ | 269M/451M [00:11<00:07, 25.0MB/s]
60%|███████████████████████▍ | 272M/451M [00:11<00:07, 24.6MB/s]
61%|███████████████████████▋ | 275M/451M [00:11<00:06, 25.4MB/s]
61%|███████████████████████▉ | 277M/451M [00:11<00:06, 25.1MB/s]
62%|████████████████████████▏ | 280M/451M [00:11<00:06, 25.1MB/s]
63%|████████████████████████▍ | 282M/451M [00:11<00:06, 25.2MB/s]
63%|████████████████████████▌ | 285M/451M [00:11<00:06, 24.7MB/s]
64%|████████████████████████▊ | 288M/451M [00:12<00:06, 25.6MB/s]
64%|█████████████████████████ | 290M/451M [00:12<00:06, 25.2MB/s]
65%|█████████████████████████▎ | 293M/451M [00:12<00:06, 25.2MB/s]
65%|█████████████████████████▌ | 295M/451M [00:12<00:06, 25.3MB/s]
66%|█████████████████████████▋ | 298M/451M [00:12<00:06, 24.9MB/s]
67%|█████████████████████████▉ | 300M/451M [00:12<00:05, 25.7MB/s]
67%|██████████████████████████▏ | 303M/451M [00:12<00:05, 25.1MB/s]
68%|██████████████████████████▍ | 306M/451M [00:12<00:05, 24.9MB/s]
68%|██████████████████████████▋ | 308M/451M [00:12<00:05, 25.2MB/s]
69%|██████████████████████████▊ | 311M/451M [00:13<00:05, 25.0MB/s]
69%|███████████████████████████ | 313M/451M [00:13<00:05, 25.8MB/s]
70%|███████████████████████████▎ | 316M/451M [00:13<00:05, 25.2MB/s]
71%|███████████████████████████▌ | 319M/451M [00:13<00:05, 24.9MB/s]
71%|███████████████████████████▊ | 321M/451M [00:13<00:05, 25.5MB/s]
72%|███████████████████████████▉ | 324M/451M [00:13<00:05, 24.9MB/s]
72%|████████████████████████████▏ | 327M/451M [00:13<00:04, 25.9MB/s]
73%|████████████████████████████▍ | 329M/451M [00:13<00:04, 25.4MB/s]
74%|████████████████████████████▋ | 332M/451M [00:13<00:04, 24.9MB/s]
74%|████████████████████████████▉ | 335M/451M [00:13<00:04, 25.6MB/s]
75%|█████████████████████████████▏ | 337M/451M [00:14<00:04, 25.0MB/s]
75%|█████████████████████████████▍ | 340M/451M [00:14<00:04, 25.7MB/s]
76%|█████████████████████████████▌ | 342M/451M [00:14<00:04, 25.3MB/s]
76%|█████████████████████████████▊ | 345M/451M [00:14<00:04, 25.3MB/s]
77%|██████████████████████████████ | 348M/451M [00:14<00:04, 25.2MB/s]
78%|██████████████████████████████▎ | 350M/451M [00:14<00:04, 25.1MB/s]
78%|██████████████████████████████▍ | 353M/451M [00:14<00:03, 25.4MB/s]
79%|██████████████████████████████▋ | 355M/451M [00:14<00:03, 25.2MB/s]
79%|██████████████████████████████▉ | 358M/451M [00:14<00:03, 25.7MB/s]
80%|███████████████████████████████▏ | 361M/451M [00:14<00:03, 25.5MB/s]
80%|███████████████████████████████▍ | 363M/451M [00:15<00:03, 25.5MB/s]
81%|███████████████████████████████▌ | 366M/451M [00:15<00:03, 25.5MB/s]
82%|███████████████████████████████▊ | 368M/451M [00:15<00:03, 24.9MB/s]
82%|████████████████████████████████ | 371M/451M [00:15<00:03, 25.6MB/s]
83%|████████████████████████████████▎ | 373M/451M [00:15<00:03, 25.1MB/s]
83%|████████████████████████████████▌ | 376M/451M [00:15<00:02, 25.7MB/s]
84%|████████████████████████████████▋ | 379M/451M [00:15<00:02, 25.5MB/s]
85%|████████████████████████████████▉ | 381M/451M [00:15<00:02, 24.9MB/s]
85%|█████████████████████████████████▏ | 384M/451M [00:15<00:02, 25.5MB/s]
86%|█████████████████████████████████▍ | 387M/451M [00:16<00:02, 25.0MB/s]
86%|█████████████████████████████████▋ | 389M/451M [00:16<00:02, 25.7MB/s]
87%|█████████████████████████████████▉ | 392M/451M [00:16<00:02, 25.6MB/s]
87%|██████████████████████████████████ | 394M/451M [00:16<00:02, 25.3MB/s]
88%|██████████████████████████████████▎ | 397M/451M [00:16<00:02, 25.6MB/s]
89%|██████████████████████████████████▌ | 400M/451M [00:16<00:02, 24.9MB/s]
89%|██████████████████████████████████▊ | 402M/451M [00:16<00:01, 25.7MB/s]
90%|███████████████████████████████████ | 405M/451M [00:16<00:01, 25.3MB/s]
90%|███████████████████████████████████▏ | 408M/451M [00:16<00:01, 25.6MB/s]
91%|███████████████████████████████████▍ | 410M/451M [00:16<00:01, 25.4MB/s]
91%|███████████████████████████████████▋ | 413M/451M [00:17<00:01, 25.2MB/s]
92%|███████████████████████████████████▉ | 415M/451M [00:17<00:01, 25.4MB/s]
93%|████████████████████████████████████▏ | 418M/451M [00:17<00:01, 25.3MB/s]
93%|████████████████████████████████████▎ | 421M/451M [00:17<00:01, 25.7MB/s]
94%|████████████████████████████████████▌ | 423M/451M [00:17<00:01, 25.6MB/s]
94%|████████████████████████████████████▊ | 426M/451M [00:17<00:00, 25.5MB/s]
95%|█████████████████████████████████████ | 428M/451M [00:17<00:00, 25.6MB/s]
96%|█████████████████████████████████████▎ | 431M/451M [00:17<00:00, 25.7MB/s]
96%|█████████████████████████████████████▍ | 434M/451M [00:17<00:00, 25.6MB/s]
97%|█████████████████████████████████████▋ | 436M/451M [00:17<00:00, 25.6MB/s]
97%|█████████████████████████████████████▉ | 439M/451M [00:18<00:00, 25.7MB/s]
98%|██████████████████████████████████████▏| 441M/451M [00:18<00:00, 25.7MB/s]
98%|██████████████████████████████████████▎| 444M/451M [00:18<00:00, 25.6MB/s]
99%|██████████████████████████████████████▌| 446M/451M [00:18<00:00, 25.7MB/s]
100%|██████████████████████████████████████▊| 449M/451M [00:18<00:00, 26.0MB/s]
0%| | 0.00/451M [00:00<?, ?B/s]
100%|███████████████████████████████████████| 451M/451M [00:00<00:00, 1.40TB/s]
Recreating the scenario for the result from saved metadata...
In order to render the 3D results you will need to install
Install napari
via pip:
Note for Mac M1 users: Qt5 does not support Mac M1, so you will need to install the Qt6 backend instead:
You can also follow the napari
installation instructions:
link.
try:
import napari # noqa: F401
assert isinstance(result, ndk.results.SteadyStateResult3D)
result.render_steady_state_amplitudes_3d()
except ImportError:
print(
"napari has not been installed. Please install it with: pip install napari[all]"
)
Out:
If you have napari installed you should see an output like the following:
Opening the napari viewer. The window might not show up on top of your notebook;
look through your open applications if it does not.
If you have napari installed you should have been able to see an image like the following:
Total running time of the script: ( 0 minutes 31.002 seconds)
Download Python source code: plot_3d.py