Note
Go to the end to download the full example code.
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-10-07 20:11:00 [info ] ===== Lib Versions ===== [junifer]
2026-10-07 20:11:00 [info ] click: 8.1.8 [junifer]
2026-10-07 20:11:00 [info ] numpy: 1.26.4 [junifer]
2026-10-07 20:11:00 [info ] scipy: 1.15.0 [junifer]
2026-10-07 20:11:00 [info ] datalad: 1.1.6 [junifer]
2026-10-07 20:11:00 [info ] pandas: 2.1.4 [junifer]
2026-10-07 20:11:00 [info ] nibabel: 5.3.3 [junifer]
2026-10-07 20:11:00 [info ] nilearn: 0.10.4 [junifer]
2026-10-07 20:11:00 [info ] sqlalchemy: 2.1.0 [junifer]
2026-10-07 20:11:00 [info ] ruamel.yaml: 0.18.17 [junifer]
2026-10-07 20:11:00 [info ] tqdm: 4.66.6 [junifer]
2026-10-07 20:11:00 [info ] templateflow: 24.2.2 [junifer]
2026-10-07 20:11:00 [info ] junifer_data: None [junifer]
2026-10-07 20:11:00 [info ] junifer: 0.0.7 [junifer]
2026-10-07 20:11:00 [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-10-07 20:11:00 [info ] Registering RSSETSMarker in marker [junifer]
2026-10-07 20:11:00 [info ] Validating Marker Collection [junifer]
2026-10-07 20:11:00 [info ] DataGrabber output type: ['BOLD', 'T1w'] [junifer]
2026-10-07 20:11:00 [info ] Validating Data Reader: [junifer]
2026-10-07 20:11:00 [info ] Data Reader output type: ['BOLD', 'T1w'] [junifer]
2026-10-07 20:11:00 [info ] Validating Marker: Schaefer100x17_RSSETS [junifer]
2026-10-07 20:11:00 [info ] Marker output type: ['timeseries'] [junifer]
2026-10-07 20:11:00 [info ] Validating storage for Schaefer100x17_RSSETS [junifer]
2026-10-07 20:11:00 [info ] Validating Marker: Schaefer200x17_RSSETS [junifer]
2026-10-07 20:11:00 [info ] Marker output type: ['timeseries'] [junifer]
2026-10-07 20:11:00 [info ] Validating storage for Schaefer200x17_RSSETS [junifer]
2026-10-07 20:11:00 [info ] Getting element sub001 [junifer]
2026-10-07 20:11:04 [info ] Fitting pipeline [junifer]
2026-10-07 20:11:04 [info ] Reading BOLD from /tmp/tmpb3re6st3/sub001_bold.nii.gz [junifer]
2026-10-07 20:11:04 [info ] BOLD is of type NIFTI [junifer]
2026-10-07 20:11:04 [info ] Reading T1w from /tmp/tmpb3re6st3/sub001_T1w.nii.gz [junifer]
2026-10-07 20:11:04 [info ] T1w is of type NIFTI [junifer]
2026-10-07 20:11:04 [info ] Fitting marker Schaefer100x17_RSSETS [junifer]
2026-10-07 20:11:04 [info ] Computing BOLD [junifer]
2026-10-07 20:11:04 [info ] Parcellation will be warped from MNI152NLin6Asym to MNI152Lin using highest resolution [junifer]
2026-10-07 20:11:04 [info ] Parcellation parameters: [junifer]
2026-10-07 20:11:04 [info ] resolution: None [junifer]
2026-10-07 20:11:04 [info ] n_rois: 100 [junifer]
2026-10-07 20:11:04 [info ] yeo_networks: 17 [junifer]
2026-10-07 20:11:04 [info ] Resolution set to None, using highest resolution. [junifer]
2026-10-07 20:11:05 [info ] Loading parcellation: /home/docker/junifer_data/v7/parcellations/Schaefer2018/Yeo2011/Schaefer2018_100Parcels_17Networks_order_FSLMNI152_1mm.nii.gz [junifer]
2026-10-07 20:11:10 [info ] Downloading template MNI152Lin (T1w in resolution 1) [junifer]
2026-10-07 20:11:11 [info ] antsApplyTransforms command to be executed:
antsApplyTransforms -d 3 -e 3 -n 'GenericLabel[NearestNeighbor]' -i /tmp/junifer/tmpj4k0plxs/ants_parcellation_warper_Schaefer100x17_from_MNI152NLin6Asym_to_MNI152Lin_3a287bd6-c28b-11f1-9c61-c662fa6c42438uern6r0/prewarp_parcellation.nii.gz -r /tmp/junifer/tmpj4k0plxs/ants_parcellation_warper_Schaefer100x17_from_MNI152NLin6Asym_to_MNI152Lin_3a287bd6-c28b-11f1-9c61-c662fa6c42438uern6r0/MNI152Lin_T1w.nii.gz -t /home/docker/junifer_data/v7/.git/annex/objects/JQ/Pp/SHA256E-s145422752--5091350b36f951d455dabd429ebe86c493c75a0217dca311ae355f1d62e080b0.h5/SHA256E-s145422752--5091350b36f951d455dabd429ebe86c493c75a0217dca311ae355f1d62e080b0.h5 -o /tmp/junifer/tmpj4k0plxs/ants_parcellation_warper_Schaefer100x17_from_MNI152NLin6Asym_to_MNI152Lin_3a287bd6-c28b-11f1-9c61-c662fa6c42438uern6r0/parcellation_warped.nii.gz [junifer]
2026-10-07 20:11:26 [info ] antsApplyTransforms command succeeded with the following output:
[junifer]
2026-10-07 20:11:36 [info ] Storing in <SQLiteFeatureStorage @ /tmp/tmp0wmjle20/test.sqlite (multiple output)> [junifer]
2026-10-07 20:11:36 [info ] Fitting marker Schaefer200x17_RSSETS [junifer]
2026-10-07 20:11:36 [info ] Computing BOLD [junifer]
2026-10-07 20:11:36 [info ] Parcellation will be warped from MNI152NLin6Asym to MNI152Lin using highest resolution [junifer]
2026-10-07 20:11:36 [info ] Parcellation parameters: [junifer]
2026-10-07 20:11:36 [info ] resolution: None [junifer]
2026-10-07 20:11:36 [info ] n_rois: 200 [junifer]
2026-10-07 20:11:36 [info ] yeo_networks: 17 [junifer]
2026-10-07 20:11:36 [info ] Resolution set to None, using highest resolution. [junifer]
2026-10-07 20:11:36 [info ] Loading parcellation: /home/docker/junifer_data/v7/parcellations/Schaefer2018/Yeo2011/Schaefer2018_200Parcels_17Networks_order_FSLMNI152_1mm.nii.gz [junifer]
2026-10-07 20:11:42 [info ] Downloading template MNI152Lin (T1w in resolution 1) [junifer]
2026-10-07 20:11:43 [info ] antsApplyTransforms command to be executed:
antsApplyTransforms -d 3 -e 3 -n 'GenericLabel[NearestNeighbor]' -i /tmp/junifer/tmpj4k0plxs/ants_parcellation_warper_Schaefer200x17_from_MNI152NLin6Asym_to_MNI152Lin_4ccb6424-c28b-11f1-9c61-c662fa6c4243pn9koixe/prewarp_parcellation.nii.gz -r /tmp/junifer/tmpj4k0plxs/ants_parcellation_warper_Schaefer200x17_from_MNI152NLin6Asym_to_MNI152Lin_4ccb6424-c28b-11f1-9c61-c662fa6c4243pn9koixe/MNI152Lin_T1w.nii.gz -t /home/docker/junifer_data/v7/.git/annex/objects/JQ/Pp/SHA256E-s145422752--5091350b36f951d455dabd429ebe86c493c75a0217dca311ae355f1d62e080b0.h5/SHA256E-s145422752--5091350b36f951d455dabd429ebe86c493c75a0217dca311ae355f1d62e080b0.h5 -o /tmp/junifer/tmpj4k0plxs/ants_parcellation_warper_Schaefer200x17_from_MNI152NLin6Asym_to_MNI152Lin_4ccb6424-c28b-11f1-9c61-c662fa6c4243pn9koixe/parcellation_warped.nii.gz [junifer]
2026-10-07 20:12:11 [info ] antsApplyTransforms command succeeded with the following output:
[junifer]
2026-10-07 20:12:19 [info ] Storing in <SQLiteFeatureStorage @ /tmp/tmp0wmjle20/test.sqlite (multiple output)> [junifer]
2026-10-07 20:12:20 [info ] Marker collection fitting done [junifer]
2026-10-07 20:12:20 [info ] Collecting data using SQLiteFeatureStorage [junifer]
2026-10-07 20:12:20 [info ] Collecting data from /tmp/tmp0wmjle20/*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, 20.81it/s]
file: 1it [00:00, 7.21it/s]
file: 1it [00:00, 7.19it/s]
2026-10-07 20:12:20 [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
Total running time of the script: (1 minutes 19.797 seconds)