Skip to content

Commit

Permalink
Merge pull request #6 from FZJ-INM1-BDA/siibra-1.0
Browse files Browse the repository at this point in the history
Siibra 1.0
  • Loading branch information
AhmetNSimsek authored Mar 12, 2024
2 parents dac25a2 + ea7d57a commit df7b959
Show file tree
Hide file tree
Showing 9 changed files with 601 additions and 229 deletions.
68 changes: 10 additions & 58 deletions 01-BasicConcepts.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"outputs": [],
"source": [
"import siibra\n",
"assert siibra.__version__ == \"0.4a69\"\n",
"assert siibra.__version__ >= \"1.0a08\"\n",
"import os\n",
"import matplotlib\n",
"%matplotlib notebook"
Expand Down Expand Up @@ -171,8 +171,8 @@
"outputs": [],
"source": [
"# search regions known by the parcellation\n",
"for region in julichbrain.find_regions('amygdala'):\n",
" print(region.name)"
"for region in julichbrain.find('amygdala'):\n",
" print(region, region.parcellation)"
]
},
{
Expand Down Expand Up @@ -245,7 +245,7 @@
"outputs": [],
"source": [
"# search all regions known by the atlas\n",
"for r in atlas.find_regions('amygdala'):\n",
"for r in siibra.find_regions('amygdala'):\n",
" print(f\"{r.name:30.30} {r.parcellation}\")"
]
},
Expand Down Expand Up @@ -288,32 +288,8 @@
"outputs": [],
"source": [
"from nilearn import plotting\n",
"plotting.plot_stat_map(mpm.fetch(), title=f\"{mpm.parcellation.name} (merged fragments)\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To fetch only the left hemisphere, we simply specifiy the fragment in the `fetch()` call:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"mpm.volumes[0]._providers['nii']._img_loaders"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"plotting.plot_stat_map(mpm.fetch(), title=mpm.parcellation.name)"
"cmap = mpm.get_colormap()\n",
"plotting.plot_roi(mpm.fetch(), cmap=cmap, title=mpm.parcellation.name)"
]
},
{
Expand All @@ -339,15 +315,6 @@
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"pmaps.fetch_iter()"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -449,7 +416,7 @@
"metadata": {},
"outputs": [],
"source": [
"bigbrain = siibra.spaces.get('bigbrain').get_template()\n",
"bigbrain = siibra.get_template('bigbrain')\n",
"bigbrain_img = bigbrain.fetch()\n",
"plotting.plot_img(bigbrain_img, cmap='gray')"
]
Expand Down Expand Up @@ -554,24 +521,9 @@
"metadata": {},
"outputs": [],
"source": [
"area44l = julichbrain.get_region('44 left')\n",
"voi = area44l.get_bounding_box(space=\"bigbrain\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We will not fetch data now, but we can compute the volume of the bounding box:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"voi.volume"
"area44r = julichbrain.get_region(\"44 right\")\n",
"bbox = area44r.get_boundingbox(\"bigbrain\")\n",
"bbox"
]
},
{
Expand Down
112 changes: 64 additions & 48 deletions 02-DataFeatures.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,33 +22,63 @@
"outputs": [],
"source": [
"import siibra\n",
"assert siibra.__version__ == \"0.4a69\""
"assert siibra.__version__ >= \"1.0a08\""
]
},
{
"cell_type": "markdown",
"id": "7b75cdf8",
"metadata": {},
"source": [
"We can choose different types of features from this module. The feature types are organized in a hierarchy under the most abstract type `siibra.features.Feature`. All other feature types are subclasses of it. The current hierarchy is\n",
"```\n",
"Feature\n",
"├── CorticalProfile\n",
"│ ├── CellDensityProfile\n",
"│ ├── BigBrainIntensityProfile\n",
"│ └── ReceptorDensityProfile\n",
"├── Tabular\n",
"│ ├── LayerwiseCellDensity\n",
"│ ├── LayerwiseBigBrainIntensities\n",
"│ ├── ReceptorDensityFingerprint\n",
"│ └── GeneExpressions\n",
"├── RegionalConnectivity\n",
"│ ├── FunctionalConnectivity\n",
"│ ├── StreamlineCounts\n",
"│ └── StreamlineLengths\n",
"├── EbrainsDataFeature\n",
"└── VolumeOfInterest\n",
"```"
"We can choose different types of features from this module. The feature types are organized in a hierarchy under the most abstract type `siibra.features.Feature`. All other feature types are subclasses of it. The current hierarchy can be obtained by"
]
},
{
"cell_type": "code",
"execution_count": 26,
"id": "96143ef5",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Feature\n",
"├── CompoundFeature\n",
"├── Tabular\n",
"│ ├── CorticalProfile\n",
"│ │ ├── BigBrainIntensityProfile\n",
"│ │ ├── CellDensityProfile\n",
"│ │ └── ReceptorDensityProfile\n",
"│ ├── GeneExpressions\n",
"│ │ ├── ProxyFeature\n",
"│ │ └── ProxyFeature\n",
"│ ├── LayerwiseBigBrainIntensities\n",
"│ ├── LayerwiseCellDensity\n",
"│ ├── ReceptorDensityFingerprint\n",
"│ └── RegionalTimeseriesActivity\n",
"│ └── RegionalBOLD\n",
"├── RegionalConnectivity\n",
"│ ├── FunctionalConnectivity\n",
"│ ├── AnatomoFunctionalConnectivity\n",
"│ ├── StreamlineCounts\n",
"│ ├── StreamlineLengths\n",
"│ └── TracingConnectivity\n",
"├── Image\n",
"│ ├── CellBodyStainedVolumeOfInterest\n",
"│ ├── BlockfaceVolumeOfInterest\n",
"│ ├── DTIVolumeOfInterest\n",
"│ ├── PLIVolumeOfInterest\n",
"│ ├── MRIVolumeOfInterest\n",
"│ ├── XPCTVolumeOfInterest\n",
"│ ├── LSFMVolumeOfInterest\n",
"│ └── CellbodyStainedSection\n",
"└── EbrainsDataFeature\n"
]
}
],
"source": [
"siibra.features.render_ascii_tree(\"Feature\")"
]
},
{
Expand Down Expand Up @@ -108,7 +138,7 @@
"id": "db81a0e1",
"metadata": {},
"source": [
"Typically, not all regions have all data modalities linked. Neurotransmitter density fingerprints are currently available for part of the cytoarchitectonic brain regions in human only. We can see this by querying with the parcellation, which represents the root region and thus provides all features linked to any Julich-Brain regions.\n",
"Typically, not all regions have all data modalities linked. Neurotransmitter density fingerprints are currently available for part of the cytoarchitectonic brain regions in human. We can see this by querying with the parcellation, which represents the root region and thus provides all features linked to any Julich-Brain regions.\n",
"\n",
"Here we just print the set of unique region names for which receptor densities are linked."
]
Expand Down Expand Up @@ -204,18 +234,7 @@
"features = siibra.features.get(\n",
" v1, siibra.features.molecular.GeneExpressions, gene=[\"TAC1\", \"MAOA\", \"GABARAPL2\"]\n",
")\n",
"fig = features[0].plot()\n",
"features[0].data"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1906734d",
"metadata": {},
"outputs": [],
"source": [
"fig = features[0].plot()\n",
"fig = features[0].plot(title=f'Gene Expressions in {v1}')\n",
"features[0].data"
]
},
Expand All @@ -234,11 +253,10 @@
"metadata": {},
"outputs": [],
"source": [
"locations = siibra.PointSet(features[0].data.mni_xyz, space=\"mni152\")\n",
"\n",
"from nilearn import plotting\n",
"mask = v1.fetch_regional_map(\"mni152\")\n",
"display = plotting.plot_glass_brain(mask, cmap='viridis')\n",
"mask = v1.get_regional_map(\"mni152\")\n",
"display = plotting.plot_glass_brain(mask.fetch(), cmap='viridis')\n",
"locations = features[0].anchor.location\n",
"display.add_markers(locations.as_list(), marker_size=2) "
]
},
Expand All @@ -253,7 +271,7 @@
"source": [
"### Connectivity matrices\n",
"\n",
"`siibra` provides connectivity matrices with parcellation averaged structural and functional measurments for different subjects of different cohorts. Here we request some streamline counts for Julich Brain."
"`siibra` provides connectivity matrices with parcellation averaged structural and functional measurments for different subjects of different cohorts. Here we request streamline counts for Julich Brain. Since the datasets comprise hundreds of connectivity matrices for the same cohort and modality, they are grouped into \"compounds\"."
]
},
{
Expand All @@ -274,7 +292,7 @@
"id": "345906a7",
"metadata": {},
"source": [
"Let's check the cohort and subject ids of the first connectivity feature."
"Let's check the cohort and indices of individual feature elements for the first compound. The elements are indexed by subject id."
]
},
{
Expand All @@ -286,8 +304,8 @@
"source": [
"print(\n",
" f\"{features[0].cohort}\\n\\n\"\n",
" \"Subjects: \"\n",
" f\"{', '.join(features[0].subjects)}\"\n",
" \"Indices: \"\n",
" f\"{', '.join(features[0].indices)}\"\n",
")"
]
},
Expand All @@ -296,9 +314,7 @@
"id": "456679fe",
"metadata": {},
"source": [
"We can retrieve the matrix of a single subject using `get_matrix()`. If we leave the subject specification out, `siibra` will compute the mean matrix across subjects.\n",
"\n",
"Again, the result is a pandas dataframe, with the notable property that the row and column indices are full region objects for further reference. This implies in particular, that we can directly associate each measure with the corresponding information in the parcellation, and with a mask of a parcellation map."
"We can retrieve the matrix of a particular subject using the `get_element()` method of the compound. It includes the actual data as a pandas dataframe, with the notable property that the row and column indices are valid region objects for further reference. This implies in particular, that we can directly associate each measure with the corresponding information in the parcellation, and with a mask of a parcellation map."
]
},
{
Expand All @@ -308,8 +324,8 @@
"metadata": {},
"outputs": [],
"source": [
"matrix_hcp_000 = features[0].get_matrix(subject='000')\n",
"matrix_hcp_000"
"sc_hcp_000 = features[0].get_element('000')\n",
"sc_hcp_000.data"
]
},
{
Expand All @@ -327,9 +343,9 @@
"metadata": {},
"outputs": [],
"source": [
"node_coords = features[0].compute_centroids(space='mni152')\n",
"node_coords = sc_hcp_000.compute_centroids(space='mni152')\n",
"plotting.view_connectome(\n",
" adjacency_matrix=matrix_hcp_000,\n",
" adjacency_matrix=sc_hcp_000.data,\n",
" node_coords=node_coords,\n",
" edge_threshold=\"99%\",\n",
" node_size=3, colorbar=False,\n",
Expand Down
Loading

0 comments on commit df7b959

Please sign in to comment.