API Reference

MRSIPrep is structured as a library of workflow-orchestration functions, one per pipeline stage, invoked in sequence by mrsiprep.workflows.participant.run_participant_workflow() -- the same top-level entry point the CLI calls. Each stage function takes the run's config object plus the outputs of earlier stages and returns a small dataclass result that later stages consume.

This page documents the internal architecture for anyone extending MRSIPrep or calling its stages directly from Python (import mrsiprep) rather than through the CLI. For end-user usage and the full CLI flag reference, see Basic Usage.

Configuration

mrsiprep.config.settings

Runtime configuration objects.

mrsiprep.config.defaults

Default values for MRSIPrep.

Top-level orchestration

mrsiprep.workflows.participant

Participant workflow orchestration.

mrsiprep.workflows.base

Workflow base helpers.

Pipeline stage workflows

Each module below wraps one pipeline stage (see the Workflow Architecture section on the home page for the stage order) behind a single run_*_workflow entry point.

mrsiprep.workflows.anatomical

Anatomical preparation workflow.

mrsiprep.workflows.mrsi

MRSI preprocessing workflow.

mrsiprep.workflows.tissue

Tissue workflow.

mrsiprep.workflows.registration

Registration workflow.

mrsiprep.workflows.parcellation

Parcellation workflow.

mrsiprep.workflows.connectivity

Metabolic profile and connectivity workflow.

mrsiprep.workflows.reports

Report workflow.

Registration

mrsiprep.registration.mrsi_to_t1

MRSI-to-T1 registration.

mrsiprep.registration.t1_to_mni

T1-to-MNI registration.

mrsiprep.registration.subject_template

Subject-level longitudinal template construction and template-to-MNI registration.

mrsiprep.registration.transforms

Transform path and application helpers.

Backend interfaces

Thin wrappers around the external registration/segmentation tools MRSIPrep shells out to or calls via Python bindings.

mrsiprep.interfaces.ants

ANTs/antspyx interface.

mrsiprep.interfaces.fsl

FSL FLIRT/FNIRT registration interface.

mrsiprep.interfaces.freesurfer

FreeSurfer helpers.

mrsiprep.interfaces.chimera

Chimera parcellation wrapper.

MRSI processing

mrsiprep.mrsi.filtering

Biharmonic-style MRSI spike filtering.

mrsiprep.mrsi.masks

MRSI mask helpers.

mrsiprep.mrsi.quality

Voxelwise MRSI QC masks.

mrsiprep.mrsi.reference

MRSI reference image generation.

mrsiprep.mrsi.resampling

MRSI resampling helpers.

mrsiprep.mrsi.pvc

Partial-volume correction via PETPVC.

Tissue segmentation

mrsiprep.tissue.synthseg_fast

SynthSeg-constrained FSL FAST tissue backend.

mrsiprep.tissue.fuzzy_cmeans

MIDAS-style fuzzy c-means tissue segmentation.

mrsiprep.tissue.fractions

Tissue fraction map helpers.

mrsiprep.tissue.psf

MIDAS-style PSF-based tissue-fraction convolution.

Parcellation and connectivity

mrsiprep.parcellation.synthseg

Lightweight SynthSeg cortical and subcortical parcellation.

mrsiprep.parcellation.chimera_native

Chimera native-space parcellation workflow.

mrsiprep.parcellation.mni_atlas

MNI atlas parcellation workflow.

mrsiprep.parcellation.extraction

Regional metabolite extraction.

mrsiprep.parcellation.tissue_regression

MIDAS-style (Maudsley et al. 2006, Eq.

mrsiprep.connectivity.export

Connectivity export helpers.

mrsiprep.connectivity.connectivity

Perturbation-based metabolite connectivity.

I/O

mrsiprep.io.bids

Input layout discovery for MRSIPrep.

mrsiprep.io.loaders

MRSI input loading helpers.

mrsiprep.io.naming

BIDS-like naming helpers.

mrsiprep.io.derivatives

Derivative directory helpers.

mrsiprep.io.validators

Input validation.

mrsiprep.io.mrsinmrs

MRSinMRS (Lin et al. 2021, PMID 33559967) sequence-parameter reporting.