Dataset validator¶
EEGDatasetCrawler
¶
Bases: BaseModel
Crawler to validate and map the raw EEG dataset directory structure.
Iterates through the root directory based on a list of expected participants and conditions. It verifies that the required folder hierarchy exists and contains exactly one EEG file per leaf node.
Attributes:
| Name | Type | Description |
|---|---|---|
root_path |
DirectoryPath
|
The base directory where raw data is stored. |
expected_participants |
list[str]
|
A list of participant IDs that must have corresponding directories. |
expected_conditions |
list[str] | None
|
Optional list of task/condition subdirectories expected within each participant folder. |
extension |
str
|
The file extension of the raw EEG recordings (e.g., '.edf', '.mff'). |
found_recordings |
list[RecordingMetadata]
|
A list of validated recording objects populated during the crawl. Excluded from model serialization. |
Source code in src/rs_bidsify/validation/dataset.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | |
verify_structure()
¶
Validate the dataset structure and populate found_recordings.
Runs automatically after model initialisation. It traverses the
directory tree, checking for the existence of participant and
condition folders, and delegates file checking to _check_leaf_node.
Returns:
| Type | Description |
|---|---|
EEGDatasetCrawler
|
The validated crawler instance with populated recording metadata. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If a participant directory is missing or if the structure validation fails at the leaf node. |
Source code in src/rs_bidsify/validation/dataset.py
RecordingMetadata
¶
Bases: BaseModel
Metadata representation of a single EEG recording file.
This model stores the relationship between a physical file on disk, its associated participant identifier, and the experimental condition. It includes logic to normalize participant IDs into BIDS-compliant subject strings.
Attributes:
| Name | Type | Description |
|---|---|---|
participant |
str
|
The raw participant identifier (e.g., 'sub-001' or 'pilot_01'). |
condition |
str | None
|
The experimental task or condition (e.g., 'resting', 'task-face'). |
path |
FilePath
|
The validated system path to the raw EEG recording file. |
Source code in src/rs_bidsify/validation/dataset.py
info_str
property
¶
A summary string of the subject and task.
Returns:
| Type | Description |
|---|---|
str
|
Formatted string: 'Sub: |
subject
property
¶
Extract a BIDS-compliant subject ID from the participant string.
Attempts to find an alphanumeric string following a dash or underscore. If no delimiter is found, it validates that the entire string is alphanumeric before returning it.
Returns:
| Type | Description |
|---|---|
str
|
The cleaned subject identifier. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no delimiter is present and the participant ID contains non-alphanumeric characters. |
task
property
¶
Derive the BIDS task name from the experimental condition.
If a condition is explicitly provided, it is returned as the task name. Otherwise, it defaults to "rest".
Returns:
| Type | Description |
|---|---|
str
|
The task label for BIDS filenames (e.g., 'rest', 'face_processing'). |