BIDS Models#
- class BidsSessionMetadata(
- *,
- session_id: str | None = None,
- participant: Participant,
- general_metadata: GeneralMetadata,
- events: Events | None = None,
- probe_table: ProbeTable | None = None,
- electrode_table: ElectrodeTable | None = None,
- channel_table: ChannelTable | None = None,
- has_units_table: bool = False,
- has_electrical_series_in_acquisition: bool = False,
- run_config: RunConfig = <factory>,
- sanitization: Sanitization | None = None,
- **extra_data: Any,
Bases:
BaseMetadataContainerModelSchema for the metadata of a single BIDS session.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- session_id: str | None#
- participant: Participant#
- general_metadata: GeneralMetadata#
- events: Events | None#
- probe_table: ProbeTable | None#
- electrode_table: ElectrodeTable | None#
- channel_table: ChannelTable | None#
- has_units_table: bool#
- has_electrical_series_in_acquisition: bool#
- sanitization: Sanitization | None#
- model_post_init(context: Any, /) None[source]#
This function is meant to behave like a BaseModel method to initialize private attributes.
It takes context as an argument since that’s what pydantic-core passes when calling it.
- Args:
self: The BaseModel instance. context: The context.
- property notifications: list[Notification]#
All notifications from contained session converters.
These can accumulate over time based on which instance methods have been called.
- classmethod from_nwbfile_paths(
- nwbfile_paths: list[Annotated[Path, PathType(path_type=file)]] | list[HttpUrl] = FieldInfo(annotation=NoneType, required=True, metadata=[MinLen(min_length=1)]),
- run_config: RunConfig = FieldInfo(annotation=NoneType, required=False, default_factory=RunConfig),
- model_config = {'extra': 'allow', 'validate_assignment': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class Channel(
- *,
- notifications: list[Notification] = <factory>,
- name: str,
- electrode_name: str,
- type: str,
- units: str,
- sampling_frequency: float,
- low_cutoff: float | None = None,
- high_cutoff: float | None = None,
- reference: str | None = None,
- notch: str | None = None,
- channel_label: str | None = None,
- stream_id: str | None = None,
- description: str | None = None,
- software_filter_types: str | None = None,
- status: Literal['good',
- 'bad',
- 'n/a'] | None=None,
- status_description: str | None = None,
- gain: float | None = None,
- time_offset: float | None = None,
- time_reference_channel: str | None = None,
- ground: str | None = None,
- recording_mode: str | None = None,
- **extra_data: Any,
Bases:
BaseMetadataModelCreate a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- name: str#
- electrode_name: str#
- type: str#
- units: str#
- sampling_frequency: float#
- low_cutoff: float | None#
- high_cutoff: float | None#
- reference: str | None#
- notch: str | None#
- channel_label: str | None#
- stream_id: str | None#
- description: str | None#
- software_filter_types: str | None#
- status: Literal['good', 'bad', 'n/a'] | None#
- status_description: str | None#
- gain: float | None#
- time_offset: float | None#
- time_reference_channel: str | None#
- ground: str | None#
- recording_mode: str | None#
- model_config = {'extra': 'allow', 'validate_assignment': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class ChannelTable(
- *,
- channels: list[Channel],
- modality: Literal['ecephys', 'icephys'],
- **extra_data: Any,
Bases:
BaseMetadataContainerModelCreate a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- modality: Literal['ecephys', 'icephys']#
- property notifications: list[Notification]#
All notifications from contained session converters.
These can accumulate over time based on which instance methods have been called.
- to_tsv(file_path: str | Path)[source]#
Write the channels data to a TSV file.
- Parameters:
file_path (path) – The path where the TSV file will be saved.
- to_json(file_path: str | Path) None[source]#
Save the channels information to a JSON file.
- Parameters:
file_path (path) – The path to the output JSON file.
- model_config = {'extra': 'allow', 'validate_assignment': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_post_init(context: Any, /) None#
This function is meant to behave like a BaseModel method to initialize private attributes.
It takes context as an argument since that’s what pydantic-core passes when calling it.
- Args:
self: The BaseModel instance. context: The context.
- class DatasetDescription(*, notifications: list[~nwb2bids.notifications._notification.Notification] = <factory>, Name: str | None = None, BIDSVersion: ~typing.Annotated[str | None, _PydanticGeneralMetadata(pattern='^\\d+\\.\\d+(?:\\.\\d+)?$')], HEDVersion: ~typing.Annotated[str | None, _PydanticGeneralMetadata(pattern='^\\d+\\.\\d+(?:\\.\\d+)?$')], Description: str | None = None, DatasetType: ~typing.Literal['raw', 'derivative'] = 'raw', Authors: list[str] | None = None, License: ~typing.Literal['CC-BY-4.0', 'CC0-1.0'] | None = None, GeneratedBy: list[~nwb2bids.bids_models._dataset_description.GeneratedByItem] | None = None, **extra_data: ~typing.Any)[source]#
Bases:
BaseMetadataModelSchema for the dataset description in BIDS format.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- Name: str | None#
- BIDSVersion: str | None#
- HEDVersion: str | None#
- Description: str | None#
- DatasetType: Literal['raw', 'derivative']#
- Authors: list[str] | None#
- License: Literal['CC-BY-4.0', 'CC0-1.0'] | None#
- GeneratedBy: list[GeneratedByItem] | None#
- model_post_init(context: Any, /) None[source]#
Override this method to perform additional initialization after __init__ and model_construct. This is useful if you want to do some validation that requires the entire model to be initialized.
- classmethod from_file_path(
- file_path: Annotated[Path, PathType(path_type=file)],
Load the BIDS dataset description from a JSON file.
- Parameters:
file_path (FilePath) – Path to the JSON file containing the dataset metadata.
- Returns:
An instance of DatasetDescription populated with data from the file.
- Return type:
BidsDatasetMetadata or None
- model_config = {'extra': 'allow', 'validate_assignment': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class Electrode(
- *,
- notifications: list[Notification] = <factory>,
- name: str,
- probe_name: str,
- x: float = nan,
- y: float = nan,
- z: float = nan,
- hemisphere: Literal['L',
- 'R',
- 'n/a']='n/a',
- impedance: float = nan,
- shank_id: str = 'n/a',
- size: float | None = None,
- electrode_shape: str | None = None,
- material: str | None = None,
- location: str | None = None,
- pipette_solution: str | None = None,
- internal_pipette_diameter: float | None = None,
- external_pipette_diameter: float | None = None,
- **extra_data: Any,
Bases:
BaseMetadataModelCreate a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- name: str#
- probe_name: str#
- x: float#
- y: float#
- z: float#
- hemisphere: Literal['L', 'R', 'n/a']#
- impedance: float#
- shank_id: str#
- size: float | None#
- electrode_shape: str | None#
- material: str | None#
- location: str | None#
- pipette_solution: str | None#
- internal_pipette_diameter: float | None#
- external_pipette_diameter: float | None#
- model_config = {'extra': 'allow', 'validate_assignment': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class ElectrodeTable(
- *,
- electrodes: list[Electrode],
- modality: Literal['ecephys', 'icephys'],
- **extra_data: Any,
Bases:
BaseMetadataContainerModelCreate a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- modality: Literal['ecephys', 'icephys']#
- property notifications: list[Notification]#
All notifications from contained session converters.
These can accumulate over time based on which instance methods have been called.
- to_tsv(file_path: str | Path) None[source]#
Write the electrode data to a TSV file.
- Parameters:
file_path (path) – The path to the output TSV file.
- to_json(file_path: str | Path) None[source]#
Save the electrode information to a JSON file.
- Parameters:
file_path (path) – The path to the output JSON file.
- model_config = {'extra': 'allow', 'validate_assignment': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_post_init(context: Any, /) None#
This function is meant to behave like a BaseModel method to initialize private attributes.
It takes context as an argument since that’s what pydantic-core passes when calling it.
- Args:
self: The BaseModel instance. context: The context.
- class GeneralMetadata(
- *,
- InstitutionName: str | None = None,
- InstitutionAddress: str | None = None,
- InstitutionalDepartmentName: str | None = None,
- PowerLineFrequency: float | Literal['n/a'] = 'n/a',
- Manufacturer: str | None = None,
- ManufacturersModelName: str | None = None,
- ManufacturersModelVersion: str | None = None,
- RecordingSetupName: str | None = None,
- SamplingFrequency: float = -1.0,
- DeviceSerialNumber: str | None = None,
- SoftwareName: str | None = None,
- SoftwareVersions: str | None = None,
- RecordingDuration: float | None = None,
- RecordingType: str | None = None,
- EpochLength: float | None = None,
- SoftwareFilters: dict[str, dict[str, Any]] | Literal['n/a'] = 'n/a',
- HardwareFilters: dict[str, dict[str, Any]] | Literal['n/a'] = 'n/a',
- PharmaceuticalName: str | None = None,
- PharmaceuticalDoseAmount: float | list[float] | None = None,
- PharmaceuticalDoseUnits: str | None = None,
- PharmaceuticalDoseRegimen: str | None = None,
- PharmaceuticalDoseTime: float | list[float] | None = None,
- BodyPart: str | None = None,
- BodyPartDetails: str | None = None,
- BodyPartDetailsOntology: str | None = None,
- SampleEnvironment: str | None = None,
- SampleEmbedding: str | None = None,
- SliceThickness: int | float | None = None,
- SampleExtractionProtocol: str | None = None,
- SupplementarySignals: str | None = None,
- TaskName: str | None = None,
- TaskDescription: str | None = None,
- Instructions: str | None = None,
- CogAtlasID: str | None = None,
- CogPOID: str | None = None,
- **extra_data: Any,
Bases:
BaseModelGeneral device and session metadata extracted from NWB files.
While NWB treats this information as high-level session-specific metadata, BIDS treats these fields as modality specific and as pertaining to ‘parameters’ that can vary.
- This should typically be written to two files, depending on the modality:
_ecephys.json
_icephys.json
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- InstitutionName: str | None#
- InstitutionAddress: str | None#
- InstitutionalDepartmentName: str | None#
- PowerLineFrequency: float | Literal['n/a']#
- Manufacturer: str | None#
- ManufacturersModelName: str | None#
- ManufacturersModelVersion: str | None#
- RecordingSetupName: str | None#
- SamplingFrequency: float#
- DeviceSerialNumber: str | None#
- SoftwareName: str | None#
- SoftwareVersions: str | None#
- RecordingDuration: float | None#
- RecordingType: str | None#
- EpochLength: float | None#
- SoftwareFilters: dict[str, dict[str, Any]] | Literal['n/a']#
- HardwareFilters: dict[str, dict[str, Any]] | Literal['n/a']#
- PharmaceuticalName: str | None#
- PharmaceuticalDoseAmount: float | list[float] | None#
- PharmaceuticalDoseUnits: str | None#
- PharmaceuticalDoseRegimen: str | None#
- PharmaceuticalDoseTime: float | list[float] | None#
- BodyPart: str | None#
- BodyPartDetails: str | None#
- BodyPartDetailsOntology: str | None#
- SampleEnvironment: str | None#
- SampleEmbedding: str | None#
- SliceThickness: int | float | None#
- SampleExtractionProtocol: str | None#
- SupplementarySignals: str | None#
- TaskName: str | None#
- TaskDescription: str | None#
- Instructions: str | None#
- CogAtlasID: str | None#
- CogPOID: str | None#
- model_config = {'extra': 'allow', 'validate_assignment': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class Participant(
- *,
- notifications: list[Notification] = <factory>,
- participant_id: str | None = None,
- species: str | None = None,
- sex: str | None = None,
- strain: str | None = None,
- **extra_data: Any,
Bases:
BaseMetadataModelCreate a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- participant_id: str | None#
- species: str | None#
- sex: str | None#
- strain: str | None#
- classmethod from_nwbfiles(
- nwbfiles: list[Annotated[NWBFile, InstanceOf()]],
Extracts participant metadata from the in-memory NWBFile objects.
- model_config = {'extra': 'allow', 'validate_assignment': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- write_coordsystem_json(
- file_path: str | Path,
- space: Literal['AllenCCFv3', 'PaxinosWatson'],
Write a BIDS coordinate system JSON sidecar file for the given space label.
- Parameters:
file_path (path) – The path to the output *_coordsystem.json file.
space ({“AllenCCFv3”, “PaxinosWatson”}) – The space/atlas label.