7.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")
2022-12-20 14:34:34,271 - JUNIFER - INFO - ===== Lib Versions =====
2022-12-20 14:34:34,272 - JUNIFER - INFO - numpy: 1.23.5
2022-12-20 14:34:34,272 - JUNIFER - INFO - scipy: 1.9.3
2022-12-20 14:34:34,272 - JUNIFER - INFO - pandas: 1.5.2
2022-12-20 14:34:34,272 - JUNIFER - INFO - nilearn: 0.9.2
2022-12-20 14:34:34,272 - JUNIFER - INFO - nibabel: 4.0.2
2022-12-20 14:34:34,272 - JUNIFER - INFO - junifer: 0.0.1
2022-12-20 14:34:34,272 - 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.9/x64/lib/python3.10/site-packages/nilearn/datasets/struct.py:774: 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.9/x64/lib/python3.10/site-packages/nilearn/datasets/struct.py:774: 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)
2022-12-20 14:34:34,297 - JUNIFER - INFO - Getting element sub-01
2022-12-20 14:34:34,297 - JUNIFER - INFO - Fitting pipeline
2022-12-20 14:34:34,298 - JUNIFER - INFO - Reading VBM_GM from /home/runner/nilearn_data/oasis1/OAS1_0001_MR1/mwrc1OAS1_0001_MR1_mpr_anon_fslswapdim_bet.nii.gz
2022-12-20 14:34:34,298 - JUNIFER - INFO - VBM_GM is type NIFTI
2022-12-20 14:34:34,299 - JUNIFER - INFO - Fitting marker Schaefer100x17_TrimMean80
2022-12-20 14:34:34,299 - JUNIFER - INFO - Computing VBM_GM
2022-12-20 14:34:34,299 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2022-12-20 14:34:34,299 - JUNIFER - INFO - Parcellatikon parameters:
2022-12-20 14:34:34,299 - JUNIFER - INFO -      n_rois: 100
2022-12-20 14:34:34,299 - JUNIFER - INFO -      yeo_networks: 17
2022-12-20 14:34:34,299 - JUNIFER - INFO -      resolution: 2.0
2022-12-20 14:34:34,301 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_100Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2022-12-20 14:34:35,140 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmp1znc2mn6/test.sqlite (multiple output)>
2022-12-20 14:34:35,196 - JUNIFER - INFO - Fitting marker Schaefer200x17_Mean
2022-12-20 14:34:35,196 - JUNIFER - INFO - Computing VBM_GM
2022-12-20 14:34:35,197 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2022-12-20 14:34:35,197 - JUNIFER - INFO - Parcellatikon parameters:
2022-12-20 14:34:35,197 - JUNIFER - INFO -      n_rois: 200
2022-12-20 14:34:35,197 - JUNIFER - INFO -      yeo_networks: 17
2022-12-20 14:34:35,197 - JUNIFER - INFO -      resolution: 2.0
2022-12-20 14:34:35,199 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_200Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2022-12-20 14:34:36,048 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmp1znc2mn6/test.sqlite (multiple output)>
2022-12-20 14:34:36,140 - JUNIFER - INFO - Marker collection fitting done
2022-12-20 14:34:36,141 - JUNIFER - INFO - Getting element sub-02
2022-12-20 14:34:36,141 - JUNIFER - INFO - Fitting pipeline
2022-12-20 14:34:36,141 - JUNIFER - INFO - Reading VBM_GM from /home/runner/nilearn_data/oasis1/OAS1_0002_MR1/mwrc1OAS1_0002_MR1_mpr_anon_fslswapdim_bet.nii.gz
2022-12-20 14:34:36,141 - JUNIFER - INFO - VBM_GM is type NIFTI
2022-12-20 14:34:36,142 - JUNIFER - INFO - Fitting marker Schaefer100x17_TrimMean80
2022-12-20 14:34:36,142 - JUNIFER - INFO - Computing VBM_GM
2022-12-20 14:34:36,142 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2022-12-20 14:34:36,142 - JUNIFER - INFO - Parcellatikon parameters:
2022-12-20 14:34:36,142 - JUNIFER - INFO -      n_rois: 100
2022-12-20 14:34:36,143 - JUNIFER - INFO -      yeo_networks: 17
2022-12-20 14:34:36,143 - JUNIFER - INFO -      resolution: 2.0
2022-12-20 14:34:36,145 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_100Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2022-12-20 14:34:36,975 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmp1znc2mn6/test.sqlite (multiple output)>
2022-12-20 14:34:37,031 - JUNIFER - INFO - Fitting marker Schaefer200x17_Mean
2022-12-20 14:34:37,031 - JUNIFER - INFO - Computing VBM_GM
2022-12-20 14:34:37,031 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2022-12-20 14:34:37,031 - JUNIFER - INFO - Parcellatikon parameters:
2022-12-20 14:34:37,031 - JUNIFER - INFO -      n_rois: 200
2022-12-20 14:34:37,031 - JUNIFER - INFO -      yeo_networks: 17
2022-12-20 14:34:37,031 - JUNIFER - INFO -      resolution: 2.0
2022-12-20 14:34:37,034 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_200Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2022-12-20 14:34:37,900 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmp1znc2mn6/test.sqlite (multiple output)>
2022-12-20 14:34:37,989 - JUNIFER - INFO - Marker collection fitting done
2022-12-20 14:34:37,989 - JUNIFER - INFO - Getting element sub-03
2022-12-20 14:34:37,990 - JUNIFER - INFO - Fitting pipeline
2022-12-20 14:34:37,990 - JUNIFER - INFO - Reading VBM_GM from /home/runner/nilearn_data/oasis1/OAS1_0003_MR1/mwrc1OAS1_0003_MR1_mpr_anon_fslswapdim_bet.nii.gz
2022-12-20 14:34:37,990 - JUNIFER - INFO - VBM_GM is type NIFTI
2022-12-20 14:34:37,991 - JUNIFER - INFO - Fitting marker Schaefer100x17_TrimMean80
2022-12-20 14:34:37,991 - JUNIFER - INFO - Computing VBM_GM
2022-12-20 14:34:37,991 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2022-12-20 14:34:37,991 - JUNIFER - INFO - Parcellatikon parameters:
2022-12-20 14:34:37,991 - JUNIFER - INFO -      n_rois: 100
2022-12-20 14:34:37,991 - JUNIFER - INFO -      yeo_networks: 17
2022-12-20 14:34:37,992 - JUNIFER - INFO -      resolution: 2.0
2022-12-20 14:34:37,994 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_100Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2022-12-20 14:34:38,825 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmp1znc2mn6/test.sqlite (multiple output)>
2022-12-20 14:34:38,877 - JUNIFER - INFO - Fitting marker Schaefer200x17_Mean
2022-12-20 14:34:38,878 - JUNIFER - INFO - Computing VBM_GM
2022-12-20 14:34:38,878 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2022-12-20 14:34:38,879 - JUNIFER - INFO - Parcellatikon parameters:
2022-12-20 14:34:38,879 - JUNIFER - INFO -      n_rois: 200
2022-12-20 14:34:38,879 - JUNIFER - INFO -      yeo_networks: 17
2022-12-20 14:34:38,879 - JUNIFER - INFO -      resolution: 2.0
2022-12-20 14:34:38,881 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_200Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2022-12-20 14:34:39,742 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmp1znc2mn6/test.sqlite (multiple output)>
2022-12-20 14:34:39,833 - JUNIFER - INFO - Marker collection fitting done
2022-12-20 14:34:39,834 - JUNIFER - INFO - Getting element sub-04
2022-12-20 14:34:39,834 - JUNIFER - INFO - Fitting pipeline
2022-12-20 14:34:39,834 - JUNIFER - INFO - Reading VBM_GM from /home/runner/nilearn_data/oasis1/OAS1_0004_MR1/mwrc1OAS1_0004_MR1_mpr_anon_fslswapdim_bet.nii.gz
2022-12-20 14:34:39,834 - JUNIFER - INFO - VBM_GM is type NIFTI
2022-12-20 14:34:39,835 - JUNIFER - INFO - Fitting marker Schaefer100x17_TrimMean80
2022-12-20 14:34:39,835 - JUNIFER - INFO - Computing VBM_GM
2022-12-20 14:34:39,835 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2022-12-20 14:34:39,835 - JUNIFER - INFO - Parcellatikon parameters:
2022-12-20 14:34:39,835 - JUNIFER - INFO -      n_rois: 100
2022-12-20 14:34:39,835 - JUNIFER - INFO -      yeo_networks: 17
2022-12-20 14:34:39,835 - JUNIFER - INFO -      resolution: 2.0
2022-12-20 14:34:39,838 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_100Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2022-12-20 14:34:40,668 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmp1znc2mn6/test.sqlite (multiple output)>
2022-12-20 14:34:40,722 - JUNIFER - INFO - Fitting marker Schaefer200x17_Mean
2022-12-20 14:34:40,722 - JUNIFER - INFO - Computing VBM_GM
2022-12-20 14:34:40,722 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2022-12-20 14:34:40,723 - JUNIFER - INFO - Parcellatikon parameters:
2022-12-20 14:34:40,723 - JUNIFER - INFO -      n_rois: 200
2022-12-20 14:34:40,723 - JUNIFER - INFO -      yeo_networks: 17
2022-12-20 14:34:40,723 - JUNIFER - INFO -      resolution: 2.0
2022-12-20 14:34:40,725 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_200Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2022-12-20 14:34:41,567 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmp1znc2mn6/test.sqlite (multiple output)>
2022-12-20 14:34:41,658 - JUNIFER - INFO - Marker collection fitting done
2022-12-20 14:34:41,658 - JUNIFER - INFO - Getting element sub-05
2022-12-20 14:34:41,658 - JUNIFER - INFO - Fitting pipeline
2022-12-20 14:34:41,658 - JUNIFER - INFO - Reading VBM_GM from /home/runner/nilearn_data/oasis1/OAS1_0005_MR1/mwrc1OAS1_0005_MR1_mpr_anon_fslswapdim_bet.nii.gz
2022-12-20 14:34:41,658 - JUNIFER - INFO - VBM_GM is type NIFTI
2022-12-20 14:34:41,659 - JUNIFER - INFO - Fitting marker Schaefer100x17_TrimMean80
2022-12-20 14:34:41,660 - JUNIFER - INFO - Computing VBM_GM
2022-12-20 14:34:41,660 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2022-12-20 14:34:41,660 - JUNIFER - INFO - Parcellatikon parameters:
2022-12-20 14:34:41,660 - JUNIFER - INFO -      n_rois: 100
2022-12-20 14:34:41,660 - JUNIFER - INFO -      yeo_networks: 17
2022-12-20 14:34:41,660 - JUNIFER - INFO -      resolution: 2.0
2022-12-20 14:34:41,662 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_100Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2022-12-20 14:34:42,487 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmp1znc2mn6/test.sqlite (multiple output)>
2022-12-20 14:34:42,540 - JUNIFER - INFO - Fitting marker Schaefer200x17_Mean
2022-12-20 14:34:42,540 - JUNIFER - INFO - Computing VBM_GM
2022-12-20 14:34:42,540 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2022-12-20 14:34:42,540 - JUNIFER - INFO - Parcellatikon parameters:
2022-12-20 14:34:42,540 - JUNIFER - INFO -      n_rois: 200
2022-12-20 14:34:42,541 - JUNIFER - INFO -      yeo_networks: 17
2022-12-20 14:34:42,541 - JUNIFER - INFO -      resolution: 2.0
2022-12-20 14:34:42,543 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_200Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2022-12-20 14:34:43,408 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmp1znc2mn6/test.sqlite (multiple output)>
2022-12-20 14:34:43,499 - JUNIFER - INFO - Marker collection fitting done
2022-12-20 14:34:43,499 - JUNIFER - INFO - Getting element sub-06
2022-12-20 14:34:43,499 - JUNIFER - INFO - Fitting pipeline
2022-12-20 14:34:43,499 - JUNIFER - INFO - Reading VBM_GM from /home/runner/nilearn_data/oasis1/OAS1_0006_MR1/mwrc1OAS1_0006_MR1_mpr_anon_fslswapdim_bet.nii.gz
2022-12-20 14:34:43,500 - JUNIFER - INFO - VBM_GM is type NIFTI
2022-12-20 14:34:43,501 - JUNIFER - INFO - Fitting marker Schaefer100x17_TrimMean80
2022-12-20 14:34:43,501 - JUNIFER - INFO - Computing VBM_GM
2022-12-20 14:34:43,501 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2022-12-20 14:34:43,501 - JUNIFER - INFO - Parcellatikon parameters:
2022-12-20 14:34:43,501 - JUNIFER - INFO -      n_rois: 100
2022-12-20 14:34:43,501 - JUNIFER - INFO -      yeo_networks: 17
2022-12-20 14:34:43,501 - JUNIFER - INFO -      resolution: 2.0
2022-12-20 14:34:43,503 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_100Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2022-12-20 14:34:44,363 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmp1znc2mn6/test.sqlite (multiple output)>
2022-12-20 14:34:44,423 - JUNIFER - INFO - Fitting marker Schaefer200x17_Mean
2022-12-20 14:34:44,423 - JUNIFER - INFO - Computing VBM_GM
2022-12-20 14:34:44,423 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2022-12-20 14:34:44,423 - JUNIFER - INFO - Parcellatikon parameters:
2022-12-20 14:34:44,423 - JUNIFER - INFO -      n_rois: 200
2022-12-20 14:34:44,424 - JUNIFER - INFO -      yeo_networks: 17
2022-12-20 14:34:44,424 - JUNIFER - INFO -      resolution: 2.0
2022-12-20 14:34:44,426 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_200Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2022-12-20 14:34:45,286 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmp1znc2mn6/test.sqlite (multiple output)>
2022-12-20 14:34:45,375 - JUNIFER - INFO - Marker collection fitting done
2022-12-20 14:34:45,375 - JUNIFER - INFO - Getting element sub-07
2022-12-20 14:34:45,375 - JUNIFER - INFO - Fitting pipeline
2022-12-20 14:34:45,375 - JUNIFER - INFO - Reading VBM_GM from /home/runner/nilearn_data/oasis1/OAS1_0007_MR1/mwrc1OAS1_0007_MR1_mpr_anon_fslswapdim_bet.nii.gz
2022-12-20 14:34:45,375 - JUNIFER - INFO - VBM_GM is type NIFTI
2022-12-20 14:34:45,376 - JUNIFER - INFO - Fitting marker Schaefer100x17_TrimMean80
2022-12-20 14:34:45,377 - JUNIFER - INFO - Computing VBM_GM
2022-12-20 14:34:45,377 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2022-12-20 14:34:45,377 - JUNIFER - INFO - Parcellatikon parameters:
2022-12-20 14:34:45,377 - JUNIFER - INFO -      n_rois: 100
2022-12-20 14:34:45,377 - JUNIFER - INFO -      yeo_networks: 17
2022-12-20 14:34:45,377 - JUNIFER - INFO -      resolution: 2.0
2022-12-20 14:34:45,379 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_100Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2022-12-20 14:34:46,206 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmp1znc2mn6/test.sqlite (multiple output)>
2022-12-20 14:34:46,261 - JUNIFER - INFO - Fitting marker Schaefer200x17_Mean
2022-12-20 14:34:46,261 - JUNIFER - INFO - Computing VBM_GM
2022-12-20 14:34:46,262 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2022-12-20 14:34:46,262 - JUNIFER - INFO - Parcellatikon parameters:
2022-12-20 14:34:46,262 - JUNIFER - INFO -      n_rois: 200
2022-12-20 14:34:46,262 - JUNIFER - INFO -      yeo_networks: 17
2022-12-20 14:34:46,262 - JUNIFER - INFO -      resolution: 2.0
2022-12-20 14:34:46,264 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_200Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2022-12-20 14:34:47,098 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmp1znc2mn6/test.sqlite (multiple output)>
2022-12-20 14:34:47,187 - JUNIFER - INFO - Marker collection fitting done
2022-12-20 14:34:47,187 - JUNIFER - INFO - Getting element sub-08
2022-12-20 14:34:47,187 - JUNIFER - INFO - Fitting pipeline
2022-12-20 14:34:47,188 - JUNIFER - INFO - Reading VBM_GM from /home/runner/nilearn_data/oasis1/OAS1_0009_MR1/mwrc1OAS1_0009_MR1_mpr_anon_fslswapdim_bet.nii.gz
2022-12-20 14:34:47,188 - JUNIFER - INFO - VBM_GM is type NIFTI
2022-12-20 14:34:47,189 - JUNIFER - INFO - Fitting marker Schaefer100x17_TrimMean80
2022-12-20 14:34:47,189 - JUNIFER - INFO - Computing VBM_GM
2022-12-20 14:34:47,189 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2022-12-20 14:34:47,189 - JUNIFER - INFO - Parcellatikon parameters:
2022-12-20 14:34:47,189 - JUNIFER - INFO -      n_rois: 100
2022-12-20 14:34:47,189 - JUNIFER - INFO -      yeo_networks: 17
2022-12-20 14:34:47,189 - JUNIFER - INFO -      resolution: 2.0
2022-12-20 14:34:47,191 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_100Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2022-12-20 14:34:48,015 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmp1znc2mn6/test.sqlite (multiple output)>
2022-12-20 14:34:48,069 - JUNIFER - INFO - Fitting marker Schaefer200x17_Mean
2022-12-20 14:34:48,069 - JUNIFER - INFO - Computing VBM_GM
2022-12-20 14:34:48,070 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2022-12-20 14:34:48,070 - JUNIFER - INFO - Parcellatikon parameters:
2022-12-20 14:34:48,070 - JUNIFER - INFO -      n_rois: 200
2022-12-20 14:34:48,070 - JUNIFER - INFO -      yeo_networks: 17
2022-12-20 14:34:48,070 - JUNIFER - INFO -      resolution: 2.0
2022-12-20 14:34:48,073 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_200Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2022-12-20 14:34:48,911 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmp1znc2mn6/test.sqlite (multiple output)>
2022-12-20 14:34:48,998 - JUNIFER - INFO - Marker collection fitting done
2022-12-20 14:34:48,998 - JUNIFER - INFO - Getting element sub-09
2022-12-20 14:34:48,998 - JUNIFER - INFO - Fitting pipeline
2022-12-20 14:34:48,999 - JUNIFER - INFO - Reading VBM_GM from /home/runner/nilearn_data/oasis1/OAS1_0010_MR1/mwrc1OAS1_0010_MR1_mpr_anon_fslswapdim_bet.nii.gz
2022-12-20 14:34:48,999 - JUNIFER - INFO - VBM_GM is type NIFTI
2022-12-20 14:34:49,000 - JUNIFER - INFO - Fitting marker Schaefer100x17_TrimMean80
2022-12-20 14:34:49,000 - JUNIFER - INFO - Computing VBM_GM
2022-12-20 14:34:49,000 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2022-12-20 14:34:49,000 - JUNIFER - INFO - Parcellatikon parameters:
2022-12-20 14:34:49,000 - JUNIFER - INFO -      n_rois: 100
2022-12-20 14:34:49,000 - JUNIFER - INFO -      yeo_networks: 17
2022-12-20 14:34:49,000 - JUNIFER - INFO -      resolution: 2.0
2022-12-20 14:34:49,003 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_100Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2022-12-20 14:34:49,878 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmp1znc2mn6/test.sqlite (multiple output)>
2022-12-20 14:34:49,931 - JUNIFER - INFO - Fitting marker Schaefer200x17_Mean
2022-12-20 14:34:49,932 - JUNIFER - INFO - Computing VBM_GM
2022-12-20 14:34:49,932 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2022-12-20 14:34:49,932 - JUNIFER - INFO - Parcellatikon parameters:
2022-12-20 14:34:49,932 - JUNIFER - INFO -      n_rois: 200
2022-12-20 14:34:49,932 - JUNIFER - INFO -      yeo_networks: 17
2022-12-20 14:34:49,932 - JUNIFER - INFO -      resolution: 2.0
2022-12-20 14:34:49,934 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_200Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2022-12-20 14:34:50,807 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmp1znc2mn6/test.sqlite (multiple output)>
2022-12-20 14:34:50,893 - JUNIFER - INFO - Marker collection fitting done
2022-12-20 14:34:50,893 - JUNIFER - INFO - Getting element sub-10
2022-12-20 14:34:50,893 - JUNIFER - INFO - Fitting pipeline
2022-12-20 14:34:50,893 - JUNIFER - INFO - Reading VBM_GM from /home/runner/nilearn_data/oasis1/OAS1_0011_MR1/mwrc1OAS1_0011_MR1_mpr_anon_fslswapdim_bet.nii.gz
2022-12-20 14:34:50,894 - JUNIFER - INFO - VBM_GM is type NIFTI
2022-12-20 14:34:50,895 - JUNIFER - INFO - Fitting marker Schaefer100x17_TrimMean80
2022-12-20 14:34:50,895 - JUNIFER - INFO - Computing VBM_GM
2022-12-20 14:34:50,895 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2022-12-20 14:34:50,895 - JUNIFER - INFO - Parcellatikon parameters:
2022-12-20 14:34:50,895 - JUNIFER - INFO -      n_rois: 100
2022-12-20 14:34:50,895 - JUNIFER - INFO -      yeo_networks: 17
2022-12-20 14:34:50,895 - JUNIFER - INFO -      resolution: 2.0
2022-12-20 14:34:50,897 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_100Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2022-12-20 14:34:51,717 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmp1znc2mn6/test.sqlite (multiple output)>
2022-12-20 14:34:51,770 - JUNIFER - INFO - Fitting marker Schaefer200x17_Mean
2022-12-20 14:34:51,770 - JUNIFER - INFO - Computing VBM_GM
2022-12-20 14:34:51,770 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2022-12-20 14:34:51,770 - JUNIFER - INFO - Parcellatikon parameters:
2022-12-20 14:34:51,771 - JUNIFER - INFO -      n_rois: 200
2022-12-20 14:34:51,771 - JUNIFER - INFO -      yeo_networks: 17
2022-12-20 14:34:51,771 - JUNIFER - INFO -      resolution: 2.0
2022-12-20 14:34:51,773 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_200Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2022-12-20 14:34:52,623 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmp1znc2mn6/test.sqlite (multiple output)>
2022-12-20 14:34:52,710 - JUNIFER - INFO - Marker collection fitting done
2022-12-20 14:34:52,711 - JUNIFER - INFO - Collecting data using SQLiteFeatureStorage
2022-12-20 14:34:52,711 - JUNIFER - INFO - Collecting data from /tmp/tmp1znc2mn6/*test.sqlite

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

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

feature: 100%|##########| 2/2 [00:00<00:00,  8.18it/s]
feature: 100%|##########| 2/2 [00:00<00:00,  8.17it/s]

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

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

feature: 100%|##########| 2/2 [00:00<00:00,  9.55it/s]
feature: 100%|##########| 2/2 [00:00<00:00,  9.53it/s]

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

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

feature: 100%|##########| 2/2 [00:00<00:00,  9.46it/s]
feature: 100%|##########| 2/2 [00:00<00:00,  9.44it/s]

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

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

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

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

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

feature: 100%|##########| 2/2 [00:00<00:00,  9.58it/s]
feature: 100%|##########| 2/2 [00:00<00:00,  9.56it/s]

file: 5it [00:01,  4.32it/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.49it/s]

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

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

feature:  50%|#####     | 1/2 [00:00<00:00,  4.63it/s]

feature: 100%|##########| 2/2 [00:00<00:00,  5.94it/s]
feature: 100%|##########| 2/2 [00:00<00:00,  5.69it/s]

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

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

feature: 100%|##########| 2/2 [00:00<00:00,  9.61it/s]
feature: 100%|##########| 2/2 [00:00<00:00,  9.59it/s]

file: 8it [00:02,  3.84it/s]

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

feature: 100%|##########| 2/2 [00:00<00:00,  9.49it/s]
feature: 100%|##########| 2/2 [00:00<00:00,  9.47it/s]

file: 9it [00:02,  3.99it/s]

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

feature: 100%|##########| 2/2 [00:00<00:00,  9.62it/s]
feature: 100%|##########| 2/2 [00:00<00:00,  9.60it/s]

file: 10it [00:02,  4.11it/s]
file: 10it [00:02,  4.06it/s]
2022-12-20 14:34:55,172 - 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.183844    0.024389   -0.872465       0     0
1  0.181063    0.024316 -139.601195       0     1
2  0.178574    0.024312   -0.261410       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 21.740 seconds)

Gallery generated by Sphinx-Gallery