|
| 1 | +# Copyright 2018-2021 |
| 2 | +# Institute of Neuroscience and Medicine (INM-1), Forschungszentrum Jülich GmbH |
| 3 | + |
| 4 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +# you may not use this file except in compliance with the License. |
| 6 | +# You may obtain a copy of the License at |
| 7 | + |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | + |
| 16 | +""" |
| 17 | +Parcellation-based functional data |
| 18 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 19 | +
|
| 20 | +`siibra` provides access to parcellation-averaged functional data such as |
| 21 | +blood-oxygen-level-dependent (BOLD) signals. |
| 22 | +""" |
| 23 | + |
| 24 | +# %% |
| 25 | +import siibra |
| 26 | +# sphinx_gallery_thumbnail_number = 1 |
| 27 | + |
| 28 | +# %% |
| 29 | +# We start by selecting an atlas parcellation. |
| 30 | +jubrain = siibra.parcellations.get("julich 2.9") |
| 31 | + |
| 32 | +# %% |
| 33 | +# The matrices are queried as expected, using `siibra.features.get`, |
| 34 | +# passing the parcellation as a concept. |
| 35 | +# Here, we query for structural connectivity matrices. |
| 36 | +features = siibra.features.get(jubrain, siibra.features.functional.RegionalBOLD) |
| 37 | +print(f"Found {len(features)} parcellation-based BOLD signals for {jubrain}.") |
| 38 | + |
| 39 | +# %% |
| 40 | +# We fetch the first result, which is a specific `RegionalBOLD` object. |
| 41 | +bold = features[0] |
| 42 | +print(f"RegionalBOLD features reflects {bold.modality} of {bold.cohort} cohort.") |
| 43 | +print(bold.name) |
| 44 | +print("\n" + bold.description) |
| 45 | + |
| 46 | +# Subjects are encoded via anonymized ids: |
| 47 | +print(bold.subjects) |
| 48 | + |
| 49 | + |
| 50 | +# %% |
| 51 | +# The parcellation-based functional data are provided as pandas DataFrames |
| 52 | +# with region objects as columns and indices as time step. |
| 53 | +subject = bold.subjects[0] |
| 54 | +table = bold.get_table(subject) |
| 55 | +print(f"Timestep: {bold.timestep}") |
| 56 | +table[jubrain.get_region("hOc3v left")] |
| 57 | + |
| 58 | +# %% |
| 59 | +# We can visualize the signal strength per region by time via a carpet plot. |
| 60 | +# In fact, `plot_carpet` method can take a list of regions to display the |
| 61 | +# data for selected regions only. |
| 62 | +selected_regions = [ |
| 63 | + 'SF (Amygdala) left', 'SF (Amygdala) right', 'Area Ph2 (PhG) left', |
| 64 | + 'Area Ph2 (PhG) right', 'Area Fo4 (OFC) left', 'Area Fo4 (OFC) right', |
| 65 | + 'Area 7A (SPL) left', 'Area 7A (SPL) right', 'CA1 (Hippocampus) left', |
| 66 | + 'CA1 (Hippocampus) right', 'CA1 (Hippocampus) left', 'CA1 (Hippocampus) right' |
| 67 | +] |
| 68 | +bold.plot_carpet(subject=bold.subjects[0], regions=selected_regions) |
| 69 | +# %% |
| 70 | +# Alternatively, we can visualize the mean signal strength per region: |
| 71 | +bold.plot(subject=bold.subjects[0], regions=selected_regions) |
0 commit comments