8.4. 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 HDF5FeatureStorage
from junifer.utils import configure_logging

Set the logging level to info to see extra information:

configure_logging(level="INFO")
2026-10-19 21:14:31 [info     ] ===== Lib Versions =====       [junifer] pkg=utils
2026-10-19 21:14:31 [info     ] click: 8.5.0                   [junifer] pkg=utils
2026-10-19 21:14:31 [info     ] numpy: 2.4.6                   [junifer] pkg=utils
2026-10-19 21:14:31 [info     ] scipy: 1.17.1                  [junifer] pkg=utils
2026-10-19 21:14:31 [info     ] datalad: 1.7.1                 [junifer] pkg=utils
2026-10-19 21:14:31 [info     ] pandas: 3.0.6                  [junifer] pkg=utils
2026-10-19 21:14:31 [info     ] nibabel: 5.4.2                 [junifer] pkg=utils
2026-10-19 21:14:31 [info     ] nilearn: 0.14.1                [junifer] pkg=utils
2026-10-19 21:14:31 [info     ] sqlalchemy: 2.1.5              [junifer] pkg=utils
2026-10-19 21:14:31 [info     ] ruamel.yaml: 0.19.1            [junifer] pkg=utils
2026-10-19 21:14:31 [info     ] h5py: 3.16.0                   [junifer] pkg=utils
2026-10-19 21:14:31 [info     ] tqdm: 4.70.1                   [junifer] pkg=utils
2026-10-19 21:14:31 [info     ] templateflow: 25.1.2           [junifer] pkg=utils
2026-10-19 21:14:31 [info     ] lapy: 1.7.0                    [junifer] pkg=utils
2026-10-19 21:14:31 [info     ] junifer_data: 1.6.1            [junifer] pkg=utils
2026-10-19 21:14:31 [info     ] junifer: 0.0.8                 [junifer] pkg=utils
2026-10-19 21:14:31 [info     ] ========================       [junifer] pkg=utils

Define the DataGrabber interface

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

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": "HDF5FeatureStorage",
        "uri": f"{tmpdir}/test.hdf5",
    }
    # Run the defined junifer feature extraction pipeline
    run(
        workdir=tmpdir,
        datagrabber=datagrabber,
        markers=markers,
        storage=storage,
        elements=["sub-01"],  # we calculate for one subject only
    )
    # Collect extracted features data
    collect(storage=storage)
    # Create storage object to read in extracted features
    db = HDF5FeatureStorage(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-10-19 21:14:31 [info     ] Parameters: {'types': ['BOLD'], 'datadir': '/tmp/tmp5u84on0q', 'resolution': 3.0, 'n_timepoints': 50} [junifer] component=ADHDTestingDataGrabber pkg=datagrabber step=datagrabber
2026-10-19 21:14:31 [info     ] Parameters: {'on': ['BOLD'], 'name': 'Schaefer100x17_RSSETS', 'parcellation': ['Schaefer100x17'], 'agg_method': 'mean', 'agg_method_params': None, 'masks': None} [junifer] component=Schaefer100x17_RSSETS pkg=markers step=marker
2026-10-19 21:14:31 [info     ] Parameters: {'on': ['BOLD'], 'name': 'Schaefer200x17_RSSETS', 'parcellation': ['Schaefer200x17'], 'agg_method': 'mean', 'agg_method_params': None, 'masks': None} [junifer] component=Schaefer200x17_RSSETS pkg=markers step=marker
2026-10-19 21:14:31 [info     ] Parameters: {'uri': '/tmp/tmp1crjlx6t/test.hdf5', 'single_output': False, 'overwrite': 'update', 'compression': 7, 'force_float32': True, 'chunk_size': 100} [junifer] component=HDF5FeatureStorage pkg=storage step=storage
2026-10-19 21:14:31 [info     ] Validating Marker Collection   [junifer] pkg=pipeline
2026-10-19 21:14:31 [info     ] DataGrabber output type: ['BOLD'] [junifer] pkg=pipeline
2026-10-19 21:14:31 [info     ] Validating Data Reader:        [junifer] pkg=pipeline
2026-10-19 21:14:31 [info     ] Data Reader output type: ['BOLD'] [junifer] pkg=pipeline
2026-10-19 21:14:31 [info     ] Validating Marker: Schaefer100x17_RSSETS [junifer] pkg=pipeline
2026-10-19 21:14:31 [info     ] Marker output type: [<StorageType.Timeseries: 'timeseries'>] [junifer] pkg=pipeline
2026-10-19 21:14:31 [info     ] Validating storage for Schaefer100x17_RSSETS [junifer] pkg=pipeline
2026-10-19 21:14:31 [info     ] Validating Marker: Schaefer200x17_RSSETS [junifer] pkg=pipeline
2026-10-19 21:14:31 [info     ] Marker output type: [<StorageType.Timeseries: 'timeseries'>] [junifer] pkg=pipeline
2026-10-19 21:14:31 [info     ] Validating storage for Schaefer200x17_RSSETS [junifer] pkg=pipeline
[fetch_adhd] Dataset directory found: /home/docker/nilearn_data/adhd
2026-10-19 21:14:31 [info     ] Getting element ('sub-01',)    [junifer] pkg=datagrabber step=datagrabber
2026-10-19 21:14:31 [info     ] Fitting pipeline               [junifer] pkg=pipeline
2026-10-19 21:14:31 [info     ] Reading BOLD from /home/docker/nilearn_data/adhd/data/0010042/0010042_rest_tshift_RPI_voreg_mni_res-3mm_tp-50.nii [junifer] pkg=datareader step=datareader
2026-10-19 21:14:31 [info     ] BOLD is of type NIFTI          [junifer] pkg=datareader step=datareader
2026-10-19 21:14:31 [info     ] Fitting marker Schaefer100x17_RSSETS [junifer] pkg=pipeline
2026-10-19 21:14:31 [info     ] Computing DataType.BOLD        [junifer] pkg=markers step=marker
2026-10-19 21:14:31 [info     ] Parameters: {'on': ['BOLD'], 'name': 'ParcelAggregation', 'parcellation': ['Schaefer100x17'], 'method': 'mean', 'method_params': None, 'time_method': None, 'time_method_params': None, 'masks': None} [junifer] component=ParcelAggregation pkg=markers step=marker
2026-10-19 21:14:31 [info     ] Parcellation parameters:       [junifer] pkg=data
2026-10-19 21:14:31 [info     ]         resolution: 3.0               [junifer] pkg=data
2026-10-19 21:14:31 [info     ]         n_rois: 100                   [junifer] pkg=data
2026-10-19 21:14:31 [info     ]         yeo_networks: 17              [junifer] pkg=data
2026-10-19 21:14:31 [info     ] Loading parcellation: /home/docker/junifer_data/v8/parcellations/Schaefer2018/Yeo2011/Schaefer2018_100Parcels_17Networks_order_FSLMNI152_2mm.nii.gz [junifer] pkg=data
2026-10-19 21:14:32 [info     ] Storing in <HDF5FeatureStorage @ /tmp/tmp1crjlx6t/test.hdf5 (multiple output)> [junifer] pkg=markers step=marker
2026-10-19 21:14:32 [info     ] Writing HDF5 metadata for 7fc47362cf2be31570759647d701d4ca to: /tmp/tmp1crjlx6t/element_sub-01_test.hdf5 [junifer] pkg=storage step=storage
2026-10-19 21:14:32 [info     ] Wrote HDF5 metadata for 7fc47362cf2be31570759647d701d4ca to: /tmp/tmp1crjlx6t/element_sub-01_test.hdf5 [junifer] pkg=storage step=storage
2026-10-19 21:14:32 [info     ] Writing HDF5 data for 7fc47362cf2be31570759647d701d4ca to: /tmp/tmp1crjlx6t/element_sub-01_test.hdf5 [junifer] pkg=storage step=storage
2026-10-19 21:14:32 [info     ] Wrote HDF5 data for 7fc47362cf2be31570759647d701d4ca to: /tmp/tmp1crjlx6t/element_sub-01_test.hdf5 [junifer] pkg=storage step=storage
2026-10-19 21:14:32 [info     ] Fitting marker Schaefer200x17_RSSETS [junifer] pkg=pipeline
2026-10-19 21:14:32 [info     ] Computing DataType.BOLD        [junifer] pkg=markers step=marker
2026-10-19 21:14:32 [info     ] Parameters: {'on': ['BOLD'], 'name': 'ParcelAggregation', 'parcellation': ['Schaefer200x17'], 'method': 'mean', 'method_params': None, 'time_method': None, 'time_method_params': None, 'masks': None} [junifer] component=ParcelAggregation pkg=markers step=marker
2026-10-19 21:14:32 [info     ] Parcellation parameters:       [junifer] pkg=data
2026-10-19 21:14:32 [info     ]         resolution: 3.0               [junifer] pkg=data
2026-10-19 21:14:32 [info     ]         n_rois: 200                   [junifer] pkg=data
2026-10-19 21:14:32 [info     ]         yeo_networks: 17              [junifer] pkg=data
2026-10-19 21:14:32 [info     ] Loading parcellation: /home/docker/junifer_data/v8/parcellations/Schaefer2018/Yeo2011/Schaefer2018_200Parcels_17Networks_order_FSLMNI152_2mm.nii.gz [junifer] pkg=data
2026-10-19 21:14:33 [info     ] Storing in <HDF5FeatureStorage @ /tmp/tmp1crjlx6t/test.hdf5 (multiple output)> [junifer] pkg=markers step=marker
2026-10-19 21:14:33 [info     ] Writing HDF5 metadata for bd734d5ef16f583bf3dc85f198aa6b45 to: /tmp/tmp1crjlx6t/element_sub-01_test.hdf5 [junifer] pkg=storage step=storage
2026-10-19 21:14:33 [info     ] Wrote HDF5 metadata for bd734d5ef16f583bf3dc85f198aa6b45 to: /tmp/tmp1crjlx6t/element_sub-01_test.hdf5 [junifer] pkg=storage step=storage
2026-10-19 21:14:33 [info     ] Writing HDF5 data for bd734d5ef16f583bf3dc85f198aa6b45 to: /tmp/tmp1crjlx6t/element_sub-01_test.hdf5 [junifer] pkg=storage step=storage
2026-10-19 21:14:33 [info     ] Wrote HDF5 data for bd734d5ef16f583bf3dc85f198aa6b45 to: /tmp/tmp1crjlx6t/element_sub-01_test.hdf5 [junifer] pkg=storage step=storage
2026-10-19 21:14:33 [info     ] Marker collection fitting done [junifer] pkg=pipeline
2026-10-19 21:14:33 [info     ] Collecting data using HDF5FeatureStorage [junifer] pkg=api
2026-10-19 21:14:33 [info     ] Parameters: {'uri': '/tmp/tmp1crjlx6t/test.hdf5', 'single_output': False, 'overwrite': 'update', 'compression': 7, 'force_float32': True, 'chunk_size': 100} [junifer] component=HDF5FeatureStorage pkg=storage step=storage
2026-10-19 21:14:33 [info     ] Parameters: {'uri': '/tmp/tmp1crjlx6t/test.hdf5', 'single_output': True, 'overwrite': 'update', 'compression': 7, 'force_float32': True, 'chunk_size': 100} [junifer] component=HDF5FeatureStorage pkg=storage step=storage
2026-10-19 21:14:33 [info     ] Collecting metadata from /tmp/tmp1crjlx6t/*_test.hdf5 [junifer] pkg=storage step=storage

file-metadata: 0it [00:00, ?it/s]2026-10-19 21:14:33 [info     ] Parameters: {'uri': '/tmp/tmp1crjlx6t/element_sub-01_test.hdf5', 'single_output': True, 'overwrite': 'update', 'compression': 7, 'force_float32': True, 'chunk_size': 100} [junifer] component=HDF5FeatureStorage pkg=storage step=storage

file-metadata: 1it [00:00, 75.93it/s]
2026-10-19 21:14:33 [info     ] Writing metadata to HDF5 file ... [junifer] pkg=storage step=storage
2026-10-19 21:14:33 [info     ] Collecting data from /tmp/tmp1crjlx6t/*_test.hdf5 [junifer] pkg=storage step=storage
2026-10-19 21:14:33 [info     ] Will collect 2 features.       [junifer] pkg=storage step=storage
2026-10-19 21:14:33 [info     ] Collecting 1 files for feature MD5: 7fc47362cf2be31570759647d701d4ca. [junifer] pkg=storage step=storage
2026-10-19 21:14:33 [info     ] Collecting 1 files for feature MD5: bd734d5ef16f583bf3dc85f198aa6b45. [junifer] pkg=storage step=storage

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

file-data:   0%|          | 0/1 [00:00<?, ?it/s]
file-data: 100%|██████████| 1/1 [00:00<00:00, 112.44it/s]


file-data:   0%|          | 0/1 [00:00<?, ?it/s]
file-data: 100%|██████████| 1/1 [00:00<00:00, 105.65it/s]

feature: 100%|██████████| 2/2 [00:00<00:00, 56.05it/s]
2026-10-19 21:14:33 [info     ] Collect done                   [junifer] pkg=api
2026-10-19 21:14:33 [info     ] Parameters: {'uri': '/tmp/tmp1crjlx6t/test.hdf5', 'single_output': True, 'overwrite': 'update', 'compression': 7, 'force_float32': True, 'chunk_size': 100} [junifer] component=HDF5FeatureStorage pkg=storage step=storage
{'7fc47362cf2be31570759647d701d4ca': {'datagrabber': {'class': 'ADHDTestingDataGrabber', 'types': ['BOLD'], 'datadir': '/tmp/tmp5u84on0q', 'resolution': 3.0, 'n_timepoints': 50}, 'dependencies': {'nilearn': '0.14.1', 'junifer': '0.0.8'}, '_element_keys': ['subject'], 'datareader': {'class': 'DefaultDataReader'}, 'type': 'BOLD', 'marker': {'class': 'RSSETSMarker', 'on': ['BOLD'], 'name': 'Schaefer100x17_RSSETS_rss_ets', 'parcellation': ['Schaefer100x17'], 'agg_method': 'mean', 'agg_method_params': None, 'masks': None}, 'name': 'BOLD_Schaefer100x17_RSSETS_rss_ets'}, 'bd734d5ef16f583bf3dc85f198aa6b45': {'datagrabber': {'class': 'ADHDTestingDataGrabber', 'types': ['BOLD'], 'datadir': '/tmp/tmp5u84on0q', 'resolution': 3.0, 'n_timepoints': 50}, 'dependencies': {'nilearn': '0.14.1', 'junifer': '0.0.8'}, '_element_keys': ['subject'], 'datareader': {'class': 'DefaultDataReader'}, 'type': 'BOLD', 'marker': {'class': 'RSSETSMarker', 'on': ['BOLD'], 'name': 'Schaefer200x17_RSSETS_rss_ets', 'parcellation': ['Schaefer200x17'], 'agg_method': 'mean', 'agg_method_params': None, 'masks': None}, 'name': 'BOLD_Schaefer200x17_RSSETS_rss_ets'}}

Now we take a look at the dataframe

root_sum_of_squares_ets
subject timepoint
sub-01 0 56.673000
1 95.662399
2 149.116409
3 130.551895
4 127.797150


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

Gallery generated by Sphinx-Gallery