.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/run_compute_parcel_mean.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_run_compute_parcel_mean.py: Computer Parcel Aggregation. ============================ This example uses the ``ParcelAggregation`` marker to compute the mean of each parcel using the Schaefer parcellations (100 rois, 7 Yeo networks) for both 3D and 4D NIfTI. Authors: Federico Raimondo, Synchon Mandal License: BSD 3 clause .. GENERATED FROM PYTHON SOURCE LINES 13-23 .. code-block:: Python from junifer.testing.datagrabbers import ( OasisVBMTestingDataGrabber, SPMAuditoryTestingDataGrabber, ) from junifer.datareader import DefaultDataReader from junifer.markers import ParcelAggregation from junifer.utils import configure_logging .. GENERATED FROM PYTHON SOURCE LINES 24-25 Set the logging level to info to see extra information .. GENERATED FROM PYTHON SOURCE LINES 25-27 .. code-block:: Python configure_logging(level="INFO") .. rst-class:: sphx-glr-script-out .. code-block:: none /__w/junifer/junifer/junifer/utils/logging.py:155: UserWarning: The '__version__' attribute is deprecated and will be removed in MarkupSafe 3.1. Use feature detection, or `importlib.metadata.version("markupsafe")`, instead. vstring = str(getattr(module, "__version__", None)) 2025-09-22 15:47:43,828 - JUNIFER - INFO - ===== Lib Versions ===== 2025-09-22 15:47:43,828 - JUNIFER - INFO - click: 8.1.8 2025-09-22 15:47:43,828 - JUNIFER - INFO - numpy: 1.26.4 2025-09-22 15:47:43,828 - JUNIFER - INFO - scipy: 1.15.0 2025-09-22 15:47:43,828 - JUNIFER - INFO - datalad: 1.1.6 2025-09-22 15:47:43,828 - JUNIFER - INFO - pandas: 2.1.4 2025-09-22 15:47:43,828 - JUNIFER - INFO - nibabel: 5.3.2 2025-09-22 15:47:43,828 - JUNIFER - INFO - nilearn: 0.10.4 2025-09-22 15:47:43,828 - JUNIFER - INFO - sqlalchemy: 2.0.43 2025-09-22 15:47:43,828 - JUNIFER - INFO - ruamel.yaml: 0.18.15 2025-09-22 15:47:43,828 - JUNIFER - INFO - tqdm: 4.66.6 2025-09-22 15:47:43,828 - JUNIFER - INFO - templateflow: 24.2.2 2025-09-22 15:47:43,828 - JUNIFER - INFO - junifer_data: None 2025-09-22 15:47:43,828 - JUNIFER - INFO - junifer: 0.0.7.dev206 2025-09-22 15:47:43,828 - JUNIFER - INFO - ======================== .. GENERATED FROM PYTHON SOURCE LINES 28-29 Perform parcel aggregation on VBM GM data (3D) from OASIS dataset .. GENERATED FROM PYTHON SOURCE LINES 29-42 .. code-block:: Python with OasisVBMTestingDataGrabber() as dg: # Get the first element element = dg.get_elements()[0] # Read the element element_data = DefaultDataReader().fit_transform(dg[element]) # Initialize marker marker = ParcelAggregation(parcellation="Schaefer100x7", method="mean") # Compute feature feature = marker.fit_transform(element_data) # Print the output print(feature.keys()) print(feature["VBM_GM"]["aggregation"]["data"].shape) # Shape is (1 x parcels) .. rst-class:: sphx-glr-script-out .. code-block:: none 2025-09-22 15:47:43,834 - JUNIFER - INFO - Getting element sub-01 2025-09-22 15:47:43,834 - JUNIFER - INFO - Reading VBM_GM from /github/home/nilearn_data/oasis1/OAS1_0001_MR1/mwrc1OAS1_0001_MR1_mpr_anon_fslswapdim_bet.nii.gz 2025-09-22 15:47:43,834 - JUNIFER - INFO - VBM_GM is of type NIFTI 2025-09-22 15:47:43,835 - JUNIFER - INFO - Computing VBM_GM 2025-09-22 15:47:43,835 - JUNIFER - INFO - Parcellation will be warped from MNI152NLin6Asym to MNI152Lin using highest resolution 2025-09-22 15:47:43,835 - JUNIFER - INFO - Parcellation parameters: 2025-09-22 15:47:43,835 - JUNIFER - INFO - resolution: None 2025-09-22 15:47:43,835 - JUNIFER - INFO - n_rois: 100 2025-09-22 15:47:43,836 - JUNIFER - INFO - yeo_networks: 7 2025-09-22 15:47:43,836 - JUNIFER - INFO - Resolution set to None, using highest resolution. 2025-09-22 15:47:43,911 - JUNIFER - INFO - Loading parcellation: /github/home/junifer_data/v4/parcellations/Schaefer2018/Yeo2011/Schaefer2018_100Parcels_7Networks_order_FSLMNI152_1mm.nii.gz 2025-09-22 15:47:46,219 - JUNIFER - INFO - Downloading template MNI152Lin (T1w in resolution 1) 2025-09-22 15:47:46,723 - JUNIFER - INFO - antsApplyTransforms command to be executed: antsApplyTransforms -d 3 -e 3 -n 'GenericLabel[NearestNeighbor]' -i /tmp/junifer/tmpsdoq4hv3/ants_parcellation_warper_Schaefer100x7_from_MNI152NLin6Asym_to_MNI152Lin_7ab86cf6-97cb-11f0-a4c0-5ace1b2a80e5or0h1c2y/prewarp_parcellation.nii.gz -r /tmp/junifer/tmpsdoq4hv3/ants_parcellation_warper_Schaefer100x7_from_MNI152NLin6Asym_to_MNI152Lin_7ab86cf6-97cb-11f0-a4c0-5ace1b2a80e5or0h1c2y/MNI152Lin_T1w.nii.gz -t /github/home/junifer_data/v4/.git/annex/objects/JQ/Pp/SHA256E-s145422752--5091350b36f951d455dabd429ebe86c493c75a0217dca311ae355f1d62e080b0.h5/SHA256E-s145422752--5091350b36f951d455dabd429ebe86c493c75a0217dca311ae355f1d62e080b0.h5 -o /tmp/junifer/tmpsdoq4hv3/ants_parcellation_warper_Schaefer100x7_from_MNI152NLin6Asym_to_MNI152Lin_7ab86cf6-97cb-11f0-a4c0-5ace1b2a80e5or0h1c2y/parcellation_warped.nii.gz 2025-09-22 15:47:53,015 - JUNIFER - INFO - antsApplyTransforms command succeeded with the following output: 2025-09-22 15:47:54,412 - JUNIFER - INFO - No storage specified, returning dictionary dict_keys(['VBM_GM']) (1, 100) .. GENERATED FROM PYTHON SOURCE LINES 43-44 Perform parcel aggregation on BOLD data (4D) from SPM Auditory dataset .. GENERATED FROM PYTHON SOURCE LINES 44-58 .. code-block:: Python with SPMAuditoryTestingDataGrabber() as dg: # Get the first element element = dg.get_elements()[0] # Read the element element_data = DefaultDataReader().fit_transform(dg[element]) # Initialize marker marker = ParcelAggregation( parcellation="Schaefer100x7", method="mean", on="BOLD" ) # Compute feature feature = marker.fit_transform(element_data) # Print the output print(feature.keys()) print(feature["BOLD"]["aggregation"]["data"].shape) # Shape is (timepoints x parcels) .. rst-class:: sphx-glr-script-out .. code-block:: none 2025-09-22 15:47:54,414 - JUNIFER - INFO - Getting element sub001 Dataset created in /github/home/nilearn_data/spm_auditory Data absent, downloading... Downloading data from https://www.fil.ion.ucl.ac.uk/spm/download/data/MoAEpilot/MoAEpilot.zip ... Downloaded 5365760 of 34212021 bytes (15.7%, 5.5s remaining) Downloaded 13172736 of 34212021 bytes (38.5%, 3.2s remaining) Downloaded 20135936 of 34212021 bytes (58.9%, 2.1s remaining) Downloaded 26574848 of 34212021 bytes (77.7%, 1.2s remaining) Downloaded 33161216 of 34212021 bytes (96.9%, 0.2s remaining) ...done. (6 seconds, 0 min) Extracting data from /github/home/nilearn_data/spm_auditory/sub001/MoAEpilot.zip..... done. 2025-09-22 15:48:03,349 - JUNIFER - INFO - Reading BOLD from /tmp/tmpkwpwounn/sub001_bold.nii.gz 2025-09-22 15:48:03,349 - JUNIFER - INFO - BOLD is of type NIFTI 2025-09-22 15:48:03,350 - JUNIFER - INFO - Reading T1w from /tmp/tmpkwpwounn/sub001_T1w.nii.gz 2025-09-22 15:48:03,350 - JUNIFER - INFO - T1w is of type NIFTI 2025-09-22 15:48:03,351 - JUNIFER - INFO - Computing BOLD 2025-09-22 15:48:03,351 - JUNIFER - INFO - Parcellation will be warped from MNI152NLin6Asym to MNI152Lin using highest resolution 2025-09-22 15:48:03,351 - JUNIFER - INFO - Parcellation parameters: 2025-09-22 15:48:03,351 - JUNIFER - INFO - resolution: None 2025-09-22 15:48:03,351 - JUNIFER - INFO - n_rois: 100 2025-09-22 15:48:03,351 - JUNIFER - INFO - yeo_networks: 7 2025-09-22 15:48:03,352 - JUNIFER - INFO - Resolution set to None, using highest resolution. 2025-09-22 15:48:03,426 - JUNIFER - INFO - Loading parcellation: /github/home/junifer_data/v4/parcellations/Schaefer2018/Yeo2011/Schaefer2018_100Parcels_7Networks_order_FSLMNI152_1mm.nii.gz 2025-09-22 15:48:05,717 - JUNIFER - INFO - Downloading template MNI152Lin (T1w in resolution 1) 2025-09-22 15:48:06,221 - JUNIFER - INFO - antsApplyTransforms command to be executed: antsApplyTransforms -d 3 -e 3 -n 'GenericLabel[NearestNeighbor]' -i /tmp/junifer/tmpsdoq4hv3/ants_parcellation_warper_Schaefer100x7_from_MNI152NLin6Asym_to_MNI152Lin_865a9516-97cb-11f0-a4c0-5ace1b2a80e5r_bdflpv/prewarp_parcellation.nii.gz -r /tmp/junifer/tmpsdoq4hv3/ants_parcellation_warper_Schaefer100x7_from_MNI152NLin6Asym_to_MNI152Lin_865a9516-97cb-11f0-a4c0-5ace1b2a80e5r_bdflpv/MNI152Lin_T1w.nii.gz -t /github/home/junifer_data/v4/.git/annex/objects/JQ/Pp/SHA256E-s145422752--5091350b36f951d455dabd429ebe86c493c75a0217dca311ae355f1d62e080b0.h5/SHA256E-s145422752--5091350b36f951d455dabd429ebe86c493c75a0217dca311ae355f1d62e080b0.h5 -o /tmp/junifer/tmpsdoq4hv3/ants_parcellation_warper_Schaefer100x7_from_MNI152NLin6Asym_to_MNI152Lin_865a9516-97cb-11f0-a4c0-5ace1b2a80e5r_bdflpv/parcellation_warped.nii.gz 2025-09-22 15:48:12,572 - JUNIFER - INFO - antsApplyTransforms command succeeded with the following output: 2025-09-22 15:48:15,591 - JUNIFER - INFO - No storage specified, returning dictionary dict_keys(['BOLD']) (96, 100) .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 31.767 seconds) .. _sphx_glr_download_auto_examples_run_compute_parcel_mean.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: run_compute_parcel_mean.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: run_compute_parcel_mean.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: run_compute_parcel_mean.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_