Description validator¶
AcceptableImpedance
¶
Bases: BaseModel
Threshold and units for acceptable sensor impedance levels.
Defines the maximum impedance value permitted for sensors during the recording session.
Attributes:
| Name | Type | Description |
|---|---|---|
value |
int
|
The maximum impedance threshold (e.g., 5, 20). |
units |
str
|
The unit of measurement for the impedance value, typically 'kOhm'. |
Source code in src/rs_bidsify/validation/description.py
AcquisitionSpecs
¶
Bases: BaseModel
Comprehensive hardware and software specifications for a recording.
Aggregates channel configurations, filter settings, and environmental details into a single schema used to populate BIDS sidecar files.
Attributes:
| Name | Type | Description |
|---|---|---|
software |
str
|
The name and version of the software used to acquire the data (e.g., 'LabRecorder v1.14', 'OpenBCI GUI'). |
acquisition_freq |
PositiveInt
|
The sampling rate of the recording in Hertz (Hz). |
file_format |
str
|
The format of the raw data file (e.g., 'BDF', 'EDF', 'FIFF'). |
amplifier_model |
str
|
The manufacturer and model of the EEG amplifier (e.g., 'BioSemi ActiveTwo', 'BrainAmp Standard'). |
eeg_channels |
EEGChanSpec
|
Specifications for the EEG electrode array and referencing scheme. |
aux_channels |
dict[str, AuxChanSpec]
|
A mapping of auxiliary channel names to their respective types, units, and locations. |
power_line_freq |
LineFreqOptions
|
The frequency of the local electrical grid (e.g., 50 or 60 Hz). |
filters |
list[FilterSpec]
|
A list of hardware and software filters applied during acquisition. |
extras |
(ExtraSpec | None, optional)
|
Additional environmental and hardware metadata, such as lighting and impedance thresholds. |
Source code in src/rs_bidsify/validation/description.py
AuxChanSpec
¶
Bases: BaseModel
Metadata specification for auxiliary channels.
Defines how non-EEG channels are categorised for MNE and BIDS, including their physical units and anatomical sensor locations. This model facilitates channel renaming and retyping during the BIDS conversion process.
Attributes:
| Name | Type | Description |
|---|---|---|
bids_type |
BIDSChanTypes
|
The BIDS channel type (e.g., 'TRIG', 'MISC', 'EYE'). |
description |
(str | None, optional)
|
A human-readable description of the channel's purpose or source. |
units |
(str | None, optional)
|
The physical unit of the signal (e.g., 'V', 'uV', 'mmHg'). |
location |
str | dict[str, str]
|
Anatomical placement of the sensors. Can be a descriptive string (e.g., 'left index finger'), "n/a", or a dictionary defining the specific lead configuration (e.g., active, reference, and ground placements) |
Source code in src/rs_bidsify/validation/description.py
mne_type
property
¶
Gets the MNE channel type based in the BIDS channel type.
BIDSChanTypes
¶
Bases: StrEnum
Channel types defined by the BIDS specification.
Upper-case strings used in the 'type' column of BIDS channels.tsv files.
Source code in src/rs_bidsify/validation/description.py
BaseRestingTask
¶
Bases: BaseModel
Core duration requirements for a resting state segment.
Attributes:
| Name | Type | Description |
|---|---|---|
duration_secs |
PositiveInt
|
The required length of the resting state recording in seconds. |
Source code in src/rs_bidsify/validation/description.py
CustomRestingTask
¶
Bases: BaseRestingTask
Named resting state condition with required stimulus description.
Used for non-standard resting segments that require a specific condition label and mandatory stimulus details.
Attributes:
| Name | Type | Description |
|---|---|---|
duration_secs |
PositiveInt
|
The required length of the resting state recording in seconds. |
condition_name |
str
|
The unique identifier for the custom task (e.g., 'meditation', 'pre-task-rest'). |
stimulus_description |
str
|
Mandatory details regarding the specific instructions or environment for this custom condition. |
Source code in src/rs_bidsify/validation/description.py
DatasetMetadata
¶
Bases: BaseModel
Schema for top-level BIDS dataset metadata.
Defines the global information required for the dataset description, including institutional details, funding, and ethical approval status. This model ensures that the dataset-level requirements for BIDS compliance are met before export.
Attributes:
| Name | Type | Description |
|---|---|---|
population |
str
|
A description of the study population (e.g., 'healthy adults'). |
dataset_name |
str
|
The full name of the dataset. |
authors |
list[str]
|
List of individuals who contributed to the creation of the dataset. |
funding |
(str | list[str] | None, optional)
|
Funding sources or grant numbers associated with the study. |
ethics_approval |
EthicsApprovalOptions
|
The institutional review board or ethics committee approval status. |
license |
str
|
The data license (e.g., 'CC0', 'PDDL') under which the data is shared. |
references_links |
str | list[str]
|
Citations or URLs to publications or repositories related to the data. |
institution_name |
str
|
The name of the university or research facility where data was collected. |
institution_dept |
str
|
The specific department within the institution. |
Source code in src/rs_bidsify/validation/description.py
create_dict()
¶
Generate a dictionary formatted for BIDS dataset_description.json.
Maps internal model fields to their official BIDS-compliant keys as defined in the BIDS specification. This dictionary can be serialized directly to JSON.
Returns:
| Type | Description |
|---|---|
dict
|
A dictionary containing the standardised BIDS metadata keys (e.g., 'Name', 'Authors', 'DatasetDOI'). |
Source code in src/rs_bidsify/validation/description.py
DescriptionSpec
¶
Bases: BaseModel
Root schema for the machine-readable dataset description.
Aggregates global metadata, acquisition hardware settings, resting-state protocols, and logic for handling subject-variable fields. This serves as the primary configuration object for BIDS conversion and directory crawling.
Attributes:
| Name | Type | Description |
|---|---|---|
metadata |
DatasetMetadata
|
Global dataset information including funding, authors, and ethics. |
conditions |
(list[str] | None, optional)
|
A list of experimental task or condition names. Aliased as 'tasks' in the input data. |
acquisition_spec |
AcquisitionSpecs
|
Hardware and software technical specifications for the recording. |
resting_state |
RestingStateProtocol
|
The protocol definition and event mapping for resting segments. |
variable_fields |
(dict[str, str] | None, optional)
|
A mapping of specification keys to subject-level metadata fields used for dynamic value injection. |
Source code in src/rs_bidsify/validation/description.py
581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 | |
crawler_info
property
¶
Metadata for the directory crawler to filter and identify files.
Returns:
| Type | Description |
|---|---|
dict
|
A dictionary containing 'expected_conditions' and the target file 'extension'. |
from_template(template, varies_paths, subject_info)
classmethod
¶
Create a subject-specific specification from a base template.
Iterates through designated paths in the configuration and replaces placeholder or generic values with specific metadata associated with an individual participant.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
template
|
Self
|
The base configuration model used as the structural template. |
required |
varies_paths
|
list of list of str
|
A list of nested dictionary paths (e.g., [['acquisition_spec', 'software']]) indicating which fields require dynamic updates. |
required |
subject_info
|
SubjectMetadata
|
The source object containing the actual participant values to be injected into the template. |
required |
Returns:
| Type | Description |
|---|---|
Self
|
A new instance of DescriptionSpec with all variable fields resolved to subject-specific values. |
Source code in src/rs_bidsify/validation/description.py
EEGChanSpec
¶
Bases: BaseModel
Configuration for the EEG electrode array and referencing.
Defines the physical properties of the EEG acquisition, including the number of sensors, their spatial arrangement, and the electrical referencing scheme used during the recording.
Attributes:
| Name | Type | Description |
|---|---|---|
number |
PositiveInt
|
Total count of EEG channels present in the recording. |
montage |
Montage
|
The spatial layout or naming convention of the electrodes, see the Montage class for more information. |
ground |
str
|
The physical location of the ground electrode (e.g., 'AFz', 'Fz'). |
reference |
str | Literal['VARIES']
|
The electrical reference used. Can be a specific electrode location (e.g., 'Cz', 'Average') or "VARIES" if the reference is inconsistent across the dataset or subject to offline changes. |
Source code in src/rs_bidsify/validation/description.py
EthicsApprovalOptions
¶
ExtraSpec
¶
Bases: BaseModel
Optional metadata for experimental environment and recording quality.
Groups secondary environmental factors and technical hardware specifications that characterise the recording conditions.
Attributes:
| Name | Type | Description |
|---|---|---|
acceptable_impedance |
(AcceptableImpedance | None, optional)
|
The threshold and units used to define valid sensor impedance. |
electrode_type |
(str | None, optional)
|
The type of electrodes used (e.g., 'active', 'passive', 'Ag/AgCl'). |
conductive_medium |
(str | None, optional)
|
The material used to reduce impedance (e.g., 'gel', 'paste', 'saline'). |
faraday_cage |
(bool | None, optional)
|
Whether the recording was performed inside a Faraday cage. |
sound_proof |
(bool | None, optional)
|
Whether the recording was performed in a sound-attenuated booth. |
lighting_conditions |
(LightingConditions | None, optional)
|
The ambient lighting state and intensity of the experimental room. |
Source code in src/rs_bidsify/validation/description.py
FilterSpec
¶
Bases: BaseModel
Configuration for signal filters applied to the dataset.
Defines the parameters and origin of a specific filter, intended for direct inclusion in the BIDS EEG sidecar metadata.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
The descriptive name of the filter (e.g., 'High-pass', 'Notch'). |
type |
FilterTypeOptions
|
The source of the filter application, either hardware or software. |
info |
dict[str, Any]
|
A dictionary of filter parameters (e.g., cut-off frequencies, roll-off, order). This content is mapped directly to the BIDS EEG sidecar JSON. |
Source code in src/rs_bidsify/validation/description.py
FilterTypeOptions
¶
LightingConditions
¶
Bases: BaseModel
Environmental lighting metadata for the recording session.
Captures the ambient lighting state and intensity of the experimental room during data acquisition.
Attributes:
| Name | Type | Description |
|---|---|---|
description |
str
|
A qualitative description of the lighting source or state (e.g., 'dimmed', 'natural light', 'fluorescent'). |
measurement |
(str, optional)
|
The quantitative value and the method or instrument used for the reading (e.g., '150 lux via T-10A Illuminance Meter', 'low via subjective report'). |
Source code in src/rs_bidsify/validation/description.py
LineFreqOptions
¶
Montage
¶
Bases: BaseModel
Configuration for sensor locations and coordinate frames.
Ensures that a valid electrode montage is provided, either by referencing a built-in MNE montage name or providing a path to a custom sensor file.
Attributes:
| Name | Type | Description |
|---|---|---|
mne_name |
str or None
|
Name of a built-in MNE montage (e.g., 'standard_1020'). If provided, must be a recognised string in MNE's built-in montages. |
path |
FilePath or None
|
Valid path to a custom sensor location file on the local system. |
Source code in src/rs_bidsify/validation/description.py
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 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 | |
montage
cached
property
¶
Lazily generate and return the MNE DigMontage object.
Uses cached_property to ensure the file or standard library is only read once upon the first access, improving performance.
Returns:
| Type | Description |
|---|---|
DigMontage
|
The constructed or loaded MNE montage object. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the class reaches an invalid state lacking both a name and a path. |
check_input_exclusivity()
¶
Ensure exactly one source for the montage is provided.
Validates that either an MNE name or a custom file path is defined, but strictly prevents providing both or neither.
Returns:
| Type | Description |
|---|---|
Self
|
The validated model instance. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If both |
Source code in src/rs_bidsify/validation/description.py
validate_mne_name(v)
classmethod
¶
Validate that the provided montage name is built into MNE.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v
|
str or None
|
The standard montage name to check. |
required |
Returns:
| Type | Description |
|---|---|
str or None
|
The validated montage name. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the provided name is not found in MNE's built-in montages. |
Source code in src/rs_bidsify/validation/description.py
RestingStateProtocol
¶
Bases: BaseModel
Comprehensive resting state protocol and event mapping.
Defines instructions, standard conditions, and custom segments, along with a dictionary mapping trigger codes to event descriptions.
Attributes:
| Name | Type | Description |
|---|---|---|
instructions |
str
|
The textual instructions provided to the participant prior to starting the resting state session. |
eyes_open |
RestingStateTask | Literal[False]
|
Configuration for the eyes-open segment. Set to False if this condition is not part of the protocol. |
eyes_closed |
RestingStateTask | Literal[False]
|
Configuration for the eyes-closed segment. Set to False if this condition is not part of the protocol. |
other_tasks |
(list[CustomRestingTask] | None, optional)
|
A list of additional resting state conditions or segments not covered by the standard eyes-open/closed categories. |
events |
dict[str, str]
|
A mapping of hardware trigger codes to human-readable labels (e.g., {"1": "eyes_open_start", "2": "eyes_closed_start"}). |
Source code in src/rs_bidsify/validation/description.py
RestingStateTask
¶
Bases: BaseRestingTask
Standard resting state condition with optional stimulus info.
Inherits core duration requirements and allows for an optional description of the resting environment or instructions.
Attributes:
| Name | Type | Description |
|---|---|---|
duration_secs |
PositiveInt
|
The required length of the resting state recording in seconds. |
stimulus_description |
(str | None, optional)
|
Details regarding the resting state protocol (e.g., 'eyes closed', 'fixation cross'). |