physioex.data.BasePhysioDataset#
- class physioex.data.BasePhysioDataset(root=None, channels=None, pipelines='raw', sequence_length=21, subset=None, cache_dir=None, cache_enabled=True, epoch_length_sec=None, label_transform=None, skip_corrupt=True, skip_subjects_without_channels=True, stage_map=None, trim_excess_wake=True, memmap_cache_size=1000)[source]#
Bases:
DatasetAbstract base class for lazy-loading EDF-based sleep datasets.
- Subclasses must implement:
_list_subjects()-> list[SubjectSpec]_read_subject_labels(spec)-> np.ndarray of int per-epoch labels
- Subclasses typically override:
DATASET_NAME(class attribute, used as cache directory name)CHANNEL_PREFERENCES(class attribute, per-modality preference lists)
- Optional overrides:
_read_edf_header(spec)to inject external metadata_read_subject_channel(spec, resolved)for non-EDF formats
- Parameters:
root (Optional[str])
channels (Optional[List[Union[str, Dict]]])
pipelines (Union[PreprocessingPipeline, str, Dict[str, Union[PreprocessingPipeline, str]]])
sequence_length (int)
subset (Optional[str])
cache_dir (Optional[str])
cache_enabled (bool)
epoch_length_sec (Optional[float])
label_transform (Optional[Callable])
skip_corrupt (bool)
skip_subjects_without_channels (bool)
stage_map (Optional[Dict])
trim_excess_wake (bool)
memmap_cache_size (int)
- __init__(root=None, channels=None, pipelines='raw', sequence_length=21, subset=None, cache_dir=None, cache_enabled=True, epoch_length_sec=None, label_transform=None, skip_corrupt=True, skip_subjects_without_channels=True, stage_map=None, trim_excess_wake=True, memmap_cache_size=1000)[source]#
- Parameters:
root (str | None)
pipelines (PreprocessingPipeline | str | Dict[str, PreprocessingPipeline | str])
sequence_length (int)
subset (str | None)
cache_dir (str | None)
cache_enabled (bool)
epoch_length_sec (float | None)
label_transform (Callable | None)
skip_corrupt (bool)
skip_subjects_without_channels (bool)
stage_map (Dict | None)
trim_excess_wake (bool)
memmap_cache_size (int)
Methods
__init__([root, channels, pipelines, ...])Return all unique channel names found across the dataset with their occurrence count.
close()Explicitly close all open memmap file handles.
Return metadata for all subjects keyed by subject_id.
Return the number of subjects in this dataset.
get_splits([fold])Return
(train, valid, test)subject_id lists.get_subject_events(subject_id)Return all temporal events for a subject without loading signals.
get_subject_metadata(subject_id)Return subject-level metadata without loading signals.
Return list of all subject IDs.
Return LRU memmap cache statistics.
probe([subject])Return discovered channels + metadata for a subject (int index, string id, or
None= first).split([fold])Return train/valid/test indices compatible with
physioex/data/dataset.py:PhysioExDataset.split.Attributes
CHANNEL_PREFERENCESDATASET_NAMEDEFAULT_EPOCH_LENGTH_SEC- available_channels()[source]#
Return all unique channel names found across the dataset with their occurrence count. Useful for discovering what channels to request.
- close()[source]#
Explicitly close all open memmap file handles.
This clears the LRU memmap cache and closes all file descriptors. Normally not needed as Python’s garbage collector will handle this, but useful for explicit cleanup or when reusing the same dataset object.
- Return type:
None
- get_splits(fold=0)[source]#
Return
(train, valid, test)subject_id lists.Default: random 70/15/15 split with seed
42 + fold. Subclasses can override to provide custom benchmark folds.
- get_subject_events(subject_id)[source]#
Return all temporal events for a subject without loading signals.
- Parameters:
subject_id (str)
- Return type:
- memmap_cache_stats()[source]#
Return LRU memmap cache statistics.
- Returns:
size: current number of cached memmaps
max_size: maximum cache size
hits: number of cache hits
misses: number of cache misses
hit_rate: hit rate as percentage
- Return type:
Dict with
- probe(subject=None)[source]#
Return discovered channels + metadata for a subject (int index, string id, or
None= first).
- split(fold=0)[source]#
Return train/valid/test indices compatible with
physioex/data/dataset.py:PhysioExDataset.split.Training: flat integer indices into the sequence-mode
__getitem__. Valid/Test: list of(dataset_idx, subject_id)tuples matching the legacy API. The convention is: one dataset here ->dataset_idx=0for all subjects.