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, PipelineCreator

import junifer.testing.registry  # noqa: F401
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-07-24 05:10:14,122 - JUNIFER - INFO - ===== Lib Versions =====
2023-07-24 05:10:14,122 - JUNIFER - INFO - numpy: 1.25.1
2023-07-24 05:10:14,122 - JUNIFER - INFO - scipy: 1.11.1
2023-07-24 05:10:14,122 - JUNIFER - INFO - pandas: 1.5.3
2023-07-24 05:10:14,122 - JUNIFER - INFO - nilearn: 0.10.0
2023-07-24 05:10:14,122 - JUNIFER - INFO - nibabel: 4.0.2
2023-07-24 05:10:14,122 - JUNIFER - INFO - junifer: 0.0.3
2023-07-24 05:10:14,122 - 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.12/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.12/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-07-24 05:10:14,151 - JUNIFER - INFO - Getting element sub-01
2023-07-24 05:10:14,151 - JUNIFER - INFO - Fitting pipeline
2023-07-24 05:10:14,151 - JUNIFER - INFO - Reading VBM_GM from /home/runner/nilearn_data/oasis1/OAS1_0001_MR1/mwrc1OAS1_0001_MR1_mpr_anon_fslswapdim_bet.nii.gz
2023-07-24 05:10:14,151 - JUNIFER - INFO - VBM_GM is type NIFTI
2023-07-24 05:10:14,152 - JUNIFER - INFO - Fitting marker Schaefer100x17_TrimMean80
2023-07-24 05:10:14,153 - JUNIFER - INFO - Computing VBM_GM
2023-07-24 05:10:14,153 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2023-07-24 05:10:14,153 - JUNIFER - INFO - Parcellation parameters:
2023-07-24 05:10:14,153 - JUNIFER - INFO -      resolution: 2.0
2023-07-24 05:10:14,153 - JUNIFER - INFO -      n_rois: 100
2023-07-24 05:10:14,153 - JUNIFER - INFO -      yeo_networks: 17
2023-07-24 05:10:14,155 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_100Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2023-07-24 05:10:15,027 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmpomu17qac/test.sqlite (multiple output)>
2023-07-24 05:10:15,083 - JUNIFER - INFO - Fitting marker Schaefer200x17_Mean
2023-07-24 05:10:15,084 - JUNIFER - INFO - Computing VBM_GM
2023-07-24 05:10:15,084 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2023-07-24 05:10:15,084 - JUNIFER - INFO - Parcellation parameters:
2023-07-24 05:10:15,084 - JUNIFER - INFO -      resolution: 2.0
2023-07-24 05:10:15,084 - JUNIFER - INFO -      n_rois: 200
2023-07-24 05:10:15,084 - JUNIFER - INFO -      yeo_networks: 17
2023-07-24 05:10:15,087 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_200Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2023-07-24 05:10:15,989 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmpomu17qac/test.sqlite (multiple output)>
2023-07-24 05:10:16,087 - JUNIFER - INFO - Marker collection fitting done
2023-07-24 05:10:16,087 - JUNIFER - INFO - Getting element sub-02
2023-07-24 05:10:16,087 - JUNIFER - INFO - Fitting pipeline
2023-07-24 05:10:16,087 - JUNIFER - INFO - Reading VBM_GM from /home/runner/nilearn_data/oasis1/OAS1_0002_MR1/mwrc1OAS1_0002_MR1_mpr_anon_fslswapdim_bet.nii.gz
2023-07-24 05:10:16,087 - JUNIFER - INFO - VBM_GM is type NIFTI
2023-07-24 05:10:16,089 - JUNIFER - INFO - Fitting marker Schaefer100x17_TrimMean80
2023-07-24 05:10:16,089 - JUNIFER - INFO - Computing VBM_GM
2023-07-24 05:10:16,089 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2023-07-24 05:10:16,089 - JUNIFER - INFO - Parcellation parameters:
2023-07-24 05:10:16,090 - JUNIFER - INFO -      resolution: 2.0
2023-07-24 05:10:16,090 - JUNIFER - INFO -      n_rois: 100
2023-07-24 05:10:16,090 - JUNIFER - INFO -      yeo_networks: 17
2023-07-24 05:10:16,093 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_100Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2023-07-24 05:10:16,947 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmpomu17qac/test.sqlite (multiple output)>
2023-07-24 05:10:17,004 - JUNIFER - INFO - Fitting marker Schaefer200x17_Mean
2023-07-24 05:10:17,004 - JUNIFER - INFO - Computing VBM_GM
2023-07-24 05:10:17,005 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2023-07-24 05:10:17,005 - JUNIFER - INFO - Parcellation parameters:
2023-07-24 05:10:17,005 - JUNIFER - INFO -      resolution: 2.0
2023-07-24 05:10:17,005 - JUNIFER - INFO -      n_rois: 200
2023-07-24 05:10:17,005 - JUNIFER - INFO -      yeo_networks: 17
2023-07-24 05:10:17,009 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_200Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2023-07-24 05:10:17,882 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmpomu17qac/test.sqlite (multiple output)>
2023-07-24 05:10:17,984 - JUNIFER - INFO - Marker collection fitting done
2023-07-24 05:10:17,984 - JUNIFER - INFO - Getting element sub-03
2023-07-24 05:10:17,984 - JUNIFER - INFO - Fitting pipeline
2023-07-24 05:10:17,984 - JUNIFER - INFO - Reading VBM_GM from /home/runner/nilearn_data/oasis1/OAS1_0003_MR1/mwrc1OAS1_0003_MR1_mpr_anon_fslswapdim_bet.nii.gz
2023-07-24 05:10:17,985 - JUNIFER - INFO - VBM_GM is type NIFTI
2023-07-24 05:10:17,986 - JUNIFER - INFO - Fitting marker Schaefer100x17_TrimMean80
2023-07-24 05:10:17,986 - JUNIFER - INFO - Computing VBM_GM
2023-07-24 05:10:17,986 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2023-07-24 05:10:17,986 - JUNIFER - INFO - Parcellation parameters:
2023-07-24 05:10:17,987 - JUNIFER - INFO -      resolution: 2.0
2023-07-24 05:10:17,987 - JUNIFER - INFO -      n_rois: 100
2023-07-24 05:10:17,987 - JUNIFER - INFO -      yeo_networks: 17
2023-07-24 05:10:17,989 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_100Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2023-07-24 05:10:18,860 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmpomu17qac/test.sqlite (multiple output)>
2023-07-24 05:10:18,920 - JUNIFER - INFO - Fitting marker Schaefer200x17_Mean
2023-07-24 05:10:18,920 - JUNIFER - INFO - Computing VBM_GM
2023-07-24 05:10:18,920 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2023-07-24 05:10:18,920 - JUNIFER - INFO - Parcellation parameters:
2023-07-24 05:10:18,920 - JUNIFER - INFO -      resolution: 2.0
2023-07-24 05:10:18,920 - JUNIFER - INFO -      n_rois: 200
2023-07-24 05:10:18,920 - JUNIFER - INFO -      yeo_networks: 17
2023-07-24 05:10:18,923 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_200Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2023-07-24 05:10:19,784 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmpomu17qac/test.sqlite (multiple output)>
2023-07-24 05:10:19,877 - JUNIFER - INFO - Marker collection fitting done
2023-07-24 05:10:19,877 - JUNIFER - INFO - Getting element sub-04
2023-07-24 05:10:19,877 - JUNIFER - INFO - Fitting pipeline
2023-07-24 05:10:19,877 - JUNIFER - INFO - Reading VBM_GM from /home/runner/nilearn_data/oasis1/OAS1_0004_MR1/mwrc1OAS1_0004_MR1_mpr_anon_fslswapdim_bet.nii.gz
2023-07-24 05:10:19,877 - JUNIFER - INFO - VBM_GM is type NIFTI
2023-07-24 05:10:19,878 - JUNIFER - INFO - Fitting marker Schaefer100x17_TrimMean80
2023-07-24 05:10:19,878 - JUNIFER - INFO - Computing VBM_GM
2023-07-24 05:10:19,879 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2023-07-24 05:10:19,879 - JUNIFER - INFO - Parcellation parameters:
2023-07-24 05:10:19,879 - JUNIFER - INFO -      resolution: 2.0
2023-07-24 05:10:19,879 - JUNIFER - INFO -      n_rois: 100
2023-07-24 05:10:19,879 - JUNIFER - INFO -      yeo_networks: 17
2023-07-24 05:10:19,881 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_100Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2023-07-24 05:10:20,726 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmpomu17qac/test.sqlite (multiple output)>
2023-07-24 05:10:20,779 - JUNIFER - INFO - Fitting marker Schaefer200x17_Mean
2023-07-24 05:10:20,779 - JUNIFER - INFO - Computing VBM_GM
2023-07-24 05:10:20,779 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2023-07-24 05:10:20,779 - JUNIFER - INFO - Parcellation parameters:
2023-07-24 05:10:20,779 - JUNIFER - INFO -      resolution: 2.0
2023-07-24 05:10:20,779 - JUNIFER - INFO -      n_rois: 200
2023-07-24 05:10:20,780 - JUNIFER - INFO -      yeo_networks: 17
2023-07-24 05:10:20,782 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_200Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2023-07-24 05:10:21,650 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmpomu17qac/test.sqlite (multiple output)>
2023-07-24 05:10:21,747 - JUNIFER - INFO - Marker collection fitting done
2023-07-24 05:10:21,747 - JUNIFER - INFO - Getting element sub-05
2023-07-24 05:10:21,748 - JUNIFER - INFO - Fitting pipeline
2023-07-24 05:10:21,748 - JUNIFER - INFO - Reading VBM_GM from /home/runner/nilearn_data/oasis1/OAS1_0005_MR1/mwrc1OAS1_0005_MR1_mpr_anon_fslswapdim_bet.nii.gz
2023-07-24 05:10:21,748 - JUNIFER - INFO - VBM_GM is type NIFTI
2023-07-24 05:10:21,750 - JUNIFER - INFO - Fitting marker Schaefer100x17_TrimMean80
2023-07-24 05:10:21,750 - JUNIFER - INFO - Computing VBM_GM
2023-07-24 05:10:21,750 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2023-07-24 05:10:21,750 - JUNIFER - INFO - Parcellation parameters:
2023-07-24 05:10:21,750 - JUNIFER - INFO -      resolution: 2.0
2023-07-24 05:10:21,750 - JUNIFER - INFO -      n_rois: 100
2023-07-24 05:10:21,751 - JUNIFER - INFO -      yeo_networks: 17
2023-07-24 05:10:21,754 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_100Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2023-07-24 05:10:22,611 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmpomu17qac/test.sqlite (multiple output)>
2023-07-24 05:10:22,666 - JUNIFER - INFO - Fitting marker Schaefer200x17_Mean
2023-07-24 05:10:22,666 - JUNIFER - INFO - Computing VBM_GM
2023-07-24 05:10:22,666 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2023-07-24 05:10:22,667 - JUNIFER - INFO - Parcellation parameters:
2023-07-24 05:10:22,667 - JUNIFER - INFO -      resolution: 2.0
2023-07-24 05:10:22,667 - JUNIFER - INFO -      n_rois: 200
2023-07-24 05:10:22,667 - JUNIFER - INFO -      yeo_networks: 17
2023-07-24 05:10:22,670 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_200Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2023-07-24 05:10:23,566 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmpomu17qac/test.sqlite (multiple output)>
2023-07-24 05:10:23,663 - JUNIFER - INFO - Marker collection fitting done
2023-07-24 05:10:23,663 - JUNIFER - INFO - Getting element sub-06
2023-07-24 05:10:23,664 - JUNIFER - INFO - Fitting pipeline
2023-07-24 05:10:23,664 - JUNIFER - INFO - Reading VBM_GM from /home/runner/nilearn_data/oasis1/OAS1_0006_MR1/mwrc1OAS1_0006_MR1_mpr_anon_fslswapdim_bet.nii.gz
2023-07-24 05:10:23,664 - JUNIFER - INFO - VBM_GM is type NIFTI
2023-07-24 05:10:23,665 - JUNIFER - INFO - Fitting marker Schaefer100x17_TrimMean80
2023-07-24 05:10:23,665 - JUNIFER - INFO - Computing VBM_GM
2023-07-24 05:10:23,666 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2023-07-24 05:10:23,666 - JUNIFER - INFO - Parcellation parameters:
2023-07-24 05:10:23,666 - JUNIFER - INFO -      resolution: 2.0
2023-07-24 05:10:23,666 - JUNIFER - INFO -      n_rois: 100
2023-07-24 05:10:23,666 - JUNIFER - INFO -      yeo_networks: 17
2023-07-24 05:10:23,669 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_100Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2023-07-24 05:10:24,570 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmpomu17qac/test.sqlite (multiple output)>
2023-07-24 05:10:24,629 - JUNIFER - INFO - Fitting marker Schaefer200x17_Mean
2023-07-24 05:10:24,629 - JUNIFER - INFO - Computing VBM_GM
2023-07-24 05:10:24,629 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2023-07-24 05:10:24,630 - JUNIFER - INFO - Parcellation parameters:
2023-07-24 05:10:24,630 - JUNIFER - INFO -      resolution: 2.0
2023-07-24 05:10:24,630 - JUNIFER - INFO -      n_rois: 200
2023-07-24 05:10:24,630 - JUNIFER - INFO -      yeo_networks: 17
2023-07-24 05:10:24,633 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_200Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2023-07-24 05:10:25,514 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmpomu17qac/test.sqlite (multiple output)>
2023-07-24 05:10:25,619 - JUNIFER - INFO - Marker collection fitting done
2023-07-24 05:10:25,619 - JUNIFER - INFO - Getting element sub-07
2023-07-24 05:10:25,619 - JUNIFER - INFO - Fitting pipeline
2023-07-24 05:10:25,619 - JUNIFER - INFO - Reading VBM_GM from /home/runner/nilearn_data/oasis1/OAS1_0007_MR1/mwrc1OAS1_0007_MR1_mpr_anon_fslswapdim_bet.nii.gz
2023-07-24 05:10:25,619 - JUNIFER - INFO - VBM_GM is type NIFTI
2023-07-24 05:10:25,621 - JUNIFER - INFO - Fitting marker Schaefer100x17_TrimMean80
2023-07-24 05:10:25,621 - JUNIFER - INFO - Computing VBM_GM
2023-07-24 05:10:25,621 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2023-07-24 05:10:25,621 - JUNIFER - INFO - Parcellation parameters:
2023-07-24 05:10:25,621 - JUNIFER - INFO -      resolution: 2.0
2023-07-24 05:10:25,621 - JUNIFER - INFO -      n_rois: 100
2023-07-24 05:10:25,621 - JUNIFER - INFO -      yeo_networks: 17
2023-07-24 05:10:25,624 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_100Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2023-07-24 05:10:26,491 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmpomu17qac/test.sqlite (multiple output)>
2023-07-24 05:10:26,552 - JUNIFER - INFO - Fitting marker Schaefer200x17_Mean
2023-07-24 05:10:26,553 - JUNIFER - INFO - Computing VBM_GM
2023-07-24 05:10:26,553 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2023-07-24 05:10:26,553 - JUNIFER - INFO - Parcellation parameters:
2023-07-24 05:10:26,553 - JUNIFER - INFO -      resolution: 2.0
2023-07-24 05:10:26,553 - JUNIFER - INFO -      n_rois: 200
2023-07-24 05:10:26,554 - JUNIFER - INFO -      yeo_networks: 17
2023-07-24 05:10:26,557 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_200Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2023-07-24 05:10:27,394 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmpomu17qac/test.sqlite (multiple output)>
2023-07-24 05:10:27,488 - JUNIFER - INFO - Marker collection fitting done
2023-07-24 05:10:27,488 - JUNIFER - INFO - Getting element sub-08
2023-07-24 05:10:27,489 - JUNIFER - INFO - Fitting pipeline
2023-07-24 05:10:27,489 - JUNIFER - INFO - Reading VBM_GM from /home/runner/nilearn_data/oasis1/OAS1_0009_MR1/mwrc1OAS1_0009_MR1_mpr_anon_fslswapdim_bet.nii.gz
2023-07-24 05:10:27,489 - JUNIFER - INFO - VBM_GM is type NIFTI
2023-07-24 05:10:27,490 - JUNIFER - INFO - Fitting marker Schaefer100x17_TrimMean80
2023-07-24 05:10:27,490 - JUNIFER - INFO - Computing VBM_GM
2023-07-24 05:10:27,491 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2023-07-24 05:10:27,491 - JUNIFER - INFO - Parcellation parameters:
2023-07-24 05:10:27,491 - JUNIFER - INFO -      resolution: 2.0
2023-07-24 05:10:27,491 - JUNIFER - INFO -      n_rois: 100
2023-07-24 05:10:27,491 - JUNIFER - INFO -      yeo_networks: 17
2023-07-24 05:10:27,494 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_100Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2023-07-24 05:10:28,306 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmpomu17qac/test.sqlite (multiple output)>
2023-07-24 05:10:28,361 - JUNIFER - INFO - Fitting marker Schaefer200x17_Mean
2023-07-24 05:10:28,361 - JUNIFER - INFO - Computing VBM_GM
2023-07-24 05:10:28,362 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2023-07-24 05:10:28,362 - JUNIFER - INFO - Parcellation parameters:
2023-07-24 05:10:28,362 - JUNIFER - INFO -      resolution: 2.0
2023-07-24 05:10:28,362 - JUNIFER - INFO -      n_rois: 200
2023-07-24 05:10:28,362 - JUNIFER - INFO -      yeo_networks: 17
2023-07-24 05:10:28,364 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_200Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2023-07-24 05:10:29,219 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmpomu17qac/test.sqlite (multiple output)>
2023-07-24 05:10:29,317 - JUNIFER - INFO - Marker collection fitting done
2023-07-24 05:10:29,317 - JUNIFER - INFO - Getting element sub-09
2023-07-24 05:10:29,317 - JUNIFER - INFO - Fitting pipeline
2023-07-24 05:10:29,317 - JUNIFER - INFO - Reading VBM_GM from /home/runner/nilearn_data/oasis1/OAS1_0010_MR1/mwrc1OAS1_0010_MR1_mpr_anon_fslswapdim_bet.nii.gz
2023-07-24 05:10:29,317 - JUNIFER - INFO - VBM_GM is type NIFTI
2023-07-24 05:10:29,319 - JUNIFER - INFO - Fitting marker Schaefer100x17_TrimMean80
2023-07-24 05:10:29,319 - JUNIFER - INFO - Computing VBM_GM
2023-07-24 05:10:29,319 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2023-07-24 05:10:29,319 - JUNIFER - INFO - Parcellation parameters:
2023-07-24 05:10:29,319 - JUNIFER - INFO -      resolution: 2.0
2023-07-24 05:10:29,319 - JUNIFER - INFO -      n_rois: 100
2023-07-24 05:10:29,319 - JUNIFER - INFO -      yeo_networks: 17
2023-07-24 05:10:29,322 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_100Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2023-07-24 05:10:30,236 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmpomu17qac/test.sqlite (multiple output)>
2023-07-24 05:10:30,296 - JUNIFER - INFO - Fitting marker Schaefer200x17_Mean
2023-07-24 05:10:30,296 - JUNIFER - INFO - Computing VBM_GM
2023-07-24 05:10:30,297 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2023-07-24 05:10:30,297 - JUNIFER - INFO - Parcellation parameters:
2023-07-24 05:10:30,297 - JUNIFER - INFO -      resolution: 2.0
2023-07-24 05:10:30,297 - JUNIFER - INFO -      n_rois: 200
2023-07-24 05:10:30,297 - JUNIFER - INFO -      yeo_networks: 17
2023-07-24 05:10:30,299 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_200Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2023-07-24 05:10:31,172 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmpomu17qac/test.sqlite (multiple output)>
2023-07-24 05:10:31,264 - JUNIFER - INFO - Marker collection fitting done
2023-07-24 05:10:31,264 - JUNIFER - INFO - Getting element sub-10
2023-07-24 05:10:31,264 - JUNIFER - INFO - Fitting pipeline
2023-07-24 05:10:31,264 - JUNIFER - INFO - Reading VBM_GM from /home/runner/nilearn_data/oasis1/OAS1_0011_MR1/mwrc1OAS1_0011_MR1_mpr_anon_fslswapdim_bet.nii.gz
2023-07-24 05:10:31,265 - JUNIFER - INFO - VBM_GM is type NIFTI
2023-07-24 05:10:31,266 - JUNIFER - INFO - Fitting marker Schaefer100x17_TrimMean80
2023-07-24 05:10:31,266 - JUNIFER - INFO - Computing VBM_GM
2023-07-24 05:10:31,266 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2023-07-24 05:10:31,267 - JUNIFER - INFO - Parcellation parameters:
2023-07-24 05:10:31,267 - JUNIFER - INFO -      resolution: 2.0
2023-07-24 05:10:31,267 - JUNIFER - INFO -      n_rois: 100
2023-07-24 05:10:31,267 - JUNIFER - INFO -      yeo_networks: 17
2023-07-24 05:10:31,270 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_100Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2023-07-24 05:10:32,097 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmpomu17qac/test.sqlite (multiple output)>
2023-07-24 05:10:32,154 - JUNIFER - INFO - Fitting marker Schaefer200x17_Mean
2023-07-24 05:10:32,154 - JUNIFER - INFO - Computing VBM_GM
2023-07-24 05:10:32,155 - JUNIFER - INFO - Fetching one of Schaefer parcellations.
2023-07-24 05:10:32,155 - JUNIFER - INFO - Parcellation parameters:
2023-07-24 05:10:32,155 - JUNIFER - INFO -      resolution: 2.0
2023-07-24 05:10:32,155 - JUNIFER - INFO -      n_rois: 200
2023-07-24 05:10:32,155 - JUNIFER - INFO -      yeo_networks: 17
2023-07-24 05:10:32,157 - JUNIFER - INFO - Loading parcellation /home/runner/junifer/data/parcellations/schaefer_2018/Schaefer2018_200Parcels_17Networks_order_FSLMNI152_2mm.nii.gz
2023-07-24 05:10:33,045 - JUNIFER - INFO - Storing in <SQLiteFeatureStorage @ /tmp/tmpomu17qac/test.sqlite (multiple output)>
2023-07-24 05:10:33,139 - JUNIFER - INFO - Marker collection fitting done
2023-07-24 05:10:33,139 - JUNIFER - INFO - Collecting data using SQLiteFeatureStorage
2023-07-24 05:10:33,139 - JUNIFER - INFO - Collecting data from /tmp/tmpomu17qac/*test.sqlite

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

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

feature: 100%|##########| 2/2 [00:00<00:00,  7.43it/s]
feature: 100%|##########| 2/2 [00:00<00:00,  7.41it/s]

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

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

feature: 100%|##########| 2/2 [00:00<00:00,  8.76it/s]
feature: 100%|##########| 2/2 [00:00<00:00,  8.74it/s]

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

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

feature: 100%|##########| 2/2 [00:00<00:00,  8.73it/s]
feature: 100%|##########| 2/2 [00:00<00:00,  8.71it/s]

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

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

feature: 100%|##########| 2/2 [00:00<00:00,  8.22it/s]
feature: 100%|##########| 2/2 [00:00<00:00,  8.21it/s]

file: 4it [00:01,  3.81it/s]

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

feature: 100%|##########| 2/2 [00:00<00:00,  8.56it/s]
feature: 100%|##########| 2/2 [00:00<00:00,  8.54it/s]

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

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

feature: 100%|##########| 2/2 [00:00<00:00,  8.84it/s]
feature: 100%|##########| 2/2 [00:00<00:00,  8.83it/s]

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

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

feature: 100%|##########| 2/2 [00:00<00:00,  8.75it/s]
feature: 100%|##########| 2/2 [00:00<00:00,  8.73it/s]

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

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

feature: 100%|##########| 2/2 [00:00<00:00,  8.29it/s]
feature: 100%|##########| 2/2 [00:00<00:00,  8.27it/s]

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

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

feature: 100%|##########| 2/2 [00:00<00:00,  8.85it/s]
feature: 100%|##########| 2/2 [00:00<00:00,  8.83it/s]

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

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

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

feature: 100%|##########| 2/2 [00:00<00:00,  5.70it/s]
feature: 100%|##########| 2/2 [00:00<00:00,  5.50it/s]

file: 10it [00:02,  3.38it/s]
file: 10it [00:02,  3.68it/s]
2023-07-24 05:10:35,855 - 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

X_types = {
    "features": X,
    "confound": confound,
}

creator = PipelineCreator(problem_type="regression", apply_to="features")
creator.add("zscore", apply_to=["features", "confound"])
creator.add("confound_removal", apply_to="features", confounds="confound")
creator.add("ridge")

scores = run_cross_validation(
    X=X + [confound],
    y=y,
    X_types=X_types,
    data=df_vbm,
    model=creator,
    cv=3,
)
print(scores)
   fit_time  score_time  ...  fold                          cv_mdsum
0  0.265640    0.034369  ...     0  509497eb21da473048117e0c6704d3ea
1  0.258639    0.033180  ...     1  509497eb21da473048117e0c6704d3ea
2  0.257170    0.034521  ...     2  509497eb21da473048117e0c6704d3ea

[3 rows x 8 columns]

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 22.952 seconds)

Gallery generated by Sphinx-Gallery