DirectoryDataSource
Note
This page is a reference documentation. It only explains the class signature, and not how to use it. Please refer to the Habitat Guide and Python API guide (v2.0) for usage.
- class DirectoryDataSource(root: str | Path, *, modalities: Sequence[str], roi: str, images_folder: str = 'images', masks_folder: str = 'masks', name: str | None = None, metadata: Dict[str, Any] | None = None)[source]
Bases:
objectBuild a
Cohortfrom HABIT’s conventional directory layout.- Parameters:
root – Directory root holding the images and masks subdirectories.
modalities – Modality keys to include, in analysis order. A subject missing any requested modality is skipped with a warning, mirroring the v0.1 scan behaviour.
roi – Mask key identifying the region of interest.
images_folder – Name of the images subdirectory under
root.masks_folder – Name of the masks subdirectory under
root.name – Human-readable cohort name used in reports.
metadata – Optional cohort-level attributes (centre, scanner, study).
- __init__(root: str | Path, *, modalities: Sequence[str], roi: str, images_folder: str = 'images', masks_folder: str = 'masks', name: str | None = None, metadata: Dict[str, Any] | None = None) None[source]
- load() Cohort[source]
Build the cohort described by this source.
- Returns:
A cohort with a defined, reproducible subject order (sorted subject ids), whose images and masks are lazy file references.
- Raises:
DataFormatError – If the convention folders are missing.