Note
Click here to download the full example code
8.3. Computer Parcel Aggregation.#
This example uses a ParcelAggregation marker to compute the mean of each parcel using the Schaefer parcellations (100 rois, 7 Yeo networks) for both a 3D and 4D nifti
Authors: Federico Raimondo
License: BSD 3 clause
import nilearn
from junifer.markers.parcel_aggregation import ParcelAggregation
from junifer.utils import configure_logging
Set the logging level to info to see extra information
configure_logging(level="INFO")
2023-09-06 09:37:41,068 - JUNIFER - INFO - ===== Lib Versions =====
2023-09-06 09:37:41,068 - JUNIFER - INFO - numpy: 1.25.2
2023-09-06 09:37:41,068 - JUNIFER - INFO - scipy: 1.11.2
2023-09-06 09:37:41,068 - JUNIFER - INFO - pandas: 1.5.3
2023-09-06 09:37:41,068 - JUNIFER - INFO - nilearn: 0.10.0
2023-09-06 09:37:41,068 - JUNIFER - INFO - nibabel: 4.0.2
2023-09-06 09:37:41,068 - JUNIFER - INFO - junifer: 0.0.4.dev21
2023-09-06 09:37:41,068 - JUNIFER - INFO - ========================
Load the VBM GM data (3d): - Fetch the Oasis dataset
Dataset created in /home/runner/nilearn_data/oasis1
Downloading data from https://www.nitrc.org/frs/download.php/6364/archive_dartel.tgz ...
Downloaded 231940096 of 905208634 bytes (25.6%, 2.9s remaining)
Downloaded 449110016 of 905208634 bytes (49.6%, 2.0s remaining)
Downloaded 661438464 of 905208634 bytes (73.1%, 1.1s remaining)
Downloaded 875479040 of 905208634 bytes (96.7%, 0.1s remaining) ...done. (5 seconds, 0 min)
Extracting data from /home/runner/nilearn_data/oasis1/6d19418bccb98b1333309bd8baa05152/archive_dartel.tgz..... done.
/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/nilearn/datasets/struct.py:733: UserWarning: `legacy_format` will default to `False` in release 0.11. Dataset fetchers will then return pandas dataframes by default instead of recarrays.
warnings.warn(_LEGACY_FORMAT_MSG)
Load the functional data (4d): - Fetch the SPM auditory dataset - Concatenate the functional data into one 4D image
Dataset created in /home/runner/nilearn_data/spm_auditory
Data absent, downloading...
Downloading data from http://www.fil.ion.ucl.ac.uk/spm/download/data/MoAEpilot/MoAEpilot.zip ...
Downloaded 4653056 of 34212021 bytes (13.6%, 6.4s remaining)
Downloaded 10870784 of 34212021 bytes (31.8%, 4.4s remaining)
Downloaded 17063936 of 34212021 bytes (49.9%, 3.1s remaining)
Downloaded 23511040 of 34212021 bytes (68.7%, 1.9s remaining)
Downloaded 29204480 of 34212021 bytes (85.4%, 0.9s remaining)
Downloaded 31334400 of 34212021 bytes (91.6%, 0.6s remaining) ...done. (8 seconds, 0 min)
Extracting data from /home/runner/nilearn_data/spm_auditory/sub001/MoAEpilot.zip..... done.
Define the marker
marker = ParcelAggregation(parcellation="Schaefer100x7", method="mean")
Prepare the input
Fit transform the data
out = marker.fit_transform(input)
2023-09-06 09:38:03,112 - JUNIFER - INFO - Computing BOLD
2023-09-06 09:38:03,112 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2023-09-06 09:38:03,112 - JUNIFER - INFO - Parcellation parameters:
2023-09-06 09:38:03,112 - JUNIFER - INFO - resolution: 3.0
2023-09-06 09:38:03,113 - JUNIFER - INFO - n_rois: 100
2023-09-06 09:38:03,113 - JUNIFER - INFO - yeo_networks: 7
2023-09-06 09:38:03,113 - JUNIFER - INFO - At least one of the parcellation files are missing. Fetching using nilearn.
Dataset created in /home/runner/junifer/data/parcellations/schaefer_2018
Downloading data from https://raw.githubusercontent.com/ThomasYeoLab/CBIG/v0.14.3-Update_Yeo2011_Schaefer2018_labelname/stable_projects/brain_parcellation/Schaefer2018_LocalGlobal/Parcellations/MNI/Schaefer2018_100Parcels_7Networks_order.txt ...
...done. (0 seconds, 0 min)
Downloading data from https://raw.githubusercontent.com/ThomasYeoLab/CBIG/v0.14.3-Update_Yeo2011_Schaefer2018_labelname/stable_projects/brain_parcellation/Schaefer2018_LocalGlobal/Parcellations/MNI/Schaefer2018_100Parcels_7Networks_order_FSLMNI152_2mm.nii.gz ...
...done. (0 seconds, 0 min)
2023-09-06 09:38:03,767 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_100Parcels_7Networks_order_FSLMNI152_2mm.nii.gz
2023-09-06 09:38:05,135 - JUNIFER - INFO - No storage specified, returning dictionary
2023-09-06 09:38:05,136 - JUNIFER - INFO - Computing VBM_GM
2023-09-06 09:38:05,136 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2023-09-06 09:38:05,136 - JUNIFER - INFO - Parcellation parameters:
2023-09-06 09:38:05,136 - JUNIFER - INFO - resolution: 2.0
2023-09-06 09:38:05,136 - JUNIFER - INFO - n_rois: 100
2023-09-06 09:38:05,136 - JUNIFER - INFO - yeo_networks: 7
2023-09-06 09:38:05,138 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_100Parcels_7Networks_order_FSLMNI152_2mm.nii.gz
2023-09-06 09:38:05,731 - JUNIFER - INFO - No storage specified, returning dictionary
Check the results
dict_keys(['BOLD', 'VBM_GM'])
(1, 100)
dict_keys(['BOLD', 'VBM_GM'])
(96, 100)
Total running time of the script: ( 0 minutes 24.668 seconds)