Sulci Reconstruction

Simple example.

Example on how to run the sulci reconstruction and identification pre-processing using BrainPrep. See user guide for details.

Data

Let’s first get some anatomical data.

from pathlib import Path
from brainprep.datasets import IBCDataset

datadir = Path("/tmp/brainprep-data")
datadir.mkdir(parents=True, exist_ok=True)
dataset = IBCDataset(datadir)
data = dataset.fetch(
    subject="01",
    modality="func",
)
print(data)
Bunch(
  description: PosixPath('/tmp/brainprep-data/rawdata/dataset_description.json')
  anat: PosixPath('/tmp/brainprep-data/rawdata/sub-01/ses-00/anat/sub-01_ses-00_T1w.nii.gz')
  func: PosixPath('/tmp/brainprep-data/rawdata/sub-01/ses-00/func/sub-01_ses-00_task-ArchiStandard_dir-pa_bold.nii.gz')
  fmap: PosixPath('/tmp/brainprep-data/rawdata/sub-01/ses-00/fmap/sub-01_ses-00_task-ArchiStandard_dir-ap_sbref.nii.gz')
)

Analysis

Let’s now perform the preprocessing using BrainPrep. As with many tutorials, we won’t execute the code directly here. However, feel free to set the ‘dryrun’ configuration to False to actually run each step and generate results on disk.

import shutil
from brainprep.workflow import (
    brainprep_group_sulcirec,
    brainprep_sulcirec,
)
from brainprep.config import Config
from brainprep.reporting import RSTReport

outdir = Path("/tmp/brainprep-sulcirec")
if outdir.is_dir():
    shutil.rmtree(outdir)
outdir.mkdir(parents=True, exist_ok=True)
with Config(dryrun=True, verbose=True):
    report = RSTReport()
    brainprep_sulcirec(
        t1_file=data.anat,
        output_dir=outdir,
        keep_intermediate=False,
    )
    print(report)
    brainprep_group_sulcirec(
        output_dir=outdir,
        keep_intermediate=False,
    )
[warn] - BIDS file name does not contain run key: sub-01_ses-00_T1w.nii.gz
[title] - Subject Level Sulci Reconstruction...
________________________________________________________________________________
[call] brainprep.workflow.sulcirec.brainprep_sulcirec(
    t1_file=PosixPath('/tmp/brainprep-data/rawdata/sub-01/ses-00/anat/sub-01_ses
-00_T1w.nii.gz'),
    output_dir=PosixPath('/tmp/brainprep-sulcirec/derivatives/sulcirec/subjects/
sub-01/ses-00'),
    keep_intermediate=False,
    kwargs={'entities': {'sub': '01', 'ses': '00', 'modality': 'T1w', 'mod':
'T1w', 'run': '28236'}},
)
[info] - setting workspace directory:
/tmp/brainprep-sulcirec/derivatives/sulcirec/subjects/sub-01/ses-00/workspace_28
236
[command] - brainprep interface morphologist-wf -t1-file
/tmp/brainprep-data/rawdata/sub-01/ses-00/anat/sub-01_ses-00_T1w.nii.gz
-output-dir /tmp/brainprep-sulcirec/derivatives/sulcirec/subjects/sub-01/ses-00
-workspace-dir
/tmp/brainprep-sulcirec/derivatives/sulcirec/subjects/sub-01/ses-00/workspace_28
236 -entities sub-01_ses-00_modality-T1w_mod-T1w_run-28236 -verbose True -dryrun
True -no-color False -skip-run-check False -cat12-file
/opt/cat12/standalone/cat_standalone.sh -spm12-dir /opt/cat12 -matlab-dir
/opt/MCR-2017b/v93 -tpm-file
/opt/cat12/spm12_mcr/home/gaser/gaser/spm/spm12/tpm/TPM.nii -darteltpm-file
/opt/cat12/spm12_mcr/home/gaser/gaser/spm/spm12/toolbox/cat12/templates_MNI152NL
in2009cAsym/Template_1_Dartel.nii -mni-2iso-file
/opt/fsl/data/standard/MNI152_T1_2mm.nii.gz -geolab-atlas-dir /opt/geolab/atlas
________________________________________________________________________________
[call] brainprep.interfaces.morphologist.morphologist_wf(
    t1_file=PosixPath('/tmp/brainprep-data/rawdata/sub-01/ses-00/anat/sub-01_ses
-00_T1w.nii.gz'),
    output_dir=PosixPath('/tmp/brainprep-sulcirec/derivatives/sulcirec/subjects/
sub-01/ses-00'),
    workspace_dir=PosixPath('/tmp/brainprep-sulcirec/derivatives/sulcirec/subjec
ts/sub-01/ses-00/workspace_28236'),
    entities={'sub': '01', 'ses': '00', 'modality': 'T1w', 'mod': 'T1w', 'run':
'28236'},
)
[command] - brainprep interface morphologist-cmd -t1-file
/tmp/brainprep-data/rawdata/sub-01/ses-00/anat/sub-01_ses-00_T1w.nii.gz
-output-dir /tmp/brainprep-sulcirec/derivatives/sulcirec/subjects/sub-01/ses-00
-workspace-dir
/tmp/brainprep-sulcirec/derivatives/sulcirec/subjects/sub-01/ses-00/workspace_28
236 -entities sub-01_ses-00_modality-T1w_mod-T1w_run-28236 -verbose True -dryrun
True -no-color False -skip-run-check False -cat12-file
/opt/cat12/standalone/cat_standalone.sh -spm12-dir /opt/cat12 -matlab-dir
/opt/MCR-2017b/v93 -tpm-file
/opt/cat12/spm12_mcr/home/gaser/gaser/spm/spm12/tpm/TPM.nii -darteltpm-file
/opt/cat12/spm12_mcr/home/gaser/gaser/spm/spm12/toolbox/cat12/templates_MNI152NL
in2009cAsym/Template_1_Dartel.nii -mni-2iso-file
/opt/fsl/data/standard/MNI152_T1_2mm.nii.gz -geolab-atlas-dir /opt/geolab/atlas
________________________________________________________________________________
[call] brainprep.interfaces.morphologist.morphologist_cmd(
    t1_file=PosixPath('/tmp/brainprep-data/rawdata/sub-01/ses-00/anat/sub-01_ses
-00_T1w.nii.gz'),
    output_dir=PosixPath('/tmp/brainprep-sulcirec/derivatives/sulcirec/subjects/
sub-01/ses-00'),
    workspace_dir=PosixPath('/tmp/brainprep-sulcirec/derivatives/sulcirec/subjec
ts/sub-01/ses-00/workspace_28236'),
    entities={'sub': '01', 'ses': '00', 'modality': 'T1w', 'mod': 'T1w', 'run':
'28236'},
)
[command] - morphologist-wrapper
/tmp/brainprep-data/rawdata/sub-01/ses-00/anat/sub-01_ses-00_T1w.nii.gz
/tmp/brainprep-sulcirec/derivatives/sulcirec/subjects/sub-01/ses-00/workspace_28
236 --subject 01
__________________________________________________________________0.00s, 0.00min
[command] - brainprep interface morphologist-move -output-dir
/tmp/brainprep-sulcirec/derivatives/sulcirec/subjects/sub-01/ses-00
-workspace-dir
/tmp/brainprep-sulcirec/derivatives/sulcirec/subjects/sub-01/ses-00/workspace_28
236 -entities sub-01_ses-00_modality-T1w_mod-T1w_run-28236 -dryrun False
-verbose True -dryrun True -no-color False -skip-run-check False -cat12-file
/opt/cat12/standalone/cat_standalone.sh -spm12-dir /opt/cat12 -matlab-dir
/opt/MCR-2017b/v93 -tpm-file
/opt/cat12/spm12_mcr/home/gaser/gaser/spm/spm12/tpm/TPM.nii -darteltpm-file
/opt/cat12/spm12_mcr/home/gaser/gaser/spm/spm12/toolbox/cat12/templates_MNI152NL
in2009cAsym/Template_1_Dartel.nii -mni-2iso-file
/opt/fsl/data/standard/MNI152_T1_2mm.nii.gz -geolab-atlas-dir /opt/geolab/atlas
________________________________________________________________________________
[call] brainprep.interfaces.morphologist.morphologist_move(
    output_dir=PosixPath('/tmp/brainprep-sulcirec/derivatives/sulcirec/subjects/
sub-01/ses-00'),
    workspace_dir=PosixPath('/tmp/brainprep-sulcirec/derivatives/sulcirec/subjec
ts/sub-01/ses-00/workspace_28236'),
    entities={'sub': '01', 'ses': '00', 'modality': 'T1w', 'mod': 'T1w', 'run':
'28236'},
    dryrun=True,
)
[info] - checking output:
/tmp/brainprep-sulcirec/derivatives/sulcirec/subjects/sub-01/ses-00/run-28236/an
at/folds/3.1/sub-01_ses-00_run-28236_hemi-L.arg
[info] - checking output:
/tmp/brainprep-sulcirec/derivatives/sulcirec/subjects/sub-01/ses-00/run-28236/an
at/folds/3.1/sub-01_ses-00_run-28236_hemi-R.arg
[info] - checking output:
/tmp/brainprep-sulcirec/derivatives/sulcirec/subjects/sub-01/ses-00/run-28236/qc
.tsv
__________________________________________________________________0.00s, 0.00min
__________________________________________________________________0.02s, 0.00min
[info] - cleaning workspace directory:
/tmp/brainprep-sulcirec/derivatives/sulcirec/subjects/sub-01/ses-00/workspace_28
236
[title] - Subject Level Sulci Reconstruction done.
__________________________________________________________________0.03s, 0.00min
Bunch(
  step1: Bunch(
    module: 'brainprep.workflow.sulcirec.brainprep_sulcirec'
    description: '\n    Subject level sulci reconstruction.\n\n    Applies morphologist tool :footcite:p:`fischer2012morphologist` for\n    cortical sulci extraction and identification.\n\n    Parameters\n    ----------\n    t1_file : File\n        Path to the input T1w image file.\n    output_dir : Directory\n        Directory where the prep-processing related outputs will be saved\n        (i.e., the root of your dataset).\n    keep_intermediate : bool\n        If True, retains intermediate results (i.e., the workspace); useful\n        for debugging. Default False.\n    **kwargs : dict\n        entities: dict\n            Dictionary of parsed BIDS entities.\n\n    Returns\n    -------\n    Bunch\n        A dictionary-like object containing:\n\n        - sulci_graphs_files : list[File] - Left and right hemispheres sulci.\n        - qc_file : File - QC TSV file.\n\n    Raises\n    ------\n    ValueError\n        If the input T1w file is not BIDS-compliant.\n\n    Notes\n    -----\n    This workflow assumes the T1w image is organized in BIDS.\n\n    References\n    ----------\n\n    .. footbibliography::\n\n    Examples\n    --------\n    >>> from brainprep.config import Config\n    >>> from brainprep.workflow import brainprep_sulcirec\n    >>>\n    >>> with Config(dryrun=True, verbose=False):\n    ...     outputs = brainprep_sulcirec(\n    ...         t1_file=(\n    ...             "/tmp/dataset/rawdata/sub-01/ses-01/anat/"\n    ...             "sub-01_ses-01_run-01_T1w.nii.gz"\n    ...         ),\n    ...         output_dir="/tmp/dataset/derivatives",\n    ...     )\n    >>> outputs\n    Bunch(\n        sulci_graphs_files=[PosixPath(\'...\'), PosixPath(\'...\')],\n        qc_file=PosixPath(\'...\')\n    )\n    '
    inputs: Bunch(
      t1_file: PosixPath('/tmp/brainprep-data/rawdata/sub-01/ses-00/anat/sub-01_ses-00_T1w.nii.gz')
      output_dir: PosixPath('/tmp/brainprep-sulcirec/derivatives/sulcirec/subjects/sub-01/ses-00')
      keep_intermediate: False
      kwargs: {'entities': {'sub': '01', 'ses': '00', 'modality': 'T1w', 'mod': 'T1w', 'run': '28236'}}
    )
    outputs: Bunch(
      sulci_graphs_files: [PosixPath('/tmp/brainprep-sulcirec/derivatives/sulcirec/subjects/sub-01/ses-00/run-28236/anat/folds/3.1/sub-01_ses-00_run-28236_hemi-L.arg'), PosixPath('/tmp/brainprep-sulcirec/derivatives/sulcirec/subjects/sub-01/ses-00/run-28236/anat/folds/3.1/sub-01_ses-00_run-28236_hemi-R.arg')]
      qc_file: PosixPath('/tmp/brainprep-sulcirec/derivatives/sulcirec/subjects/sub-01/ses-00/run-28236/qc.tsv')
    )
    runtime: Bunch(
      start: '2026-05-12 09:57:07.309100'
      end: '2026-05-12 09:57:07.334794'
      execution_time: 7.137222222222223e-06
      brainprep_version: '2.1.0.dev'
      platform: 'Linux-6.17.0-1010-azure-x86_64-with-glibc2.39'
      hostname: 'runnervmeorf1'
    )
    config: Bunch(
      verbose: True
      dryrun: True
      no_color: False
      skip_run_check: False
      cat12_file: PosixPath('/opt/cat12/standalone/cat_standalone.sh')
      spm12_dir: PosixPath('/opt/cat12')
      matlab_dir: PosixPath('/opt/MCR-2017b/v93')
      tpm_file: PosixPath('/opt/cat12/spm12_mcr/home/gaser/gaser/spm/spm12/tpm/TPM.nii')
      darteltpm_file: PosixPath('/opt/cat12/spm12_mcr/home/gaser/gaser/spm/spm12/toolbox/cat12/templates_MNI152NLin2009cAsym/Template_1_Dartel.nii')
      mni_2iso_file: PosixPath('/opt/fsl/data/standard/MNI152_T1_2mm.nii.gz')
      geolab_atlas_dir: PosixPath('/opt/geolab/atlas')
    )
  )
  step2: Bunch(
    module: 'brainprep.interfaces.morphologist.morphologist_wf'
    description: '\n    Sulci reconstruction and identification using morphologist.\n\n    Parameters\n    ----------\n    t1_file : File\n        Path to the input T1w image file.\n    output_dir : Directory\n        Directory where the prep-processing related outputs will be saved.\n    workspace_dir: Directory\n        Working directory with the workspace of the current processing, and\n        where subject specific data are symlinked.\n    entities : dict\n        A dictionary of parsed BIDS entities including modality.*\n\n    Returns\n    -------\n    sulci_graphs_files : list[File]\n        Left and right hemispheres sulci.\n    qc_file : File\n        QC TSV file.\n    '
    trace: 'brainprep.workflow.sulcirec.brainprep_sulcirec'
    inputs: Bunch(
      t1_file: PosixPath('/tmp/brainprep-data/rawdata/sub-01/ses-00/anat/sub-01_ses-00_T1w.nii.gz')
      output_dir: PosixPath('/tmp/brainprep-sulcirec/derivatives/sulcirec/subjects/sub-01/ses-00')
      workspace_dir: PosixPath('/tmp/brainprep-sulcirec/derivatives/sulcirec/subjects/sub-01/ses-00/workspace_28236')
      entities: {'sub': '01', 'ses': '00', 'modality': 'T1w', 'mod': 'T1w', 'run': '28236'}
    )
    outputs: Bunch(
      outputs: ([PosixPath('/tmp/brainprep-sulcirec/derivatives/sulcirec/subjects/sub-01/ses-00/run-28236/anat/folds/3.1/sub-01_ses-00_run-28236_hemi-L.arg'), PosixPath('/tmp/brainprep-sulcirec/derivatives/sulcirec/subjects/sub-01/ses-00/run-28236/anat/folds/3.1/sub-01_ses-00_run-28236_hemi-R.arg')], PosixPath('/tmp/brainprep-sulcirec/derivatives/sulcirec/subjects/sub-01/ses-00/run-28236/qc.tsv'))
    )
    runtime: Bunch(
      start: '2026-05-12 09:57:07.315950'
      end: '2026-05-12 09:57:07.333779'
      execution_time: 4.9525000000000004e-06
      brainprep_version: '2.1.0.dev'
      platform: 'Linux-6.17.0-1010-azure-x86_64-with-glibc2.39'
      hostname: 'runnervmeorf1'
    )
    config: Bunch(
      verbose: True
      dryrun: True
      no_color: False
      skip_run_check: False
      cat12_file: PosixPath('/opt/cat12/standalone/cat_standalone.sh')
      spm12_dir: PosixPath('/opt/cat12')
      matlab_dir: PosixPath('/opt/MCR-2017b/v93')
      tpm_file: PosixPath('/opt/cat12/spm12_mcr/home/gaser/gaser/spm/spm12/tpm/TPM.nii')
      darteltpm_file: PosixPath('/opt/cat12/spm12_mcr/home/gaser/gaser/spm/spm12/toolbox/cat12/templates_MNI152NLin2009cAsym/Template_1_Dartel.nii')
      mni_2iso_file: PosixPath('/opt/fsl/data/standard/MNI152_T1_2mm.nii.gz')
      geolab_atlas_dir: PosixPath('/opt/geolab/atlas')
    )
  )
  step3: Bunch(
    module: 'brainprep.interfaces.morphologist.morphologist_cmd'
    description: '\n    Morphologist command wrapper.\n\n    Parameters\n    ----------\n    t1_file : File\n        Path to the input T1w image file.\n    output_dir : Directory\n        Directory where the prep-processing related outputs will be saved.\n    workspace_dir: Directory\n        Working directory with the workspace of the current processing, and\n        where subject specific data are symlinked.\n    entities : dict\n        A dictionary of parsed BIDS entities including modality.\n\n    Returns\n    -------\n    command : list[str]\n       Pre-processing command-line.\n    '
    trace: 'brainprep.workflow.sulcirec.brainprep_sulcirec->brainprep.interfaces.morphologist.morphologist_wf'
    inputs: Bunch(
      t1_file: PosixPath('/tmp/brainprep-data/rawdata/sub-01/ses-00/anat/sub-01_ses-00_T1w.nii.gz')
      output_dir: PosixPath('/tmp/brainprep-sulcirec/derivatives/sulcirec/subjects/sub-01/ses-00')
      workspace_dir: PosixPath('/tmp/brainprep-sulcirec/derivatives/sulcirec/subjects/sub-01/ses-00/workspace_28236')
      entities: {'sub': '01', 'ses': '00', 'modality': 'T1w', 'mod': 'T1w', 'run': '28236'}
    )
    outputs: Bunch(
      outputs: ['morphologist-wrapper', '/tmp/brainprep-data/rawdata/sub-01/ses-00/anat/sub-01_ses-00_T1w.nii.gz', '/tmp/brainprep-sulcirec/derivatives/sulcirec/subjects/sub-01/ses-00/workspace_28236', '--subject', '01']
    )
    runtime: Bunch(
      start: '2026-05-12 09:57:07.322496'
      end: '2026-05-12 09:57:07.324858'
      execution_time: 6.56111111111111e-07
      brainprep_version: '2.1.0.dev'
      platform: 'Linux-6.17.0-1010-azure-x86_64-with-glibc2.39'
      hostname: 'runnervmeorf1'
    )
    config: Bunch(
      verbose: True
      dryrun: True
      no_color: False
      skip_run_check: False
      cat12_file: PosixPath('/opt/cat12/standalone/cat_standalone.sh')
      spm12_dir: PosixPath('/opt/cat12')
      matlab_dir: PosixPath('/opt/MCR-2017b/v93')
      tpm_file: PosixPath('/opt/cat12/spm12_mcr/home/gaser/gaser/spm/spm12/tpm/TPM.nii')
      darteltpm_file: PosixPath('/opt/cat12/spm12_mcr/home/gaser/gaser/spm/spm12/toolbox/cat12/templates_MNI152NLin2009cAsym/Template_1_Dartel.nii')
      mni_2iso_file: PosixPath('/opt/fsl/data/standard/MNI152_T1_2mm.nii.gz')
      geolab_atlas_dir: PosixPath('/opt/geolab/atlas')
    )
  )
  step4: Bunch(
    module: 'brainprep.interfaces.morphologist.morphologist_move'
    description: '\n    Morpholigist validation.\n\n    Move Morphologist outputs (QC file and run directory) from the workspace\n    into the final BIDS derivatives structure, and return the expected output\n    file paths.\n\n    Parameters\n    ----------\n    output_dir : Directory\n        Directory where the prep-processing related outputs will be saved.\n    workspace_dir: Directory\n        Working directory with the workspace of the current processing, and\n        where subject specific data are symlinked.\n    entities : dict\n        A dictionary of parsed BIDS entities including modality.\n    dryrun : bool\n        If True, skip actual computation and file writing. Default False.\n\n    Returns\n    -------\n    sulci_graphs_files : list[File]\n        Left and right hemispheres sulci.\n    qc_file : File\n        QC TSV file.\n    '
    trace: 'brainprep.workflow.sulcirec.brainprep_sulcirec->brainprep.interfaces.morphologist.morphologist_wf'
    inputs: Bunch(
      output_dir: PosixPath('/tmp/brainprep-sulcirec/derivatives/sulcirec/subjects/sub-01/ses-00')
      workspace_dir: PosixPath('/tmp/brainprep-sulcirec/derivatives/sulcirec/subjects/sub-01/ses-00/workspace_28236')
      entities: {'sub': '01', 'ses': '00', 'modality': 'T1w', 'mod': 'T1w', 'run': '28236'}
      dryrun: False
    )
    outputs: Bunch(
      outputs: ([PosixPath('/tmp/brainprep-sulcirec/derivatives/sulcirec/subjects/sub-01/ses-00/run-28236/anat/folds/3.1/sub-01_ses-00_run-28236_hemi-L.arg'), PosixPath('/tmp/brainprep-sulcirec/derivatives/sulcirec/subjects/sub-01/ses-00/run-28236/anat/folds/3.1/sub-01_ses-00_run-28236_hemi-R.arg')], PosixPath('/tmp/brainprep-sulcirec/derivatives/sulcirec/subjects/sub-01/ses-00/run-28236/qc.tsv'))
    )
    runtime: Bunch(
      start: '2026-05-12 09:57:07.329159'
      end: '2026-05-12 09:57:07.331892'
      execution_time: 7.591666666666667e-07
      brainprep_version: '2.1.0.dev'
      platform: 'Linux-6.17.0-1010-azure-x86_64-with-glibc2.39'
      hostname: 'runnervmeorf1'
    )
    config: Bunch(
      verbose: True
      dryrun: True
      no_color: False
      skip_run_check: False
      cat12_file: PosixPath('/opt/cat12/standalone/cat_standalone.sh')
      spm12_dir: PosixPath('/opt/cat12')
      matlab_dir: PosixPath('/opt/MCR-2017b/v93')
      tpm_file: PosixPath('/opt/cat12/spm12_mcr/home/gaser/gaser/spm/spm12/tpm/TPM.nii')
      darteltpm_file: PosixPath('/opt/cat12/spm12_mcr/home/gaser/gaser/spm/spm12/toolbox/cat12/templates_MNI152NLin2009cAsym/Template_1_Dartel.nii')
      mni_2iso_file: PosixPath('/opt/fsl/data/standard/MNI152_T1_2mm.nii.gz')
      geolab_atlas_dir: PosixPath('/opt/geolab/atlas')
    )
  )
)
[title] - Group Level Sulci Reconstruction...
________________________________________________________________________________
[call] brainprep.workflow.sulcirec.brainprep_group_sulcirec(
    output_dir=PosixPath('/tmp/brainprep-sulcirec/derivatives/sulcirec'),
    keep_intermediate=False,
)
[command] - brainprep interface morphologist-morphometry -output-dir
/tmp/brainprep-sulcirec/derivatives/sulcirec -dryrun False -verbose True -dryrun
True -no-color False -skip-run-check False -cat12-file
/opt/cat12/standalone/cat_standalone.sh -spm12-dir /opt/cat12 -matlab-dir
/opt/MCR-2017b/v93 -tpm-file
/opt/cat12/spm12_mcr/home/gaser/gaser/spm/spm12/tpm/TPM.nii -darteltpm-file
/opt/cat12/spm12_mcr/home/gaser/gaser/spm/spm12/toolbox/cat12/templates_MNI152NL
in2009cAsym/Template_1_Dartel.nii -mni-2iso-file
/opt/fsl/data/standard/MNI152_T1_2mm.nii.gz -geolab-atlas-dir /opt/geolab/atlas
________________________________________________________________________________
[call] brainprep.interfaces.morphologist.morphologist_morphometry(
    output_dir=PosixPath('/tmp/brainprep-sulcirec/derivatives/sulcirec/morphomet
ry'),
    dryrun=True,
)
[info] - checking output:
/tmp/brainprep-sulcirec/derivatives/sulcirec/morphometry/sulcal_morphologist_roi
.tsv
[info] - checking output:
/tmp/brainprep-sulcirec/derivatives/sulcirec/morphometry/brain_volumes_morpholog
ist_roi.tsv
__________________________________________________________________0.00s, 0.00min
[command] - brainprep interface sulcirec-metrics -output-dir
/tmp/brainprep-sulcirec/derivatives/sulcirec -dryrun False -verbose True -dryrun
True -no-color False -skip-run-check False -cat12-file
/opt/cat12/standalone/cat_standalone.sh -spm12-dir /opt/cat12 -matlab-dir
/opt/MCR-2017b/v93 -tpm-file
/opt/cat12/spm12_mcr/home/gaser/gaser/spm/spm12/tpm/TPM.nii -darteltpm-file
/opt/cat12/spm12_mcr/home/gaser/gaser/spm/spm12/toolbox/cat12/templates_MNI152NL
in2009cAsym/Template_1_Dartel.nii -mni-2iso-file
/opt/fsl/data/standard/MNI152_T1_2mm.nii.gz -geolab-atlas-dir /opt/geolab/atlas
________________________________________________________________________________
[call] brainprep.interfaces.qualcheck.sulcirec_metrics(
    output_dir=PosixPath('/tmp/brainprep-sulcirec/derivatives/sulcirec/quality_c
heck'),
    dryrun=True,
)
[info] - checking output:
/tmp/brainprep-sulcirec/derivatives/sulcirec/quality_check/group_stats.tsv
__________________________________________________________________0.00s, 0.00min
[title] - Group Level Sulci Reconstruction done.
__________________________________________________________________0.01s, 0.00min

CLI

Let’s now generate the same analysis using the CLI. The goal here is to translate the workflow calls into explicit shell commands. See user guide for details.

from pprint import pprint

commands = []
commands.append(
    [
        [
            "brainprep", "subject-level-sulcirec",
            "--t1-file", str(data.anat),
            "--output-dir", str(outdir),
        ]
    ]
)
commands.append(
    [
        [
            "brainprep", "group-level-sulcirec",
            "--output-dir", str(outdir),
        ],
    ]
)
pprint(commands)
[[['brainprep',
   'subject-level-sulcirec',
   '--t1-file',
   '/tmp/brainprep-data/rawdata/sub-01/ses-00/anat/sub-01_ses-00_T1w.nii.gz',
   '--output-dir',
   '/tmp/brainprep-sulcirec']],
 [['brainprep',
   'group-level-sulcirec',
   '--output-dir',
   '/tmp/brainprep-sulcirec']]]

Container

Note that the commands generated by the CLI are not limited to being displayed for reference; they can also be executed directly within the workflow‑dedicated container. By running the commands inside the container, you benefit from a controlled runtime context where all necessary dependencies, libraries, and configuration files are already available. In practice, this means that once the CLI has produced the appropriate instructions, you can simply copy and run them inside the container to achieve the intended results. You can find the BrainPrep images on Docker Hub: Neurospin Docker Hub.

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

Estimated memory usage: 113 MB

Gallery generated by Sphinx-Gallery