Workflows#
The thesis.workflows package contains all neuroimaging pipeline workflows.
Each workflow self-registers with thesis.core.registry.WORKFLOW_REGISTRY
at import time via a WorkflowEntry. There are 17 registered entries.
thesis.workflows#
Workflow modules for neuroimaging data processing.
Package structure:
hcp: HCP tractography workflow plus config, node, and operation helpersmrtrix3: MRtrix3 tractography workflow (drop-in replacement forhcp)synthseg: standalone SynthSeg segmentation workflowtract_synthseg: combined meta-workflow joining SynthSeg and a tractography backend (hcp/ProbTrackX2 ormrtrix3) selected bytractography.methodregistration: ANTs-based patient-to-template structural registrationpreprocess: raw DWI/T1/T2 preprocessing into an HCP-compatible layoutqc: quality-control visualisation and reporting workflowtransforms: reusable ANTs transform application workflowatlas_to_patient: transform cohort atlas maps into patient spacefull_pipeline: composite backend-parameterized meta-workflow (preprocess → registration → tract_synthseg ‖ atlas_to_patient → tract_similarity); backend selected bytractography.method
Main entry points:
thesis.workflows.hcp.build_workflowthesis.workflows.mrtrix3.build_workflowthesis.workflows.synthseg.workflow.build_workflowthesis.workflows.tract_synthseg.workflow.build_workflowthesis.workflows.registration.workflow.build_workflowthesis.workflows.preprocess.workflow.build_workflowthesis.workflows.transforms.workflow.build_workflowthesis.workflows.atlas_to_patient.workflow.build_workflowthesis.workflows.full_pipeline.workflow.build_workflow
- thesis.workflows.hcp_build_workflow(*, t1, mask, bedpostx, tract_dir, config, context)
Build the HCP ProbTrackX2 tractography workflow.
Hemisphere modes via
config.tractography.hemisphere:"left"/"right"(single hemisphere via fixed input),"both"(merged ROIs, default),"both-separately"(two hemispheres via Nipypeiterables).- Parameters:
t1 (
Path)mask (
Path)bedpostx (
GlobGroupResult)tract_dir (
Path)config (
PipelineConfig)context (
ProcessingContext)
- Return type:
Workflow
- thesis.workflows.mrtrix3_build_workflow(*, t1, mask, dwi, bvec, bval, tract_dir, config, context)
Build the MRtrix3 tractography workflow for one patient.
Hemisphere modes via
config.tractography.hemisphere:"left"/"right"(single hemisphere via fixed input),"both"(merged ROIs, default),"both-separately"(two hemispheres via Nipypeiterables).- Parameters:
t1 (
Path)mask (
Path)dwi (
Path)bvec (
Path)bval (
Path)tract_dir (
Path)config (
PipelineConfig)context (
ProcessingContext)
- Return type:
Workflow
- thesis.workflows.synthseg_build_workflow(*, t1, seg_dir, config, context)
Build a Nipype workflow that segments a T1w image with SynthSeg.
The workflow contains a single node (
synthseg) wrappingmri_synthseg. Outputs land in{output_dir}/segmentation/synthseg/{patient_id}_synthseg.nii.gz.- Parameters:
t1 (
Path|None) – Resolved T1-weighted image path (declared via@requires).seg_dir (
Path) – Resolved segmentation output directory.config (
PipelineConfig) – PipelineConfig (may include an optionalsynthsegsection).context (
ProcessingContext) – ProcessingContext carryingpatient_id.
- Return type:
Workflow- Returns:
Nipype Workflow ready to run or embed in a meta-workflow.
- thesis.workflows.tract_synthseg_build_workflow(*, t1, config, context)
Build the combined SynthSeg + tractography meta-workflow.
The tractography backend is chosen from
config.tractography.method:probtrackx2/fslbuilds thehcpworkflow,mrtrix3/tckgenbuilds themrtrix3workflow. Each backend writes to its owntractography/<backend>folder.ROI source mixing
Configure
tractography.atlas_sourcesfor atlas-sourced roles andtractography.synthseg_roi_labelsfor SynthSeg-sourced roles. Roles can be split arbitrarily:tractography: atlas_sources: - name: main # atlas — seed / waypoint / target roi_file: data/masks/annotation_full.nii.gz label_file: data/masks/label_map.csv waypoint_labels: thalamus_left: region_kind: seed label_name: Thalamus-Left synthseg_roi_labels: # SynthSeg — avoid / stop label_file: data/masks/synthseg_lut.csv waypoint_labels: csf: region_kind: avoid label_name: CSF
The
synthseg_roi_labelssection does not include aroi_filebecause the file is supplied at runtime by connecting the SynthSeg output.Connection logic
The meta-workflow uses a strict I/O contract — no node-name introspection.
inputnodeforwards the backend’s contract fields directly totract_wf.inputnode, and also connectsinputnode.t1_braintosynthseg_wf.inputnode.input_image. The single cross-workflow edgesynthseg_wf.outputnode.segmentation → tract_wf.inputnode.seg_mapdelivers the label map; per-resampler / per-hemisphere fan-out is handled inside the tractography workflow. Theoutputnodere-exposesfdt_paths.- Parameters:
config (
PipelineConfig) – PipelineConfig. Must satisfy the active backend’s requirements. May include asynthsegsection and/or atractography.synthseg_roi_labelssection.context (
ProcessingContext) – ProcessingContext withpatient_id,input_dir,output_dir.t1 (
Path)
- Return type:
Workflow- Returns:
Nipype Workflow ready for
NipypeExecutoror.run().
- thesis.workflows.preprocess_build_workflow(*, t1, t2, dwi_ap, dwi_ap_bval, dwi_ap_bvec, dwi_pa, config, context)
Build the preprocess workflow for one raw patient dataset.
- thesis.workflows.registration_build_workflow(*, config, context)
Build the configured registration workflow for one patient.
- Parameters:
config (
PipelineConfig)context (
ProcessingContext)
- Return type:
Workflow
- thesis.workflows.transform_build_workflow(*, config, context)
Build a transform workflow from
config.transforms.jobs.- Parameters:
config (
PipelineConfig)context (
ProcessingContext)
- Return type:
Workflow
- thesis.workflows.atlas_to_patient_build_workflow(*, config, context)
Build the atlas-to-patient-space transform workflow.
Delegates to the generic transform workflow after validating that the required transforms are configured. Raises
ValueErrorwhen no jobs are configured.- Parameters:
config (
PipelineConfig)context (
ProcessingContext)
- Return type:
Workflow
- thesis.workflows.full_pipeline_build_workflow(*, template, config, context)
Build the unified full-pipeline meta-workflow for one patient.
The backend is selected from
config.tractography.method; BedpostX is enabled/disabled structurally to match.- Parameters:
template (
Path) – Registration template (registration.fixed_image), declared viaExternalFileso an out-of-tree absolute template path is allowed and existence-checked.config (
PipelineConfig) – Validated pipeline configuration.context (
ProcessingContext) – Processing context carrying the patient ID, paths, and config.
- Return type:
Workflow- Returns:
Nipype Workflow ready for
NipypeExecutoror.run().
thesis.workflows.minimal#
Minimal Nipype workflow example for CLI usage.