.. 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 2026-01-29 12:40:33 [info ] ===== Lib Versions ===== [junifer] 2026-01-29 12:40:33 [info ] click: 8.1.8 [junifer] 2026-01-29 12:40:33 [info ] numpy: 1.26.4 [junifer] 2026-01-29 12:40:33 [info ] scipy: 1.15.0 [junifer] 2026-01-29 12:40:33 [info ] datalad: 1.1.6 [junifer] 2026-01-29 12:40:33 [info ] pandas: 2.1.4 [junifer] 2026-01-29 12:40:33 [info ] nibabel: 5.3.3 [junifer] 2026-01-29 12:40:33 [info ] nilearn: 0.10.4 [junifer] 2026-01-29 12:40:33 [info ] sqlalchemy: 2.0.46 [junifer] 2026-01-29 12:40:33 [info ] ruamel.yaml: 0.18.17 [junifer] 2026-01-29 12:40:33 [info ] tqdm: 4.66.6 [junifer] 2026-01-29 12:40:33 [info ] templateflow: 24.2.2 [junifer] 2026-01-29 12:40:33 [info ] junifer_data: None [junifer] 2026-01-29 12:40:33 [info ] junifer: 0.0.7.dev310 [junifer] 2026-01-29 12:40:33 [info ] ======================== [junifer] .. 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 2026-01-29 12:40:33 [info ] Getting element sub-01 [junifer] 2026-01-29 12:40:33 [info ] Reading VBM_GM from /github/home/nilearn_data/oasis1/OAS1_0001_MR1/mwrc1OAS1_0001_MR1_mpr_anon_fslswapdim_bet.nii.gz [junifer] 2026-01-29 12:40:33 [info ] VBM_GM is of type NIFTI [junifer] 2026-01-29 12:40:33 [info ] Computing VBM_GM [junifer] 2026-01-29 12:40:33 [info ] Parcellation will be warped from MNI152NLin6Asym to MNI152Lin using highest resolution [junifer] 2026-01-29 12:40:33 [info ] Parcellation parameters: [junifer] 2026-01-29 12:40:33 [info ] resolution: None [junifer] 2026-01-29 12:40:33 [info ] n_rois: 100 [junifer] 2026-01-29 12:40:33 [info ] yeo_networks: 7 [junifer] 2026-01-29 12:40:33 [info ] Resolution set to None, using highest resolution. [junifer] 2026-01-29 12:40:33 [info ] Start annex operation [datalad.annex] dlm_progress=annexprogress-139808610960928 dlm_progress_label=Total dlm_progress_noninteractive_level=5 dlm_progress_total=233605 dlm_progress_unit=' Bytes' 2026-01-29 12:40:34 [info ] Start annex action: {'command': 'get', 'file': 'parcellations/Schaefer2018/Yeo2011/Schaefer2018_100Parcels_7Networks_order_FSLMNI152_1mm.nii.gz', 'input': ['parcellations/Schaefer2018/Yeo2011/Schaefer2018_100Parcels_7Networks_order_FSLMNI152_1mm.nii.gz'], 'key': 'MD5E-s233605--0709e73f84a0cd60687ff4add7f8fd05.nii.gz', 'note': 'from gin-src...'} [datalad.annex] dlm_progress=annexprogress-139808610960928--3636483356103479566 dlm_progress_label='Get parcella .. 2_1mm.nii.gz' dlm_progress_noninteractive_level=5 dlm_progress_total=233605.0 dlm_progress_unit=' Bytes' 2026-01-29 12:40:34 [info ] 38.57% [datalad.annex] dlm_progress=annexprogress-139808610960928--3636483356103479566 dlm_progress_noninteractive_level=5 dlm_progress_update=90112.0 2026-01-29 12:40:35 [info ] Finished annex action: None [datalad.annex] dlm_progress=annexprogress-139808610960928--3636483356103479566 dlm_progress_noninteractive_level=5 2026-01-29 12:40:35 [info ] Finished annex get [datalad.annex] dlm_progress=annexprogress-139808610960928 dlm_progress_noninteractive_level=5 2026-01-29 12:40:35 [info ] Loading parcellation: /github/home/junifer_data/v5/parcellations/Schaefer2018/Yeo2011/Schaefer2018_100Parcels_7Networks_order_FSLMNI152_1mm.nii.gz [junifer] 2026-01-29 12:40:37 [info ] Downloading template MNI152Lin (T1w in resolution 1) [junifer] 2026-01-29 12:40:37 [info ] antsApplyTransforms command to be executed: antsApplyTransforms -d 3 -e 3 -n 'GenericLabel[NearestNeighbor]' -i /tmp/junifer/tmpxx0_ayke/ants_parcellation_warper_Schaefer100x7_from_MNI152NLin6Asym_to_MNI152Lin_b522f998-fd0f-11f0-9821-7a325534a278ym5vlv52/prewarp_parcellation.nii.gz -r /tmp/junifer/tmpxx0_ayke/ants_parcellation_warper_Schaefer100x7_from_MNI152NLin6Asym_to_MNI152Lin_b522f998-fd0f-11f0-9821-7a325534a278ym5vlv52/MNI152Lin_T1w.nii.gz -t /github/home/junifer_data/v5/.git/annex/objects/JQ/Pp/SHA256E-s145422752--5091350b36f951d455dabd429ebe86c493c75a0217dca311ae355f1d62e080b0.h5/SHA256E-s145422752--5091350b36f951d455dabd429ebe86c493c75a0217dca311ae355f1d62e080b0.h5 -o /tmp/junifer/tmpxx0_ayke/ants_parcellation_warper_Schaefer100x7_from_MNI152NLin6Asym_to_MNI152Lin_b522f998-fd0f-11f0-9821-7a325534a278ym5vlv52/parcellation_warped.nii.gz [junifer] 2026-01-29 12:40:44 [info ] antsApplyTransforms command succeeded with the following output: [junifer] 2026-01-29 12:40:45 [info ] No storage specified, returning dictionary [junifer] 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 2026-01-29 12:40:45 [info ] Getting element sub001 [junifer] 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 4521984 of 34212021 bytes (13.2%, 7.0s remaining) Downloaded 9297920 of 34212021 bytes (27.2%, 5.5s remaining) Downloaded 14401536 of 34212021 bytes (42.1%, 4.2s remaining) Downloaded 19111936 of 34212021 bytes (55.9%, 3.2s remaining) Downloaded 24207360 of 34212021 bytes (70.8%, 2.1s remaining) Downloaded 29130752 of 34212021 bytes (85.1%, 1.1s remaining) ...done. (8 seconds, 0 min) Extracting data from /github/home/nilearn_data/spm_auditory/sub001/MoAEpilot.zip..... done. 2026-01-29 12:40:56 [info ] Reading BOLD from /tmp/tmp570v4z8o/sub001_bold.nii.gz [junifer] 2026-01-29 12:40:56 [info ] BOLD is of type NIFTI [junifer] 2026-01-29 12:40:56 [info ] Reading T1w from /tmp/tmp570v4z8o/sub001_T1w.nii.gz [junifer] 2026-01-29 12:40:56 [info ] T1w is of type NIFTI [junifer] 2026-01-29 12:40:56 [info ] Computing BOLD [junifer] 2026-01-29 12:40:56 [info ] Parcellation will be warped from MNI152NLin6Asym to MNI152Lin using highest resolution [junifer] 2026-01-29 12:40:56 [info ] Parcellation parameters: [junifer] 2026-01-29 12:40:56 [info ] resolution: None [junifer] 2026-01-29 12:40:56 [info ] n_rois: 100 [junifer] 2026-01-29 12:40:56 [info ] yeo_networks: 7 [junifer] 2026-01-29 12:40:56 [info ] Resolution set to None, using highest resolution. [junifer] 2026-01-29 12:40:56 [info ] Loading parcellation: /github/home/junifer_data/v5/parcellations/Schaefer2018/Yeo2011/Schaefer2018_100Parcels_7Networks_order_FSLMNI152_1mm.nii.gz [junifer] 2026-01-29 12:40:59 [info ] Downloading template MNI152Lin (T1w in resolution 1) [junifer] 2026-01-29 12:40:59 [info ] antsApplyTransforms command to be executed: antsApplyTransforms -d 3 -e 3 -n 'GenericLabel[NearestNeighbor]' -i /tmp/junifer/tmpxx0_ayke/ants_parcellation_warper_Schaefer100x7_from_MNI152NLin6Asym_to_MNI152Lin_c217c7e6-fd0f-11f0-9821-7a325534a27847xv1fyu/prewarp_parcellation.nii.gz -r /tmp/junifer/tmpxx0_ayke/ants_parcellation_warper_Schaefer100x7_from_MNI152NLin6Asym_to_MNI152Lin_c217c7e6-fd0f-11f0-9821-7a325534a27847xv1fyu/MNI152Lin_T1w.nii.gz -t /github/home/junifer_data/v5/.git/annex/objects/JQ/Pp/SHA256E-s145422752--5091350b36f951d455dabd429ebe86c493c75a0217dca311ae355f1d62e080b0.h5/SHA256E-s145422752--5091350b36f951d455dabd429ebe86c493c75a0217dca311ae355f1d62e080b0.h5 -o /tmp/junifer/tmpxx0_ayke/ants_parcellation_warper_Schaefer100x7_from_MNI152NLin6Asym_to_MNI152Lin_c217c7e6-fd0f-11f0-9821-7a325534a27847xv1fyu/parcellation_warped.nii.gz [junifer] 2026-01-29 12:41:05 [info ] antsApplyTransforms command succeeded with the following output: [junifer] 2026-01-29 12:41:08 [info ] No storage specified, returning dictionary [junifer] dict_keys(['BOLD']) (96, 100) .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 35.214 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 `_