Skip to content

Commit

Permalink
Update hiball winterschool 2023 to Julich 3.1 and siirba-python v1.0a17
Browse files Browse the repository at this point in the history
  • Loading branch information
AhmetNSimsek committed Oct 24, 2024
1 parent 24be13e commit 926e2c3
Showing 1 changed file with 33 additions and 22 deletions.
55 changes: 33 additions & 22 deletions HIBALL-winterschool-2023.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"source": [
"import siibra\n",
"from packaging.version import Version\n",
"assert Version(siibra.__version__) >= Version('1.0a14')\n",
"assert Version(siibra.__version__) >= Version('1.0a17')\n",
"\n",
"import matplotlib\n",
"from nilearn import plotting\n",
Expand Down Expand Up @@ -73,7 +73,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"id": "ecd71f02",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -130,7 +130,7 @@
"metadata": {},
"outputs": [],
"source": [
"siibra.parcellations.JULICH_BRAIN_CYTOARCHITECTONIC_ATLAS_V3_0_3"
"siibra.parcellations['julich']"
]
},
{
Expand Down Expand Up @@ -271,7 +271,7 @@
"outputs": [],
"source": [
"julich_brain = (\n",
" siibra.parcellations.JULICH_BRAIN_CYTOARCHITECTONIC_ATLAS_V3_0_3\n",
" siibra.parcellations['julich']\n",
")\n",
"julich_mpm = julich_brain.get_map(\n",
" space=siibra.spaces.MNI_152_ICBM_2009C_NONLINEAR_ASYMMETRIC\n",
Expand Down Expand Up @@ -650,7 +650,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 30,
"id": "1e6834c0",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -827,7 +827,7 @@
"outputs": [],
"source": [
"features = siibra.features.get(\n",
" siibra.parcellations.get('julich 2.9'),\n",
" siibra.parcellations.get('julich'),\n",
" siibra.features.connectivity.StreamlineCounts\n",
")\n",
"f = features[0]"
Expand Down Expand Up @@ -869,8 +869,8 @@
"metadata": {},
"outputs": [],
"source": [
"sc_hcp_000 = f.get_element('000')\n",
"sc_hcp_000"
"sc_hcp_0 = f.get_element('210415')\n",
"sc_hcp_0"
]
},
{
Expand All @@ -881,7 +881,7 @@
"outputs": [],
"source": [
"# we can also plot the matrix\n",
"sc_hcp_000.plot(logscale=True)"
"sc_hcp_0.plot(logscale=True)"
]
},
{
Expand All @@ -899,9 +899,9 @@
"metadata": {},
"outputs": [],
"source": [
"node_coords = sc_hcp_000.compute_centroids(space='mni152')\n",
"node_coords = sc_hcp_0.compute_centroids(space='mni152')\n",
"plotting.view_connectome(\n",
" adjacency_matrix=sc_hcp_000.data,\n",
" adjacency_matrix=sc_hcp_0.data,\n",
" node_coords=node_coords,\n",
" edge_threshold=\"99%\",\n",
" node_size=3, colorbar=False,\n",
Expand Down Expand Up @@ -961,7 +961,7 @@
" siibra.get_region('julich', '4p left'),\n",
" siibra.features.cellular.BigBrainIntensityProfile\n",
")\n",
"print(len(features))\n",
"print(len(features[0]))\n",
"f = features[0]"
]
},
Expand All @@ -985,6 +985,16 @@
"f.plot()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2ed9f6a5",
"metadata": {},
"outputs": [],
"source": [
"f[0].plot()"
]
},
{
"cell_type": "markdown",
"id": "fc1eacea",
Expand Down Expand Up @@ -1029,11 +1039,11 @@
"outputs": [],
"source": [
"# let's fetch the 1 micron section at a lower resolutioin, and display in 3D space.\n",
"section1402 = features[3]\n",
"section1402 = [f for f in features if \"#1402\" in f.name][0]\n",
"plotting.plot_img(\n",
" section1402.fetch(),\n",
" bg_img=bigbrain_template.fetch(),\n",
" title=\"#1402\",\n",
" title=section1402.name,\n",
" cmap='gray'\n",
")"
]
Expand All @@ -1045,13 +1055,14 @@
"metadata": {},
"outputs": [],
"source": [
"# Let's fetch a crop inside hoc5 at full resolution.\n",
"# we intersect the bounding box of hoc5l and the section\n",
"hoc5_bbox = hoc5l.get_boundingbox('bigbrain').intersection(section1402)\n",
"print(f\"Size of the bounding box: {hoc5_bbox.shape}\")\n",
"# Let's fetch a crop inside hoc5 at full resolution. We intersect the bounding box of hoc5l and the section\n",
"# (Since hoc5l is not mapped in bigbrain, we don't restrict the space so that\n",
"# siibra gets the bounding box from a map on another space and warps it to BigBrain space automatically)\n",
"hoc5_intersection_bbox = hoc5l.get_boundingbox('bigbrain', restrict_space=False).intersection(section1402)\n",
"print(f\"Size of the bounding box: {hoc5_intersection_bbox.shape}\")\n",
"\n",
"# this is quite large, so we shrink it\n",
"voi = hoc5_bbox.zoom(0.1)\n",
"voi = hoc5_intersection_bbox.zoom(0.4)\n",
"crop = section1402.fetch(voi=voi, resolution_mm=-1)"
]
},
Expand All @@ -1062,7 +1073,7 @@
"metadata": {},
"outputs": [],
"source": [
"plotting.plot_img(crop, bg_img=None, cmap='gray')"
"plotting.plot_img(crop, bg_img=None, cmap='gray', display_mode='y')"
]
},
{
Expand All @@ -1072,7 +1083,7 @@
"metadata": {},
"outputs": [],
"source": [
"plotting.plot_img(crop, bg_img=bigbrain_template.fetch(), cmap='magma')"
"plotting.plot_img(crop, bg_img=bigbrain_template.fetch(resolution_mm=0.8), cmap='magma', display_mode='y')"
]
},
{
Expand Down Expand Up @@ -1100,7 +1111,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.8"
"version": "3.9.15"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 926e2c3

Please sign in to comment.