make_synthetic_cohort
Note
This page is a reference documentation. It only explains the function signature, and not how to use it. Please refer to the Habitat Guide and Python API guide (v2.0) for usage.
- make_synthetic_cohort(n_subjects: int = 4, modalities: Tuple[str, ...] = ('T1', 'T2'), shape: Tuple[int, int, int] = (32, 32, 32), n_subregions: int = 3, rng: int | Generator | SeedSequence = 0, *, realism: Literal['demo', 'legacy'] = 'demo') Cohort[source]
Build a deterministic imaging cohort entirely in memory.
Each subject receives its own child seed from
SeedSequence.spawnso that per-subject noise differs while the cohort remains reproducible for a fixed master seed. The ROI containsn_subregionsintensity blobs with distinct modality profiles to support multi-habitat clustering.With the default
realism="demo", volumes look like soft tissue plus an irregular lesion blob (demo-realistic, not clinical anatomy). Passrealism="legacy"for the older flat ROI / zero-background look.- Parameters:
n_subjects – Number of subjects to synthesise.
modalities – Modality keys attached to every subject.
shape – Cubic grid shape
(z, y, x).n_subregions – Number of distinguishable subregions inside the ROI.
rng – Master seed controlling the entire cohort.
realism –
"demo"(default) or"legacy".
- Returns:
A
Cohortwith subjectssubj001,subj002, …
Examples
>>> from habit.datasets import make_synthetic_cohort >>> cohort = make_synthetic_cohort(n_subjects=3, rng=42) >>> len(cohort) 3 >>> cohort.subject_ids ('subj001', 'subj002', 'subj003') >>> subject = cohort[0] >>> sorted(subject.images), sorted(subject.masks) (['T1', 'T2'], ['tumor'])