Source code for thesis.workflows.hcp.verifiers
"""Preflight verifiers for the HCP ProbTrackX2 workflow.
Each verifier is a pure function returning a list of error strings (empty when
the check passes). ``verify_requirements`` aggregates them in the order they
were defined in the legacy ``workflow.py`` so error messages remain stable.
"""
from thesis.core.config import PipelineConfig
from thesis.core.context import ProcessingContext
from ..common import get_atlas_sources
from ..config import prepare_hcp_paths
from .atlas_transform import _verify_atlas_transform
from .bedpostx import _verify_bedpostx_samples
from .brain_mask import _verify_brain_mask
from .roi import _verify_roi_inputs
from .seed import _verify_seed_inputs
[docs]
def verify_requirements(config: PipelineConfig, context: ProcessingContext) -> list[str]:
"""Cross-cutting preflight checks for the HCP ProbTrackX2 workflow.
Note: T1, brain mask, and BedpostX sample existence are *also* validated
declaratively by ``@requires`` on :func:`build_workflow`; the composite
verifier may surface near-duplicate messages on a missing file. The
explicit verifier checks below carry the more informative, search-path
aware messages and stay for that reason.
"""
hcp_paths = prepare_hcp_paths(config, context)
input_dir = hcp_paths["input_dir"]
errors: list[str] = []
errors.extend(_verify_bedpostx_samples(hcp_paths, context))
errors.extend(_verify_brain_mask(hcp_paths))
errors.extend(_verify_seed_inputs(config, input_dir))
errors.extend(_verify_roi_inputs(config, context, input_dir))
for atlas_source in get_atlas_sources(config):
errors.extend(_verify_atlas_transform(config, context, input_dir, atlas_source))
return errors
__all__ = [
"_verify_atlas_transform",
"_verify_bedpostx_samples",
"_verify_brain_mask",
"_verify_roi_inputs",
"_verify_seed_inputs",
"verify_requirements",
]