Modality Vocabulary¶
The modality vocabulary backs the per-channel channel_type / modality
contract used by Recording.add_channel and set_channel: it validates channel
types and coarse modalities (EEG, EMG, IEEG, MEG, BEH, MISC) and maps types to
BIDS channels.tsv values.
Module Documentation¶
biosigio.core.modality
¶
BIDS-aligned channel-type and modality vocabularies for biosignal data.
This module is the single source of truth for the two-axis model that replaces
the historical single channel_type string:
channel_type: the fine-grainedBrain Imaging Data Structure (BIDS) <https://bids-specification.readthedocs.io/>_ channeltype(e.g.EEG,EMG,ECG,ACC).modality: the coarse recording modality (EEG,EMG,IEEG,MEG,BEH,MISC).
There is no silent default; callers must provide an explicit channel type, and unknown values raise rather than being relabelled.
VALID_CHANNEL_TYPES = frozenset({'EEG', 'SEEG', 'ECOG', 'DBS', 'MEGMAG', 'MEGGRADAXIAL', 'MEGGRADPLANAR', 'MEGREFMAG', 'MEGREFGRADAXIAL', 'MEGREFGRADPLANAR', 'EMG', 'ECG', 'EKG', 'EOG', 'VEOG', 'HEOG', 'REF', 'TRIG', 'MISC', 'OTHER', 'ACC', 'GYRO', 'QUAT', 'CTRL', 'MAGN', 'RESP', 'GSR', 'TEMP', 'PPG', 'SYSCLOCK'})
module-attribute
¶
VALID_MODALITIES = frozenset({'EEG', 'EMG', 'IEEG', 'MEG', 'BEH', 'MISC'})
module-attribute
¶
_BIDS_CHANNELS_TSV_TYPES = frozenset({'EEG', 'SEEG', 'ECOG', 'DBS', 'MEGMAG', 'MEGGRADAXIAL', 'MEGGRADPLANAR', 'MEGREFMAG', 'MEGREFGRADAXIAL', 'MEGREFGRADPLANAR', 'EMG', 'ECG', 'EKG', 'EOG', 'VEOG', 'HEOG', 'REF', 'TRIG', 'MISC', 'RESP', 'GSR', 'TEMP', 'PPG', 'SYSCLOCK'})
module-attribute
¶
_CHANNEL_TYPE_TO_MODALITY = {'EEG': 'EEG', 'EMG': 'EMG', 'SEEG': 'IEEG', 'ECOG': 'IEEG', 'DBS': 'IEEG', 'MEGMAG': 'MEG', 'MEGGRADAXIAL': 'MEG', 'MEGGRADPLANAR': 'MEG', 'MEGREFMAG': 'MEG', 'MEGREFGRADAXIAL': 'MEG', 'MEGREFGRADPLANAR': 'MEG'}
module-attribute
¶
infer_modality_from_channel_type(channel_type)
¶
Derive the coarse modality for a channel type.
The mapping is deterministic: neural types map to EEG/IEEG/MEG, EMG maps
to EMG, and every other valid type (ECG, EOG, ACC, TRIG, ...) maps to MISC.
Args: channel_type: A channel type string (case-insensitive); validated first.
Returns:
One of :data:VALID_MODALITIES.
Raises:
ValueError: If channel_type is not a known type.
Source code in biosigio/core/modality.py
to_bids_channels_tsv_type(channel_type)
¶
Map an biosigio channel type to a BIDS channels.tsv type value.
Genuine BIDS electrophysiology/physiology types pass through; device-domain
types (ACC, GYRO, QUAT, CTRL, MAGN) and OTHER map to MISC.
Source code in biosigio/core/modality.py
validate_channel_type(channel_type)
¶
Normalize and validate a channel type against :data:VALID_CHANNEL_TYPES.
Args: channel_type: A channel type string (case-insensitive).
Returns: The canonical uppercase channel type.
Raises:
ValueError: If channel_type is empty, n/a, or not a known type.
Source code in biosigio/core/modality.py
validate_modality(modality)
¶
Normalize and validate a modality against :data:VALID_MODALITIES.
Args: modality: A modality string (case-insensitive).
Returns: The canonical uppercase modality.
Raises:
ValueError: If modality is not a known modality.