Factory pattern for creating dataset instances from config. The factory searches for dataset classes in the datasets/ folder by looking up the dataset name in the module's namespace.
For 2D/3D datasets (inherit from BaseDataset):
Required methods:
_get_ordered_images_path()→ Returns(train_images, train_labels, val_images, val_labels, test_images, test_labels)get_loader(split)→ Returns appropriate loader for 'train'/'val'/'test'
Optional: Override _get_patch_loader() if you need a custom weighted sampler for patch-based training.
For 2D sliced datasets (inherit from BaseDataset2DSliced):
Required methods:
_get_ordered_images_path()→ Returns paths to 3D volumes_extract_slice_indices(split)→ Returns list of (volume_idx, slice_idx) tuplesget_loader(split)→ Returns DataLoader for 2D slices
Examples:
- ATLAS.py: 3D segmentation dataset with optional train/val split files or random splitting
- BraTS2D.py: 2D sliced version extracting axial slices from 3D BraTS volumes
- QaTaCov.py: 2D chest X-ray dataset (preprocessed)
- QaTaCovPreprocess.py: raw/preprocess dataset loader
- QaTaCovTextEmb.py: 2D chest X-ray dataset with report text embeddings
When you create a new dataset class, remember to add it to __init__.py in the datasets/ folder. This ensures the DatasetFactory can find and instantiate your custom dataset class. Simply import your new dataset class in the __init__.py file:
from .YourNewDataset import YourNewDataset