Source code for thesis.workflows.hcp.config.params

"""HCP tractography parameter extraction."""

from typing import TypedDict

from thesis.core.config import PipelineConfig

DEFAULT_N_SAMPLES = 5000
DEFAULT_N_STEPS = 2000
DEFAULT_STEP_LENGTH = 0.5
DEFAULT_CURVATURE_THRESHOLD = 0.2
DEFAULT_DIST_THRESH = 0.0
DEFAULT_FIBST = 1
DEFAULT_RAND_FIB = 0
DEFAULT_MEM_GB_GPU = 8.0
DEFAULT_MEM_GB_CPU = 4.0


[docs] class TractographyParams(TypedDict): """Runtime tractography parameters for the ProbTrackX2 node.""" n_samples: int n_steps: int step_length: float curvature_threshold: float force_dir: bool opd: bool loop_check: bool dist_thresh: float fibst: int rand_fib: int mod_euler: bool mem_gb_gpu: float mem_gb_cpu: float
[docs] def prepare_tractography_params(config: PipelineConfig) -> TractographyParams: """ Extract tractography parameters from config with sensible defaults. Args: config: PipelineConfig with tractography section Returns: Dict with tractography parameters: n_samples, n_steps, step_length, curvature_threshold, force_dir, opd, loop_check, dist_thresh, fibst, rand_fib, mod_euler, mem_gb_gpu, mem_gb_cpu """ tract_cfg = getattr(config, "tractography", None) return { "n_samples": getattr(tract_cfg, "n_samples", DEFAULT_N_SAMPLES), "n_steps": getattr(tract_cfg, "n_steps", DEFAULT_N_STEPS), "step_length": getattr(tract_cfg, "step_length", DEFAULT_STEP_LENGTH), "curvature_threshold": getattr( tract_cfg, "curvature_threshold", DEFAULT_CURVATURE_THRESHOLD, ), "force_dir": getattr(tract_cfg, "force_dir", True), "opd": getattr(tract_cfg, "opd", True), "loop_check": getattr(tract_cfg, "loop_check", True), "dist_thresh": getattr(tract_cfg, "dist_thresh", DEFAULT_DIST_THRESH), "fibst": getattr(tract_cfg, "fibst", DEFAULT_FIBST), "rand_fib": getattr(tract_cfg, "rand_fib", DEFAULT_RAND_FIB), "mod_euler": getattr(tract_cfg, "mod_euler", False), "mem_gb_gpu": getattr(tract_cfg, "mem_gb_gpu", DEFAULT_MEM_GB_GPU), "mem_gb_cpu": getattr(tract_cfg, "mem_gb_cpu", DEFAULT_MEM_GB_CPU), }