utils
tit.pre.qsi.utils ¶
Utility functions for QSI integration.
This module provides path resolution, validation, and helper functions for the QSI Docker-out-of-Docker integration.
resolve_host_project_path ¶
Resolve a container path to the corresponding host path for Docker mounts.
When running inside the SimNIBS container, project directories are mounted at /mnt/$PROJECT_DIR_NAME. However, sibling containers (QSIPrep/QSIRecon) need to mount the original host path, not the container path.
The LOCAL_PROJECT_DIR environment variable contains the host machine's absolute path to the project directory.
Parameters¶
container_path : str Path as seen from inside the SimNIBS container (e.g., /mnt/myproject).
Returns¶
str The corresponding host path for Docker volume mounts.
Raises¶
ValueError If LOCAL_PROJECT_DIR is not set or the path cannot be resolved.
Source code in tit/pre/qsi/utils.py
get_host_project_dir ¶
get_host_project_dir() -> str
Get the host machine's project directory path.
Returns¶
str Absolute path to the project directory on the host machine.
Raises¶
ValueError If LOCAL_PROJECT_DIR is not set.
Source code in tit/pre/qsi/utils.py
check_image_exists ¶
Check if a Docker image exists locally.
Parameters¶
image : str Docker image name (e.g., 'pennlinc/qsiprep'). tag : str Image tag (e.g., '26.0.0').
Returns¶
bool True if the image exists locally.
Source code in tit/pre/qsi/utils.py
pull_image_if_needed ¶
Pull a Docker image if it doesn't exist locally.
Parameters¶
image : str Docker image name. tag : str Image tag. logger : logging.Logger Logger for status messages.
Returns¶
bool True if image is available (either existed or was pulled successfully).
Source code in tit/pre/qsi/utils.py
validate_dood_environment ¶
validate_dood_environment(project_dir: str, *, require_gpu: bool = False) -> tuple[bool, str | None]
Validate Docker-outside-of-Docker prerequisites before QSI runs.
Source code in tit/pre/qsi/utils.py
validate_bids_dwi ¶
Validate that DWI data exists for a subject in BIDS format.
Parameters¶
project_dir : str Path to the BIDS project root. subject_id : str Subject identifier (without 'sub-' prefix). logger : logging.Logger Logger for status messages.
Returns¶
tuple[bool, str | None] (is_valid, error_message). If valid, error_message is None.
Source code in tit/pre/qsi/utils.py
validate_qsiprep_output ¶
Validate that QSIPrep output exists for a subject.
Parameters¶
project_dir : str Path to the project root. subject_id : str Subject identifier.
Returns¶
tuple[bool, str | None] (is_valid, error_message). If valid, error_message is None.
Source code in tit/pre/qsi/utils.py
format_memory_limit ¶
get_container_resource_limits ¶
Return (cpu_limit, mem_limit_bytes) for the current container.
- cpu_limit: integer number of CPUs available via cgroups/cpuset if limited, otherwise None.
- mem_limit_bytes: memory limit in bytes via cgroups if limited, otherwise None.
Source code in tit/pre/qsi/utils.py
365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 | |
get_inherited_dood_resources ¶
Determine DooD resource defaults that match the current container.
Returns (cpus, memory_gb) with conservative rounding.