diff --git a/HIBALL-winterschool-2023.ipynb b/HIBALL-winterschool-2023.ipynb index 4938542..a6ccd9e 100644 --- a/HIBALL-winterschool-2023.ipynb +++ b/HIBALL-winterschool-2023.ipynb @@ -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", @@ -73,7 +73,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "id": "ecd71f02", "metadata": {}, "outputs": [], @@ -130,7 +130,7 @@ "metadata": {}, "outputs": [], "source": [ - "siibra.parcellations.JULICH_BRAIN_CYTOARCHITECTONIC_ATLAS_V3_0_3" + "siibra.parcellations['julich']" ] }, { @@ -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", @@ -650,7 +650,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 30, "id": "1e6834c0", "metadata": {}, "outputs": [], @@ -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]" @@ -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" ] }, { @@ -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)" ] }, { @@ -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", @@ -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]" ] }, @@ -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", @@ -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", ")" ] @@ -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)" ] }, @@ -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')" ] }, { @@ -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')" ] }, { @@ -1100,7 +1111,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.8" + "version": "3.9.15" } }, "nbformat": 4,