Skip to content

Commit

Permalink
Complex coordination port (#266)
Browse files Browse the repository at this point in the history
* Complex coordination port

* Lint

* Lint

* Rename functions

* Add docstrings for new functions

* Lint

* Implement link_views_by_dict
  • Loading branch information
keller-mark authored Sep 12, 2023
1 parent 6cd3505 commit 8a2b710
Show file tree
Hide file tree
Showing 6 changed files with 1,406 additions and 20 deletions.
168 changes: 168 additions & 0 deletions docs/notebooks/widget_imaging_beta.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"nbsphinx": "hidden"
},
"source": [
"# Vitessce Widget Tutorial"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Visualization of Multi-Modal Imaging Data\n",
"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."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"from vitessce import (\n",
" VitessceConfig,\n",
" Component as cm,\n",
" CoordinationType as ct,\n",
" OmeTiffWrapper,\n",
" MultiImageWrapper,\n",
" CoordinationLevel as CL,\n",
")\n",
"from os.path import join"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 1. Configure Vitessce\n",
"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."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"vc = VitessceConfig(schema_version=\"1.0.16\", name='Spraggins Multi-Modal', description='PAS + IMS + AF From https://portal.hubmapconsortium.org/browse/collection/6a6efd0c1a2681dc7d2faab8e4ab0bca')\n",
"dataset = vc.add_dataset(name='Spraggins').add_file(\n",
" 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",
" file_type=\"image.ome-tiff\",\n",
" coordination_values={\n",
" \"fileUid\": \"PAS\",\n",
" },\n",
")\n",
"\n",
"imageScopes = vc.add_coordination_by_dict({\n",
" \"imageLayer\": CL([\n",
" {\n",
" \"fileUid\": 'PAS',\n",
" \"spatialLayerOpacity\": 1,\n",
" \"spatialLayerVisible\": True,\n",
" \"photometricInterpretation\": 'RGB',\n",
" \"imageChannel\": CL([\n",
" {\n",
" \"spatialTargetC\": 0,\n",
" \"spatialChannelColor\": [255, 0, 0],\n",
" \"spatialChannelVisible\": True,\n",
" \"spatialChannelOpacity\": 1.0,\n",
" \"spatialChannelWindow\": [0, 255],\n",
" },\n",
" {\n",
" \"spatialTargetC\": 1,\n",
" \"spatialChannelColor\": [0, 255, 0],\n",
" \"spatialChannelVisible\": True,\n",
" \"spatialChannelOpacity\": 1.0,\n",
" \"spatialChannelWindow\": [0, 255],\n",
" },\n",
" {\n",
" \"spatialTargetC\": 2,\n",
" \"spatialChannelColor\": [0, 0, 255],\n",
" \"spatialChannelVisible\": True,\n",
" \"spatialChannelOpacity\": 1.0,\n",
" \"spatialChannelWindow\": [0, 255],\n",
" },\n",
" ]),\n",
" }\n",
" ])\n",
"})\n",
"\n",
"metaCoordinationScope = vc.add_meta_coordination()\n",
"metaCoordinationScope.use_coordination_by_dict(imageScopes)\n",
"\n",
"spatial = vc.add_view(\"spatialBeta\", dataset=dataset)\n",
"lc = vc.add_view(\"layerControllerBeta\", dataset=dataset)\n",
"\n",
"spatial.use_meta_coordination(metaCoordinationScope)\n",
"lc.use_meta_coordination(metaCoordinationScope)\n",
"\n",
"vc.layout(spatial | lc);"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 2. Create the Vitessce widget"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "a5efa92286df4ad58cf94cfb3d12b703",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"VitessceWidget(config={'version': '1.0.16', 'name': 'Spraggins Multi-Modal', 'description': 'PAS + IMS + AF Fr…"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"vw = vc.widget(custom_js_url='http://localhost:8000/packages/main/prod/dist/index.min.js')\n",
"vw"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"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.9.0"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Loading

0 comments on commit 8a2b710

Please sign in to comment.