.. 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 2024-09-30 11:46:58,539 - JUNIFER - INFO - ===== Lib Versions ===== 2024-09-30 11:46:58,539 - JUNIFER - INFO - numpy: 1.26.4 2024-09-30 11:46:58,540 - JUNIFER - INFO - scipy: 1.14.0 2024-09-30 11:46:58,540 - JUNIFER - INFO - pandas: 2.1.4 2024-09-30 11:46:58,540 - JUNIFER - INFO - nilearn: 0.10.4 2024-09-30 11:46:58,540 - JUNIFER - INFO - nibabel: 5.2.1 2024-09-30 11:46:58,540 - JUNIFER - INFO - junifer: 0.0.6.dev90 2024-09-30 11:46:58,540 - 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 2024-09-30 11:46:58,545 - JUNIFER - INFO - Getting element sub-01 2024-09-30 11:46:58,545 - JUNIFER - INFO - Reading VBM_GM from /home/runner/nilearn_data/oasis1/OAS1_0001_MR1/mwrc1OAS1_0001_MR1_mpr_anon_fslswapdim_bet.nii.gz 2024-09-30 11:46:58,545 - JUNIFER - INFO - VBM_GM is of type NIFTI 2024-09-30 11:46:58,546 - JUNIFER - INFO - Computing VBM_GM 2024-09-30 11:46:58,547 - JUNIFER - INFO - Fetching one of Schaefer parcellations. 2024-09-30 11:46:58,547 - JUNIFER - INFO - Parcellation parameters: 2024-09-30 11:46:58,547 - JUNIFER - INFO - resolution: 2.0 2024-09-30 11:46:58,547 - JUNIFER - INFO - n_rois: 100 2024-09-30 11:46:58,547 - JUNIFER - INFO - yeo_networks: 7 2024-09-30 11:46:58,547 - JUNIFER - INFO - At least one of the parcellation files are missing. Fetching using nilearn. 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) 2024-09-30 11:46:58,588 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_100Parcels_7Networks_order_FSLMNI152_2mm.nii.gz 2024-09-30 11:46:58,617 - JUNIFER - INFO - Found existing xfm file for MNI152NLin6Asym to MNI152Lin at /home/runner/junifer/data/xfms/MNI152NLin6Asym_to_MNI152Lin/MNI152NLin6Asym_to_MNI152Lin_Composite.h5 2024-09-30 11:46:59,600 - JUNIFER - INFO - Downloading template MNI152Lin in resolution 2 2024-09-30 11:46:59,697 - JUNIFER - INFO - antsApplyTransforms command to be executed: antsApplyTransforms -d 3 -e 3 -n 'GenericLabel[NearestNeighbor]' -i /tmp/tmpn9vwo4yf/parcellationsxdkcoc6n/Schaefer100x7.nii.gz -r /tmp/tmpn9vwo4yf/parcellationsxdkcoc6n/MNI152Lin_T1w_2.0.nii.gz -t /home/runner/junifer/data/xfms/MNI152NLin6Asym_to_MNI152Lin/MNI152NLin6Asym_to_MNI152Lin_Composite.h5 -o /tmp/tmp16ha0i5x/parcellationsm27teqqc/Schaefer100x7_warped_from_MNI152NLin6Asym_to_MNI152Lin.nii.gz 2024-09-30 11:47:01,089 - JUNIFER - INFO - antsApplyTransforms command succeeded with the following output: 2024-09-30 11:47:02,025 - 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 2024-09-30 11:47:02,026 - JUNIFER - INFO - Getting element sub001 Dataset created in /home/runner/nilearn_data/spm_auditory Data absent, downloading... Downloading data from https://www.fil.ion.ucl.ac.uk/spm/download/data/MoAEpilot/MoAEpilot.zip ... Downloaded 4456448 of 34212021 bytes (13.0%, 6.9s remaining) Downloaded 11681792 of 34212021 bytes (34.1%, 3.9s remaining) Downloaded 16596992 of 34212021 bytes (48.5%, 3.2s remaining) Downloaded 20652032 of 34212021 bytes (60.4%, 2.7s remaining) Downloaded 25092096 of 34212021 bytes (73.3%, 1.8s remaining) Downloaded 29474816 of 34212021 bytes (86.2%, 1.0s remaining) Downloaded 34144256 of 34212021 bytes (99.8%, 0.0s remaining) ...done. (8 seconds, 0 min) Extracting data from /home/runner/nilearn_data/spm_auditory/sub001/MoAEpilot.zip..... done. 2024-09-30 11:47:13,522 - JUNIFER - INFO - Reading BOLD from /tmp/tmppjz_i635/sub001_bold.nii.gz 2024-09-30 11:47:13,523 - JUNIFER - INFO - BOLD is of type NIFTI 2024-09-30 11:47:13,523 - JUNIFER - INFO - Reading T1w from /tmp/tmppjz_i635/sub001_T1w.nii.gz 2024-09-30 11:47:13,524 - JUNIFER - INFO - T1w is of type NIFTI 2024-09-30 11:47:13,524 - JUNIFER - INFO - Computing BOLD 2024-09-30 11:47:13,525 - JUNIFER - INFO - Fetching one of Schaefer parcellations. 2024-09-30 11:47:13,525 - JUNIFER - INFO - Parcellation parameters: 2024-09-30 11:47:13,525 - JUNIFER - INFO - resolution: 3.0 2024-09-30 11:47:13,525 - JUNIFER - INFO - n_rois: 100 2024-09-30 11:47:13,525 - JUNIFER - INFO - yeo_networks: 7 2024-09-30 11:47:13,527 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_100Parcels_7Networks_order_FSLMNI152_2mm.nii.gz 2024-09-30 11:47:13,557 - JUNIFER - INFO - Found existing xfm file for MNI152NLin6Asym to MNI152Lin at /home/runner/junifer/data/xfms/MNI152NLin6Asym_to_MNI152Lin/MNI152NLin6Asym_to_MNI152Lin_Composite.h5 2024-09-30 11:47:14,552 - JUNIFER - INFO - Downloading template MNI152Lin in resolution 2 2024-09-30 11:47:14,649 - JUNIFER - INFO - antsApplyTransforms command to be executed: antsApplyTransforms -d 3 -e 3 -n 'GenericLabel[NearestNeighbor]' -i /tmp/tmpn9vwo4yf/parcellations37_nytpz/Schaefer100x7.nii.gz -r /tmp/tmpn9vwo4yf/parcellations37_nytpz/MNI152Lin_T1w_3.0.nii.gz -t /home/runner/junifer/data/xfms/MNI152NLin6Asym_to_MNI152Lin/MNI152NLin6Asym_to_MNI152Lin_Composite.h5 -o /tmp/tmp16ha0i5x/parcellations42jaau08/Schaefer100x7_warped_from_MNI152NLin6Asym_to_MNI152Lin.nii.gz 2024-09-30 11:47:16,032 - JUNIFER - INFO - antsApplyTransforms command succeeded with the following output: 2024-09-30 11:47:18,689 - 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 20.156 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 ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_