8.7. Run junifer and julearn.#

This example uses a ParcelAggregation marker to compute the mean of each parcel using the Schaefer parcellation (100 rois, 7 Yeo networks) for a 3D nifti to extract some features for machine learning using julearn to predict some other data.

Authors: Leonard Sasse, Sami Hamdan, Nicolas Nieto, Synchon Mandal

License: BSD 3 clause

import tempfile

import nilearn
import pandas as pd
from julearn import run_cross_validation

import junifer.testing.registry  # noqa
from junifer.api import collect, run
from junifer.storage.sqlite import SQLiteFeatureStorage
from junifer.utils import configure_logging

Set the logging level to info to see extra information:

configure_logging(level="INFO")
2023-03-31 13:29:56,428 - JUNIFER - INFO - ===== Lib Versions =====
2023-03-31 13:29:56,428 - JUNIFER - INFO - numpy: 1.23.5
2023-03-31 13:29:56,428 - JUNIFER - INFO - scipy: 1.10.1
2023-03-31 13:29:56,428 - JUNIFER - INFO - pandas: 1.5.3
2023-03-31 13:29:56,428 - JUNIFER - INFO - nilearn: 0.10.0
2023-03-31 13:29:56,428 - JUNIFER - INFO - nibabel: 4.0.2
2023-03-31 13:29:56,428 - JUNIFER - INFO - junifer: 0.0.2
2023-03-31 13:29:56,428 - JUNIFER - INFO - ========================

Define the markers you want:

marker_dicts = [
    {
        "name": "Schaefer100x17_TrimMean80",
        "kind": "ParcelAggregation",
        "parcellation": "Schaefer100x17",
        "method": "trim_mean",
        "method_params": {"proportiontocut": 0.2},
    },
    {
        "name": "Schaefer200x17_Mean",
        "kind": "ParcelAggregation",
        "parcellation": "Schaefer200x17",
        "method": "mean",
    },
]

Define target and confounds for julearn machine learning:

y = "age"
confound = "sex"

Load the VBM phenotype data for machine learning data: - Fetch the Oasis dataset

oasis_dataset = nilearn.datasets.fetch_oasis_vbm()
age = oasis_dataset.ext_vars[y][:10]
sex = (
    pd.Series(oasis_dataset.ext_vars["mf"][:10])
    .map(lambda x: 1 if x == "F" else 0)
    .values
)
/opt/hostedtoolcache/Python/3.10.10/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)

Create a temporary directory for junifer feature extraction:

with tempfile.TemporaryDirectory() as tmpdir:

    storage = {"kind": "SQLiteFeatureStorage", "uri": f"{tmpdir}/test.sqlite"}
    # run the defined junifer feature extraction pipeline
    run(
        workdir="/tmp",
        datagrabber={"kind": "OasisVBMTestingDatagrabber"},
        markers=marker_dicts,
        storage=storage,
    )

    # read in extracted features and add confounds and targets
    # for julearn run cross validation
    collect(storage)
    db = SQLiteFeatureStorage(uri=storage["uri"])

    df_vbm = db.read_df(feature_name="VBM_GM_Schaefer200x17_Mean")
    oasis_subjects = [x[0] for x in df_vbm.index]
    df_vbm.index = oasis_subjects
/opt/hostedtoolcache/Python/3.10.10/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)
2023-03-31 13:29:56,453 - JUNIFER - INFO - Getting element sub-01
2023-03-31 13:29:56,453 - JUNIFER - INFO - Fitting pipeline
2023-03-31 13:29:56,453 - JUNIFER - INFO - Reading VBM_GM from /home/runner/nilearn_data/oasis1/OAS1_0001_MR1/mwrc1OAS1_0001_MR1_mpr_anon_fslswapdim_bet.nii.gz
2023-03-31 13:29:56,453 - JUNIFER - INFO - VBM_GM is type NIFTI
2023-03-31 13:29:56,454 - JUNIFER - INFO - Fitting marker Schaefer100x17_TrimMean80
2023-03-31 13:29:56,454 - JUNIFER - INFO - Computing VBM_GM
2023-03-31 13:29:56,454 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2023-03-31 13:29:56,454 - JUNIFER - INFO - Parcellation parameters:
2023-03-31 13:29:56,454 - JUNIFER - INFO -      n_rois: 100
2023-03-31 13:29:56,454 - JUNIFER - INFO -      yeo_networks: 17
2023-03-31 13:29:56,454 - JUNIFER - INFO -      resolution: 2.0
2023-03-31 13:29:56,456 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_100Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2023-03-31 13:29:57,144 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmp9k431lw0/test.sqlite (multiple output)>
2023-03-31 13:29:57,187 - JUNIFER - INFO - Fitting marker Schaefer200x17_Mean
2023-03-31 13:29:57,187 - JUNIFER - INFO - Computing VBM_GM
2023-03-31 13:29:57,187 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2023-03-31 13:29:57,187 - JUNIFER - INFO - Parcellation parameters:
2023-03-31 13:29:57,188 - JUNIFER - INFO -      n_rois: 200
2023-03-31 13:29:57,188 - JUNIFER - INFO -      yeo_networks: 17
2023-03-31 13:29:57,188 - JUNIFER - INFO -      resolution: 2.0
2023-03-31 13:29:57,190 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_200Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2023-03-31 13:29:57,839 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmp9k431lw0/test.sqlite (multiple output)>
2023-03-31 13:29:57,915 - JUNIFER - INFO - Marker collection fitting done
2023-03-31 13:29:57,915 - JUNIFER - INFO - Getting element sub-02
2023-03-31 13:29:57,916 - JUNIFER - INFO - Fitting pipeline
2023-03-31 13:29:57,916 - JUNIFER - INFO - Reading VBM_GM from /home/runner/nilearn_data/oasis1/OAS1_0002_MR1/mwrc1OAS1_0002_MR1_mpr_anon_fslswapdim_bet.nii.gz
2023-03-31 13:29:57,916 - JUNIFER - INFO - VBM_GM is type NIFTI
2023-03-31 13:29:57,917 - JUNIFER - INFO - Fitting marker Schaefer100x17_TrimMean80
2023-03-31 13:29:57,917 - JUNIFER - INFO - Computing VBM_GM
2023-03-31 13:29:57,917 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2023-03-31 13:29:57,917 - JUNIFER - INFO - Parcellation parameters:
2023-03-31 13:29:57,917 - JUNIFER - INFO -      n_rois: 100
2023-03-31 13:29:57,917 - JUNIFER - INFO -      yeo_networks: 17
2023-03-31 13:29:57,917 - JUNIFER - INFO -      resolution: 2.0
2023-03-31 13:29:57,919 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_100Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2023-03-31 13:29:58,548 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmp9k431lw0/test.sqlite (multiple output)>
2023-03-31 13:29:58,589 - JUNIFER - INFO - Fitting marker Schaefer200x17_Mean
2023-03-31 13:29:58,589 - JUNIFER - INFO - Computing VBM_GM
2023-03-31 13:29:58,590 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2023-03-31 13:29:58,590 - JUNIFER - INFO - Parcellation parameters:
2023-03-31 13:29:58,590 - JUNIFER - INFO -      n_rois: 200
2023-03-31 13:29:58,590 - JUNIFER - INFO -      yeo_networks: 17
2023-03-31 13:29:58,590 - JUNIFER - INFO -      resolution: 2.0
2023-03-31 13:29:58,592 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_200Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2023-03-31 13:29:59,238 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmp9k431lw0/test.sqlite (multiple output)>
2023-03-31 13:29:59,313 - JUNIFER - INFO - Marker collection fitting done
2023-03-31 13:29:59,313 - JUNIFER - INFO - Getting element sub-03
2023-03-31 13:29:59,313 - JUNIFER - INFO - Fitting pipeline
2023-03-31 13:29:59,313 - JUNIFER - INFO - Reading VBM_GM from /home/runner/nilearn_data/oasis1/OAS1_0003_MR1/mwrc1OAS1_0003_MR1_mpr_anon_fslswapdim_bet.nii.gz
2023-03-31 13:29:59,313 - JUNIFER - INFO - VBM_GM is type NIFTI
2023-03-31 13:29:59,314 - JUNIFER - INFO - Fitting marker Schaefer100x17_TrimMean80
2023-03-31 13:29:59,314 - JUNIFER - INFO - Computing VBM_GM
2023-03-31 13:29:59,315 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2023-03-31 13:29:59,315 - JUNIFER - INFO - Parcellation parameters:
2023-03-31 13:29:59,315 - JUNIFER - INFO -      n_rois: 100
2023-03-31 13:29:59,315 - JUNIFER - INFO -      yeo_networks: 17
2023-03-31 13:29:59,315 - JUNIFER - INFO -      resolution: 2.0
2023-03-31 13:29:59,317 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_100Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2023-03-31 13:29:59,934 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmp9k431lw0/test.sqlite (multiple output)>
2023-03-31 13:29:59,976 - JUNIFER - INFO - Fitting marker Schaefer200x17_Mean
2023-03-31 13:29:59,976 - JUNIFER - INFO - Computing VBM_GM
2023-03-31 13:29:59,977 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2023-03-31 13:29:59,977 - JUNIFER - INFO - Parcellation parameters:
2023-03-31 13:29:59,977 - JUNIFER - INFO -      n_rois: 200
2023-03-31 13:29:59,977 - JUNIFER - INFO -      yeo_networks: 17
2023-03-31 13:29:59,977 - JUNIFER - INFO -      resolution: 2.0
2023-03-31 13:29:59,979 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_200Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2023-03-31 13:30:00,640 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmp9k431lw0/test.sqlite (multiple output)>
2023-03-31 13:30:00,717 - JUNIFER - INFO - Marker collection fitting done
2023-03-31 13:30:00,717 - JUNIFER - INFO - Getting element sub-04
2023-03-31 13:30:00,717 - JUNIFER - INFO - Fitting pipeline
2023-03-31 13:30:00,717 - JUNIFER - INFO - Reading VBM_GM from /home/runner/nilearn_data/oasis1/OAS1_0004_MR1/mwrc1OAS1_0004_MR1_mpr_anon_fslswapdim_bet.nii.gz
2023-03-31 13:30:00,717 - JUNIFER - INFO - VBM_GM is type NIFTI
2023-03-31 13:30:00,718 - JUNIFER - INFO - Fitting marker Schaefer100x17_TrimMean80
2023-03-31 13:30:00,718 - JUNIFER - INFO - Computing VBM_GM
2023-03-31 13:30:00,718 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2023-03-31 13:30:00,719 - JUNIFER - INFO - Parcellation parameters:
2023-03-31 13:30:00,719 - JUNIFER - INFO -      n_rois: 100
2023-03-31 13:30:00,719 - JUNIFER - INFO -      yeo_networks: 17
2023-03-31 13:30:00,719 - JUNIFER - INFO -      resolution: 2.0
2023-03-31 13:30:00,721 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_100Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2023-03-31 13:30:01,334 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmp9k431lw0/test.sqlite (multiple output)>
2023-03-31 13:30:01,378 - JUNIFER - INFO - Fitting marker Schaefer200x17_Mean
2023-03-31 13:30:01,378 - JUNIFER - INFO - Computing VBM_GM
2023-03-31 13:30:01,379 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2023-03-31 13:30:01,379 - JUNIFER - INFO - Parcellation parameters:
2023-03-31 13:30:01,379 - JUNIFER - INFO -      n_rois: 200
2023-03-31 13:30:01,379 - JUNIFER - INFO -      yeo_networks: 17
2023-03-31 13:30:01,379 - JUNIFER - INFO -      resolution: 2.0
2023-03-31 13:30:01,381 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_200Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2023-03-31 13:30:02,038 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmp9k431lw0/test.sqlite (multiple output)>
2023-03-31 13:30:02,117 - JUNIFER - INFO - Marker collection fitting done
2023-03-31 13:30:02,117 - JUNIFER - INFO - Getting element sub-05
2023-03-31 13:30:02,117 - JUNIFER - INFO - Fitting pipeline
2023-03-31 13:30:02,117 - JUNIFER - INFO - Reading VBM_GM from /home/runner/nilearn_data/oasis1/OAS1_0005_MR1/mwrc1OAS1_0005_MR1_mpr_anon_fslswapdim_bet.nii.gz
2023-03-31 13:30:02,117 - JUNIFER - INFO - VBM_GM is type NIFTI
2023-03-31 13:30:02,118 - JUNIFER - INFO - Fitting marker Schaefer100x17_TrimMean80
2023-03-31 13:30:02,119 - JUNIFER - INFO - Computing VBM_GM
2023-03-31 13:30:02,119 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2023-03-31 13:30:02,119 - JUNIFER - INFO - Parcellation parameters:
2023-03-31 13:30:02,119 - JUNIFER - INFO -      n_rois: 100
2023-03-31 13:30:02,119 - JUNIFER - INFO -      yeo_networks: 17
2023-03-31 13:30:02,119 - JUNIFER - INFO -      resolution: 2.0
2023-03-31 13:30:02,121 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_100Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2023-03-31 13:30:02,784 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmp9k431lw0/test.sqlite (multiple output)>
2023-03-31 13:30:02,829 - JUNIFER - INFO - Fitting marker Schaefer200x17_Mean
2023-03-31 13:30:02,829 - JUNIFER - INFO - Computing VBM_GM
2023-03-31 13:30:02,829 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2023-03-31 13:30:02,829 - JUNIFER - INFO - Parcellation parameters:
2023-03-31 13:30:02,829 - JUNIFER - INFO -      n_rois: 200
2023-03-31 13:30:02,829 - JUNIFER - INFO -      yeo_networks: 17
2023-03-31 13:30:02,829 - JUNIFER - INFO -      resolution: 2.0
2023-03-31 13:30:02,831 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_200Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2023-03-31 13:30:03,525 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmp9k431lw0/test.sqlite (multiple output)>
2023-03-31 13:30:03,603 - JUNIFER - INFO - Marker collection fitting done
2023-03-31 13:30:03,604 - JUNIFER - INFO - Getting element sub-06
2023-03-31 13:30:03,604 - JUNIFER - INFO - Fitting pipeline
2023-03-31 13:30:03,604 - JUNIFER - INFO - Reading VBM_GM from /home/runner/nilearn_data/oasis1/OAS1_0006_MR1/mwrc1OAS1_0006_MR1_mpr_anon_fslswapdim_bet.nii.gz
2023-03-31 13:30:03,604 - JUNIFER - INFO - VBM_GM is type NIFTI
2023-03-31 13:30:03,605 - JUNIFER - INFO - Fitting marker Schaefer100x17_TrimMean80
2023-03-31 13:30:03,605 - JUNIFER - INFO - Computing VBM_GM
2023-03-31 13:30:03,605 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2023-03-31 13:30:03,605 - JUNIFER - INFO - Parcellation parameters:
2023-03-31 13:30:03,605 - JUNIFER - INFO -      n_rois: 100
2023-03-31 13:30:03,605 - JUNIFER - INFO -      yeo_networks: 17
2023-03-31 13:30:03,605 - JUNIFER - INFO -      resolution: 2.0
2023-03-31 13:30:03,608 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_100Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2023-03-31 13:30:04,248 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmp9k431lw0/test.sqlite (multiple output)>
2023-03-31 13:30:04,291 - JUNIFER - INFO - Fitting marker Schaefer200x17_Mean
2023-03-31 13:30:04,291 - JUNIFER - INFO - Computing VBM_GM
2023-03-31 13:30:04,292 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2023-03-31 13:30:04,292 - JUNIFER - INFO - Parcellation parameters:
2023-03-31 13:30:04,292 - JUNIFER - INFO -      n_rois: 200
2023-03-31 13:30:04,292 - JUNIFER - INFO -      yeo_networks: 17
2023-03-31 13:30:04,292 - JUNIFER - INFO -      resolution: 2.0
2023-03-31 13:30:04,294 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_200Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2023-03-31 13:30:04,957 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmp9k431lw0/test.sqlite (multiple output)>
2023-03-31 13:30:05,034 - JUNIFER - INFO - Marker collection fitting done
2023-03-31 13:30:05,035 - JUNIFER - INFO - Getting element sub-07
2023-03-31 13:30:05,035 - JUNIFER - INFO - Fitting pipeline
2023-03-31 13:30:05,035 - JUNIFER - INFO - Reading VBM_GM from /home/runner/nilearn_data/oasis1/OAS1_0007_MR1/mwrc1OAS1_0007_MR1_mpr_anon_fslswapdim_bet.nii.gz
2023-03-31 13:30:05,035 - JUNIFER - INFO - VBM_GM is type NIFTI
2023-03-31 13:30:05,036 - JUNIFER - INFO - Fitting marker Schaefer100x17_TrimMean80
2023-03-31 13:30:05,036 - JUNIFER - INFO - Computing VBM_GM
2023-03-31 13:30:05,036 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2023-03-31 13:30:05,036 - JUNIFER - INFO - Parcellation parameters:
2023-03-31 13:30:05,036 - JUNIFER - INFO -      n_rois: 100
2023-03-31 13:30:05,036 - JUNIFER - INFO -      yeo_networks: 17
2023-03-31 13:30:05,036 - JUNIFER - INFO -      resolution: 2.0
2023-03-31 13:30:05,039 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_100Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2023-03-31 13:30:05,685 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmp9k431lw0/test.sqlite (multiple output)>
2023-03-31 13:30:05,729 - JUNIFER - INFO - Fitting marker Schaefer200x17_Mean
2023-03-31 13:30:05,730 - JUNIFER - INFO - Computing VBM_GM
2023-03-31 13:30:05,730 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2023-03-31 13:30:05,730 - JUNIFER - INFO - Parcellation parameters:
2023-03-31 13:30:05,730 - JUNIFER - INFO -      n_rois: 200
2023-03-31 13:30:05,730 - JUNIFER - INFO -      yeo_networks: 17
2023-03-31 13:30:05,730 - JUNIFER - INFO -      resolution: 2.0
2023-03-31 13:30:05,732 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_200Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2023-03-31 13:30:06,405 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmp9k431lw0/test.sqlite (multiple output)>
2023-03-31 13:30:06,483 - JUNIFER - INFO - Marker collection fitting done
2023-03-31 13:30:06,483 - JUNIFER - INFO - Getting element sub-08
2023-03-31 13:30:06,483 - JUNIFER - INFO - Fitting pipeline
2023-03-31 13:30:06,483 - JUNIFER - INFO - Reading VBM_GM from /home/runner/nilearn_data/oasis1/OAS1_0009_MR1/mwrc1OAS1_0009_MR1_mpr_anon_fslswapdim_bet.nii.gz
2023-03-31 13:30:06,483 - JUNIFER - INFO - VBM_GM is type NIFTI
2023-03-31 13:30:06,484 - JUNIFER - INFO - Fitting marker Schaefer100x17_TrimMean80
2023-03-31 13:30:06,484 - JUNIFER - INFO - Computing VBM_GM
2023-03-31 13:30:06,484 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2023-03-31 13:30:06,484 - JUNIFER - INFO - Parcellation parameters:
2023-03-31 13:30:06,484 - JUNIFER - INFO -      n_rois: 100
2023-03-31 13:30:06,484 - JUNIFER - INFO -      yeo_networks: 17
2023-03-31 13:30:06,485 - JUNIFER - INFO -      resolution: 2.0
2023-03-31 13:30:06,487 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_100Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2023-03-31 13:30:07,114 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmp9k431lw0/test.sqlite (multiple output)>
2023-03-31 13:30:07,157 - JUNIFER - INFO - Fitting marker Schaefer200x17_Mean
2023-03-31 13:30:07,157 - JUNIFER - INFO - Computing VBM_GM
2023-03-31 13:30:07,157 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2023-03-31 13:30:07,157 - JUNIFER - INFO - Parcellation parameters:
2023-03-31 13:30:07,157 - JUNIFER - INFO -      n_rois: 200
2023-03-31 13:30:07,157 - JUNIFER - INFO -      yeo_networks: 17
2023-03-31 13:30:07,157 - JUNIFER - INFO -      resolution: 2.0
2023-03-31 13:30:07,160 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_200Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2023-03-31 13:30:07,802 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmp9k431lw0/test.sqlite (multiple output)>
2023-03-31 13:30:07,879 - JUNIFER - INFO - Marker collection fitting done
2023-03-31 13:30:07,879 - JUNIFER - INFO - Getting element sub-09
2023-03-31 13:30:07,879 - JUNIFER - INFO - Fitting pipeline
2023-03-31 13:30:07,879 - JUNIFER - INFO - Reading VBM_GM from /home/runner/nilearn_data/oasis1/OAS1_0010_MR1/mwrc1OAS1_0010_MR1_mpr_anon_fslswapdim_bet.nii.gz
2023-03-31 13:30:07,879 - JUNIFER - INFO - VBM_GM is type NIFTI
2023-03-31 13:30:07,880 - JUNIFER - INFO - Fitting marker Schaefer100x17_TrimMean80
2023-03-31 13:30:07,880 - JUNIFER - INFO - Computing VBM_GM
2023-03-31 13:30:07,880 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2023-03-31 13:30:07,880 - JUNIFER - INFO - Parcellation parameters:
2023-03-31 13:30:07,881 - JUNIFER - INFO -      n_rois: 100
2023-03-31 13:30:07,881 - JUNIFER - INFO -      yeo_networks: 17
2023-03-31 13:30:07,881 - JUNIFER - INFO -      resolution: 2.0
2023-03-31 13:30:07,883 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_100Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2023-03-31 13:30:08,562 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmp9k431lw0/test.sqlite (multiple output)>
2023-03-31 13:30:08,607 - JUNIFER - INFO - Fitting marker Schaefer200x17_Mean
2023-03-31 13:30:08,608 - JUNIFER - INFO - Computing VBM_GM
2023-03-31 13:30:08,608 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2023-03-31 13:30:08,608 - JUNIFER - INFO - Parcellation parameters:
2023-03-31 13:30:08,608 - JUNIFER - INFO -      n_rois: 200
2023-03-31 13:30:08,608 - JUNIFER - INFO -      yeo_networks: 17
2023-03-31 13:30:08,608 - JUNIFER - INFO -      resolution: 2.0
2023-03-31 13:30:08,610 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_200Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2023-03-31 13:30:09,276 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmp9k431lw0/test.sqlite (multiple output)>
2023-03-31 13:30:09,354 - JUNIFER - INFO - Marker collection fitting done
2023-03-31 13:30:09,354 - JUNIFER - INFO - Getting element sub-10
2023-03-31 13:30:09,354 - JUNIFER - INFO - Fitting pipeline
2023-03-31 13:30:09,354 - JUNIFER - INFO - Reading VBM_GM from /home/runner/nilearn_data/oasis1/OAS1_0011_MR1/mwrc1OAS1_0011_MR1_mpr_anon_fslswapdim_bet.nii.gz
2023-03-31 13:30:09,354 - JUNIFER - INFO - VBM_GM is type NIFTI
2023-03-31 13:30:09,355 - JUNIFER - INFO - Fitting marker Schaefer100x17_TrimMean80
2023-03-31 13:30:09,355 - JUNIFER - INFO - Computing VBM_GM
2023-03-31 13:30:09,356 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2023-03-31 13:30:09,356 - JUNIFER - INFO - Parcellation parameters:
2023-03-31 13:30:09,356 - JUNIFER - INFO -      n_rois: 100
2023-03-31 13:30:09,356 - JUNIFER - INFO -      yeo_networks: 17
2023-03-31 13:30:09,356 - JUNIFER - INFO -      resolution: 2.0
2023-03-31 13:30:09,358 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_100Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2023-03-31 13:30:09,982 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmp9k431lw0/test.sqlite (multiple output)>
2023-03-31 13:30:10,024 - JUNIFER - INFO - Fitting marker Schaefer200x17_Mean
2023-03-31 13:30:10,025 - JUNIFER - INFO - Computing VBM_GM
2023-03-31 13:30:10,025 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2023-03-31 13:30:10,025 - JUNIFER - INFO - Parcellation parameters:
2023-03-31 13:30:10,025 - JUNIFER - INFO -      n_rois: 200
2023-03-31 13:30:10,025 - JUNIFER - INFO -      yeo_networks: 17
2023-03-31 13:30:10,025 - JUNIFER - INFO -      resolution: 2.0
2023-03-31 13:30:10,027 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_200Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2023-03-31 13:30:10,673 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmp9k431lw0/test.sqlite (multiple output)>
2023-03-31 13:30:10,749 - JUNIFER - INFO - Marker collection fitting done
2023-03-31 13:30:10,749 - JUNIFER - INFO - Collecting data using SQLiteFeatureStorage
2023-03-31 13:30:10,749 - JUNIFER - INFO - Collecting data from /tmp/tmp9k431lw0/*test.sqlite

file: 0it [00:00, ?it/s]

feature:   0%|          | 0/2 [00:00<?, ?it/s]

feature: 100%|##########| 2/2 [00:00<00:00,  9.52it/s]
feature: 100%|##########| 2/2 [00:00<00:00,  9.50it/s]

file: 1it [00:00,  4.42it/s]

feature:   0%|          | 0/2 [00:00<?, ?it/s]

feature: 100%|##########| 2/2 [00:00<00:00, 10.70it/s]
feature: 100%|##########| 2/2 [00:00<00:00, 10.68it/s]

file: 2it [00:00,  4.69it/s]

feature:   0%|          | 0/2 [00:00<?, ?it/s]

feature: 100%|##########| 2/2 [00:00<00:00, 10.66it/s]
feature: 100%|##########| 2/2 [00:00<00:00, 10.64it/s]

file: 3it [00:00,  4.77it/s]

feature:   0%|          | 0/2 [00:00<?, ?it/s]

feature: 100%|##########| 2/2 [00:00<00:00, 10.74it/s]
feature: 100%|##########| 2/2 [00:00<00:00, 10.72it/s]

file: 4it [00:00,  4.81it/s]

feature:   0%|          | 0/2 [00:00<?, ?it/s]

feature: 100%|##########| 2/2 [00:00<00:00, 10.73it/s]
feature: 100%|##########| 2/2 [00:00<00:00, 10.70it/s]

file: 5it [00:01,  4.84it/s]

feature:   0%|          | 0/2 [00:00<?, ?it/s]

feature: 100%|##########| 2/2 [00:00<00:00, 10.78it/s]
feature: 100%|##########| 2/2 [00:00<00:00, 10.76it/s]

file: 6it [00:01,  4.86it/s]

feature:   0%|          | 0/2 [00:00<?, ?it/s]

feature: 100%|##########| 2/2 [00:00<00:00, 10.57it/s]
feature: 100%|##########| 2/2 [00:00<00:00, 10.55it/s]

file: 7it [00:01,  4.85it/s]

feature:   0%|          | 0/2 [00:00<?, ?it/s]

feature: 100%|##########| 2/2 [00:00<00:00, 10.65it/s]
feature: 100%|##########| 2/2 [00:00<00:00, 10.63it/s]

file: 8it [00:01,  4.85it/s]

feature:   0%|          | 0/2 [00:00<?, ?it/s]

feature: 100%|##########| 2/2 [00:00<00:00,  6.91it/s]
feature: 100%|##########| 2/2 [00:00<00:00,  6.90it/s]

file: 9it [00:01,  4.20it/s]

feature:   0%|          | 0/2 [00:00<?, ?it/s]

feature: 100%|##########| 2/2 [00:00<00:00, 10.33it/s]
feature: 100%|##########| 2/2 [00:00<00:00, 10.31it/s]

file: 10it [00:02,  4.35it/s]
file: 10it [00:02,  4.58it/s]
2023-03-31 13:30:12,933 - JUNIFER - INFO - Collect done

Using julearn for machine learning: We predict the age given our vbm features and sex as a confound.

X = list(df_vbm.columns)
df_vbm[y] = age
df_vbm[confound] = sex

scores = run_cross_validation(
    X=X,
    confounds=confound,
    y=y,
    data=df_vbm,
    problem_type="regression",
    model="ridge",
    cv=3,
    preprocess_X=["zscore", "remove_confound"],
)
print(scores)
   fit_time  score_time  test_score  repeat  fold
0  0.165060    0.024141   -0.799588       0     0
1  0.158438    0.023678 -313.683244       0     1
2  0.157643    0.023585    0.187337       0     2

Interpretation of results: Doing machine learning with only 10 datapoints is not meaningful. This explains the big variation in scores for different cross-validation folds.

Total running time of the script: ( 0 minutes 17.270 seconds)

Gallery generated by Sphinx-Gallery