Skip to content

Commit 8a2b710

Browse files
authored
Complex coordination port (#266)
* Complex coordination port * Lint * Lint * Rename functions * Add docstrings for new functions * Lint * Implement link_views_by_dict
1 parent 6cd3505 commit 8a2b710

File tree

6 files changed

+1406
-20
lines changed

6 files changed

+1406
-20
lines changed
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {
6+
"nbsphinx": "hidden"
7+
},
8+
"source": [
9+
"# Vitessce Widget Tutorial"
10+
]
11+
},
12+
{
13+
"cell_type": "markdown",
14+
"metadata": {},
15+
"source": [
16+
"# Visualization of Multi-Modal Imaging Data\n",
17+
"We visualize IMS, PAS, and AF imaging data overlaid from the Spraggins Lab of the Biomolecular Multimodal Imaging Center (BIOMC) at Vanderbilt University, uploaded to the HuBMAP data portal."
18+
]
19+
},
20+
{
21+
"cell_type": "code",
22+
"execution_count": 1,
23+
"metadata": {},
24+
"outputs": [],
25+
"source": [
26+
"from vitessce import (\n",
27+
" VitessceConfig,\n",
28+
" Component as cm,\n",
29+
" CoordinationType as ct,\n",
30+
" OmeTiffWrapper,\n",
31+
" MultiImageWrapper,\n",
32+
" CoordinationLevel as CL,\n",
33+
")\n",
34+
"from os.path import join"
35+
]
36+
},
37+
{
38+
"cell_type": "markdown",
39+
"metadata": {},
40+
"source": [
41+
"## 1. Configure Vitessce\n",
42+
"Set up the images from the three different assays, with the `use_physical_size_scaling` set to `True` so that the IMS image scales to the other images based on their physical sizes."
43+
]
44+
},
45+
{
46+
"cell_type": "code",
47+
"execution_count": 2,
48+
"metadata": {},
49+
"outputs": [],
50+
"source": [
51+
"vc = VitessceConfig(schema_version=\"1.0.16\", name='Spraggins Multi-Modal', description='PAS + IMS + AF From https://portal.hubmapconsortium.org/browse/collection/6a6efd0c1a2681dc7d2faab8e4ab0bca')\n",
52+
"dataset = vc.add_dataset(name='Spraggins').add_file(\n",
53+
" url='https://assets.hubmapconsortium.org/f4188a148e4c759092d19369d310883b/ometiff-pyramids/processedMicroscopy/VAN0006-LK-2-85-PAS_images/VAN0006-LK-2-85-PAS_registered.ome.tif?token=',\n",
54+
" file_type=\"image.ome-tiff\",\n",
55+
" coordination_values={\n",
56+
" \"fileUid\": \"PAS\",\n",
57+
" },\n",
58+
")\n",
59+
"\n",
60+
"imageScopes = vc.add_coordination_by_dict({\n",
61+
" \"imageLayer\": CL([\n",
62+
" {\n",
63+
" \"fileUid\": 'PAS',\n",
64+
" \"spatialLayerOpacity\": 1,\n",
65+
" \"spatialLayerVisible\": True,\n",
66+
" \"photometricInterpretation\": 'RGB',\n",
67+
" \"imageChannel\": CL([\n",
68+
" {\n",
69+
" \"spatialTargetC\": 0,\n",
70+
" \"spatialChannelColor\": [255, 0, 0],\n",
71+
" \"spatialChannelVisible\": True,\n",
72+
" \"spatialChannelOpacity\": 1.0,\n",
73+
" \"spatialChannelWindow\": [0, 255],\n",
74+
" },\n",
75+
" {\n",
76+
" \"spatialTargetC\": 1,\n",
77+
" \"spatialChannelColor\": [0, 255, 0],\n",
78+
" \"spatialChannelVisible\": True,\n",
79+
" \"spatialChannelOpacity\": 1.0,\n",
80+
" \"spatialChannelWindow\": [0, 255],\n",
81+
" },\n",
82+
" {\n",
83+
" \"spatialTargetC\": 2,\n",
84+
" \"spatialChannelColor\": [0, 0, 255],\n",
85+
" \"spatialChannelVisible\": True,\n",
86+
" \"spatialChannelOpacity\": 1.0,\n",
87+
" \"spatialChannelWindow\": [0, 255],\n",
88+
" },\n",
89+
" ]),\n",
90+
" }\n",
91+
" ])\n",
92+
"})\n",
93+
"\n",
94+
"metaCoordinationScope = vc.add_meta_coordination()\n",
95+
"metaCoordinationScope.use_coordination_by_dict(imageScopes)\n",
96+
"\n",
97+
"spatial = vc.add_view(\"spatialBeta\", dataset=dataset)\n",
98+
"lc = vc.add_view(\"layerControllerBeta\", dataset=dataset)\n",
99+
"\n",
100+
"spatial.use_meta_coordination(metaCoordinationScope)\n",
101+
"lc.use_meta_coordination(metaCoordinationScope)\n",
102+
"\n",
103+
"vc.layout(spatial | lc);"
104+
]
105+
},
106+
{
107+
"cell_type": "markdown",
108+
"metadata": {},
109+
"source": [
110+
"## 2. Create the Vitessce widget"
111+
]
112+
},
113+
{
114+
"cell_type": "code",
115+
"execution_count": 3,
116+
"metadata": {},
117+
"outputs": [
118+
{
119+
"data": {
120+
"application/vnd.jupyter.widget-view+json": {
121+
"model_id": "a5efa92286df4ad58cf94cfb3d12b703",
122+
"version_major": 2,
123+
"version_minor": 0
124+
},
125+
"text/plain": [
126+
"VitessceWidget(config={'version': '1.0.16', 'name': 'Spraggins Multi-Modal', 'description': 'PAS + IMS + AF Fr…"
127+
]
128+
},
129+
"execution_count": 3,
130+
"metadata": {},
131+
"output_type": "execute_result"
132+
}
133+
],
134+
"source": [
135+
"vw = vc.widget(custom_js_url='http://localhost:8000/packages/main/prod/dist/index.min.js')\n",
136+
"vw"
137+
]
138+
},
139+
{
140+
"cell_type": "code",
141+
"execution_count": null,
142+
"metadata": {},
143+
"outputs": [],
144+
"source": []
145+
}
146+
],
147+
"metadata": {
148+
"kernelspec": {
149+
"display_name": "Python 3 (ipykernel)",
150+
"language": "python",
151+
"name": "python3"
152+
},
153+
"language_info": {
154+
"codemirror_mode": {
155+
"name": "ipython",
156+
"version": 3
157+
},
158+
"file_extension": ".py",
159+
"mimetype": "text/x-python",
160+
"name": "python",
161+
"nbconvert_exporter": "python",
162+
"pygments_lexer": "ipython3",
163+
"version": "3.9.0"
164+
}
165+
},
166+
"nbformat": 4,
167+
"nbformat_minor": 4
168+
}

0 commit comments

Comments
 (0)