8.5. Extracting root sum of squares from edge-wise timeseries.

This example uses a RSSETSMarker to compute root sum of squares of the edge-wise timeseries using the Schaefer parcellation (100 rois and 200 rois, 17 Yeo networks) for a 4D nifti BOLD file.

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

License: BSD 3 clause

import tempfile

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

Set the logging level to info to see extra information:

configure_logging(level="INFO")
2026-01-29 12:41:09 [info     ] ===== Lib Versions =====       [junifer]
2026-01-29 12:41:09 [info     ] click: 8.1.8                   [junifer]
2026-01-29 12:41:09 [info     ] numpy: 1.26.4                  [junifer]
2026-01-29 12:41:09 [info     ] scipy: 1.15.0                  [junifer]
2026-01-29 12:41:09 [info     ] datalad: 1.1.6                 [junifer]
2026-01-29 12:41:09 [info     ] pandas: 2.1.4                  [junifer]
2026-01-29 12:41:09 [info     ] nibabel: 5.3.3                 [junifer]
2026-01-29 12:41:09 [info     ] nilearn: 0.10.4                [junifer]
2026-01-29 12:41:09 [info     ] sqlalchemy: 2.0.46             [junifer]
2026-01-29 12:41:09 [info     ] ruamel.yaml: 0.18.17           [junifer]
2026-01-29 12:41:09 [info     ] tqdm: 4.66.6                   [junifer]
2026-01-29 12:41:09 [info     ] templateflow: 24.2.2           [junifer]
2026-01-29 12:41:09 [info     ] junifer_data: None             [junifer]
2026-01-29 12:41:09 [info     ] junifer: 0.0.7.dev310          [junifer]
2026-01-29 12:41:09 [info     ] ========================       [junifer]

Define the DataGrabber interface

datagrabber = {
    "kind": "SPMAuditoryTestingDataGrabber",
}

Define the markers interface

markers = [
    {
        "name": "Schaefer100x17_RSSETS",
        "kind": "RSSETSMarker",
        "parcellation": "Schaefer100x17",
    },
    {
        "name": "Schaefer200x17_RSSETS",
        "kind": "RSSETSMarker",
        "parcellation": "Schaefer200x17",
    },
]

Create a temporary directory for junifer feature extraction: At the end you can read the extracted data into a pandas.DataFrame.

with tempfile.TemporaryDirectory() as tmpdir:
    # Define the storage interface
    storage = {
        "kind": "SQLiteFeatureStorage",
        "uri": f"{tmpdir}/test.sqlite",
    }
    # Run the defined junifer feature extraction pipeline
    run(
        workdir=tmpdir,
        datagrabber=datagrabber,
        markers=markers,
        storage=storage,
        elements=["sub001"],  # we calculate for one subject only
    )
    # Collect extracted features data
    collect(storage=storage)
    # Create storage object to read in extracted features
    db = SQLiteFeatureStorage(uri=storage["uri"])

    # List all the features
    print(db.list_features())
    # Read extracted features
    df_rssets = db.read_df(feature_name="BOLD_Schaefer200x17_RSSETS_rss_ets")
2026-01-29 12:41:09 [info     ] Registering RSSETSMarker in marker [junifer]
2026-01-29 12:41:09 [info     ] Validating Marker Collection   [junifer]
2026-01-29 12:41:09 [info     ] DataGrabber output type: ['BOLD', 'T1w'] [junifer]
2026-01-29 12:41:09 [info     ] Validating Data Reader:        [junifer]
2026-01-29 12:41:09 [info     ] Data Reader output type: ['BOLD', 'T1w'] [junifer]
2026-01-29 12:41:09 [info     ] Validating Marker: Schaefer100x17_RSSETS [junifer]
2026-01-29 12:41:09 [info     ] Marker output type: ['timeseries'] [junifer]
2026-01-29 12:41:09 [info     ] Validating storage for Schaefer100x17_RSSETS [junifer]
2026-01-29 12:41:09 [info     ] Validating Marker: Schaefer200x17_RSSETS [junifer]
2026-01-29 12:41:09 [info     ] Marker output type: ['timeseries'] [junifer]
2026-01-29 12:41:09 [info     ] Validating storage for Schaefer200x17_RSSETS [junifer]
2026-01-29 12:41:09 [info     ] Getting element sub001         [junifer]
2026-01-29 12:41:11 [info     ] Fitting pipeline               [junifer]
2026-01-29 12:41:11 [info     ] Reading BOLD from /tmp/tmpit59aka9/sub001_bold.nii.gz [junifer]
2026-01-29 12:41:11 [info     ] BOLD is of type NIFTI          [junifer]
2026-01-29 12:41:11 [info     ] Reading T1w from /tmp/tmpit59aka9/sub001_T1w.nii.gz [junifer]
2026-01-29 12:41:11 [info     ] T1w is of type NIFTI           [junifer]
2026-01-29 12:41:11 [info     ] Fitting marker Schaefer100x17_RSSETS [junifer]
2026-01-29 12:41:11 [info     ] Computing BOLD                 [junifer]
2026-01-29 12:41:11 [info     ] Parcellation will be warped from MNI152NLin6Asym to MNI152Lin using highest resolution [junifer]
2026-01-29 12:41:11 [info     ] Parcellation parameters:       [junifer]
2026-01-29 12:41:11 [info     ]         resolution: None              [junifer]
2026-01-29 12:41:11 [info     ]         n_rois: 100                   [junifer]
2026-01-29 12:41:11 [info     ]         yeo_networks: 17              [junifer]
2026-01-29 12:41:11 [info     ] Resolution set to None, using highest resolution. [junifer]
2026-01-29 12:41:11 [info     ] Start annex operation          [datalad.annex] dlm_progress=annexprogress-139808558656944 dlm_progress_label=Total dlm_progress_noninteractive_level=5 dlm_progress_total=233863 dlm_progress_unit=' Bytes'
2026-01-29 12:41:12 [info     ] Start annex action: {'command': 'get', 'file': 'parcellations/Schaefer2018/Yeo2011/Schaefer2018_100Parcels_17Networks_order_FSLMNI152_1mm.nii.gz', 'input': ['parcellations/Schaefer2018/Yeo2011/Schaefer2018_100Parcels_17Networks_order_FSLMNI152_1mm.nii.gz'], 'key': 'MD5E-s233863--52fdf9073096aa55b7196e41619442bb.nii.gz', 'note': 'from gin-src...'} [datalad.annex] dlm_progress=annexprogress-139808558656944-454284447197089701 dlm_progress_label='Get parcella .. 2_1mm.nii.gz' dlm_progress_noninteractive_level=5 dlm_progress_total=233863.0 dlm_progress_unit=' Bytes'
2026-01-29 12:41:12 [info     ] 14.01%                         [datalad.annex] dlm_progress=annexprogress-139808558656944-454284447197089701 dlm_progress_noninteractive_level=5 dlm_progress_update=32768.0
2026-01-29 12:41:12 [info     ] Finished annex action: None    [datalad.annex] dlm_progress=annexprogress-139808558656944-454284447197089701 dlm_progress_noninteractive_level=5
2026-01-29 12:41:12 [info     ] Finished annex get             [datalad.annex] dlm_progress=annexprogress-139808558656944 dlm_progress_noninteractive_level=5
2026-01-29 12:41:12 [info     ] Loading parcellation: /github/home/junifer_data/v5/parcellations/Schaefer2018/Yeo2011/Schaefer2018_100Parcels_17Networks_order_FSLMNI152_1mm.nii.gz [junifer]
2026-01-29 12:41:14 [info     ] Downloading template MNI152Lin (T1w in resolution 1) [junifer]
2026-01-29 12:41:15 [info     ] antsApplyTransforms command to be executed:
antsApplyTransforms -d 3 -e 3 -n 'GenericLabel[NearestNeighbor]' -i /tmp/junifer/tmpxx0_ayke/ants_parcellation_warper_Schaefer100x17_from_MNI152NLin6Asym_to_MNI152Lin_cb7c2f7a-fd0f-11f0-9821-7a325534a278mlinvml4/prewarp_parcellation.nii.gz -r /tmp/junifer/tmpxx0_ayke/ants_parcellation_warper_Schaefer100x17_from_MNI152NLin6Asym_to_MNI152Lin_cb7c2f7a-fd0f-11f0-9821-7a325534a278mlinvml4/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_Schaefer100x17_from_MNI152NLin6Asym_to_MNI152Lin_cb7c2f7a-fd0f-11f0-9821-7a325534a278mlinvml4/parcellation_warped.nii.gz [junifer]
2026-01-29 12:41:21 [info     ] antsApplyTransforms command succeeded with the following output:
 [junifer]
2026-01-29 12:41:24 [info     ] Storing in <SQLiteFeatureStorage @ /tmp/tmp0wrne09u/test.sqlite (multiple output)> [junifer]
2026-01-29 12:41:24 [info     ] Fitting marker Schaefer200x17_RSSETS [junifer]
2026-01-29 12:41:24 [info     ] Computing BOLD                 [junifer]
2026-01-29 12:41:24 [info     ] Parcellation will be warped from MNI152NLin6Asym to MNI152Lin using highest resolution [junifer]
2026-01-29 12:41:24 [info     ] Parcellation parameters:       [junifer]
2026-01-29 12:41:24 [info     ]         resolution: None              [junifer]
2026-01-29 12:41:24 [info     ]         n_rois: 200                   [junifer]
2026-01-29 12:41:24 [info     ]         yeo_networks: 17              [junifer]
2026-01-29 12:41:24 [info     ] Resolution set to None, using highest resolution. [junifer]
2026-01-29 12:41:24 [info     ] Start annex operation          [datalad.annex] dlm_progress=annexprogress-139808559997984 dlm_progress_label=Total dlm_progress_noninteractive_level=5 dlm_progress_total=259405 dlm_progress_unit=' Bytes'
2026-01-29 12:41:25 [info     ] Start annex action: {'command': 'get', 'file': 'parcellations/Schaefer2018/Yeo2011/Schaefer2018_200Parcels_17Networks_order_FSLMNI152_1mm.nii.gz', 'input': ['parcellations/Schaefer2018/Yeo2011/Schaefer2018_200Parcels_17Networks_order_FSLMNI152_1mm.nii.gz'], 'key': 'MD5E-s259405--74b10470e93053e255b8dad06d00c9c4.nii.gz', 'note': 'from gin-src...'} [datalad.annex] dlm_progress=annexprogress-139808559997984-6731668974673869167 dlm_progress_label='Get parcella .. 2_1mm.nii.gz' dlm_progress_noninteractive_level=5 dlm_progress_total=259405.0 dlm_progress_unit=' Bytes'
2026-01-29 12:41:25 [info     ] 12.63%                         [datalad.annex] dlm_progress=annexprogress-139808559997984-6731668974673869167 dlm_progress_noninteractive_level=5 dlm_progress_update=32768.0
2026-01-29 12:41:26 [info     ] Finished annex action: None    [datalad.annex] dlm_progress=annexprogress-139808559997984-6731668974673869167 dlm_progress_noninteractive_level=5
2026-01-29 12:41:26 [info     ] Finished annex get             [datalad.annex] dlm_progress=annexprogress-139808559997984 dlm_progress_noninteractive_level=5
2026-01-29 12:41:26 [info     ] Loading parcellation: /github/home/junifer_data/v5/parcellations/Schaefer2018/Yeo2011/Schaefer2018_200Parcels_17Networks_order_FSLMNI152_1mm.nii.gz [junifer]
2026-01-29 12:41:28 [info     ] Downloading template MNI152Lin (T1w in resolution 1) [junifer]
2026-01-29 12:41:29 [info     ] antsApplyTransforms command to be executed:
antsApplyTransforms -d 3 -e 3 -n 'GenericLabel[NearestNeighbor]' -i /tmp/junifer/tmpxx0_ayke/ants_parcellation_warper_Schaefer200x17_from_MNI152NLin6Asym_to_MNI152Lin_d3af82b4-fd0f-11f0-9821-7a325534a278pg58_82h/prewarp_parcellation.nii.gz -r /tmp/junifer/tmpxx0_ayke/ants_parcellation_warper_Schaefer200x17_from_MNI152NLin6Asym_to_MNI152Lin_d3af82b4-fd0f-11f0-9821-7a325534a278pg58_82h/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_Schaefer200x17_from_MNI152NLin6Asym_to_MNI152Lin_d3af82b4-fd0f-11f0-9821-7a325534a278pg58_82h/parcellation_warped.nii.gz [junifer]
2026-01-29 12:41:40 [info     ] antsApplyTransforms command succeeded with the following output:
 [junifer]
2026-01-29 12:41:43 [info     ] Storing in <SQLiteFeatureStorage @ /tmp/tmp0wrne09u/test.sqlite (multiple output)> [junifer]
2026-01-29 12:41:43 [info     ] Marker collection fitting done [junifer]
2026-01-29 12:41:43 [info     ] Collecting data using SQLiteFeatureStorage [junifer]
2026-01-29 12:41:43 [info     ] Collecting data from /tmp/tmp0wrne09u/*test.sqlite [junifer]

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

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

file: 1it [00:00, 25.83it/s]
2026-01-29 12:41:43 [info     ] Collect done                   [junifer]
{'de47d0513cf22df792d264ecc363085a': {'datagrabber': {'class': 'SPMAuditoryTestingDataGrabber', 'types': ['BOLD', 'T1w']}, 'dependencies': {'nilearn': '0.10.4'}, 'datareader': {'class': 'DefaultDataReader'}, 'type': 'BOLD', 'marker': {'agg_method': 'mean', 'agg_method_params': None, 'class': 'RSSETSMarker', 'masks': None, 'name': 'Schaefer100x17_RSSETS_rss_ets', 'parcellation': 'Schaefer100x17'}, '_element_keys': ['subject'], 'name': 'BOLD_Schaefer100x17_RSSETS_rss_ets'}, '0ff7a9e8f65fc25885bd0cd4936f87a4': {'datagrabber': {'class': 'SPMAuditoryTestingDataGrabber', 'types': ['BOLD', 'T1w']}, 'dependencies': {'nilearn': '0.10.4'}, 'datareader': {'class': 'DefaultDataReader'}, 'type': 'BOLD', 'marker': {'agg_method': 'mean', 'agg_method_params': None, 'class': 'RSSETSMarker', 'masks': None, 'name': 'Schaefer200x17_RSSETS_rss_ets', 'parcellation': 'Schaefer200x17'}, '_element_keys': ['subject'], 'name': 'BOLD_Schaefer200x17_RSSETS_rss_ets'}}

Now we take a look at the dataframe

root_sum_of_squares_ets
subject timepoint
sub001 0 2502.888057
1 168.174038
2 102.849715
3 132.639660
4 109.615993


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

Gallery generated by Sphinx-Gallery