bidsschematools.types.protocols

BIDS validation context definitions

The classes in this module are used to define the context for BIDS validation. The context is a namespace that contains relevant information about the dataset as a whole and an individual file to be validated.

These classes are used to define the structure of the context, but they cannot be instantiated directly. Conforming subtypes need only match the structure of these classes, and do not need to inherit from them. It is recommended to import this module in an if TYPE_CHECKING block to avoid import costs.

The classes use @property decorators to indicate that subtypes need only provide read access to the attributes, and may restrict writing, for example, when calculating attributes dynamically based on other attributes.

Note that some type checkers will not match classes that use functools.cached_property. To permit this, add the following to your module:

if TYPE_CHECKING:
    cached_property = property
else:
    from functools import cached_property

This module has been auto-generated from the BIDS schema version 1.2.0-dev.

Classes

class bidsschematools.types.protocols.Aslcontext(*args, **kwargs)

Bases: Protocol

ASL context file

property n_rows: int

Number of rows in aslcontext.tsv

property path: str

Path to associated aslcontext file

property volume_type: Sequence[str] | None

Contents of the volume_type column

class bidsschematools.types.protocols.Associations(*args, **kwargs)

Bases: Protocol

Associated files, indexed by suffix, selected according to the inheritance principle

property aslcontext: Aslcontext | None

ASL context file

property bval: Bval | None

B value file

property bvec: Bvec | None

B vector file

property channels: Channels | None

Channels file

property coordsystem: Coordsystem | None

Coordinate system file

property electrodes: Electrodes | None

Electrodes file

property events: Events | None

Events file

property m0scan: M0scan | None

M0 scan file

property magnitude: Magnitude | None

Magnitude image file

property magnitude1: Magnitude1 | None

Magnitude1 image file

class bidsschematools.types.protocols.Bval(*args, **kwargs)

Bases: Protocol

B value file

property n_cols: int

Number of columns in bval file

property n_rows: int

Number of rows in bval file

property path: str

Path to associated bval file

property values: Sequence[float]

B-values contained in bval file

class bidsschematools.types.protocols.Bvec(*args, **kwargs)

Bases: Protocol

B vector file

property n_cols: int

Number of columns in bvec file

property n_rows: int

Number of rows in bvec file

property path: str

Path to associated bvec file

class bidsschematools.types.protocols.Channels(*args, **kwargs)

Bases: Protocol

Channels file

property path: str

Path to associated channels file

property sampling_frequency: Sequence[str] | None

Contents of the sampling_frequency column

property short_channel: Sequence[str] | None

Contents of the short_channel column

property type: Sequence[str] | None

Contents of the type column

class bidsschematools.types.protocols.Context(*args, **kwargs)

Bases: Protocol

property associations: Associations

Associated files, indexed by suffix, selected according to the inheritance principle

property columns: Mapping[str, Any] | None

TSV columns, indexed by column header, values are arrays with column contents

property dataset: Dataset

Properties and contents of the entire dataset

property datatype: str | None

Datatype of current file, for examples, anat

property entities: Mapping[str, Any] | None

Entities parsed from the current filename

property extension: str | None

Extension of current file including initial dot

property gzip: Gzip | None

Parsed contents of gzip header

property json: Mapping[str, Any] | None

Contents of the current JSON file

property modality: str | None

Modality of current file, for examples, MRI

property nifti_header: NiftiHeader | None

Parsed contents of NIfTI header referenced elsewhere in schema.

property ome: Ome | None

Parsed contents of OME-XML header, which may be found in OME-TIFF or OME-ZARR files

property path: str

Path of the current file

property schema: Mapping[str, Any]

The BIDS specification schema

property sidecar: Mapping[str, Any]

Sidecar metadata constructed via the inheritance principle

property size: int

Length of the current file in bytes

property subject: Subject | None

Properties and contents of the current subject

property suffix: str | None

Suffix of current file

property tiff: Tiff | None

TIFF file format metadata

class bidsschematools.types.protocols.Coordsystem(*args, **kwargs)

Bases: Protocol

Coordinate system file

property path: str

Path to associated coordsystem file

class bidsschematools.types.protocols.Dataset(*args, **kwargs)

Bases: Protocol

Properties and contents of the entire dataset

property dataset_description: Mapping[str, Any]

Contents of /dataset_description.json

property datatypes: Sequence[str]

Data types present in the dataset

property ignored: Sequence[str]

Set of ignored files

property modalities: Sequence[str]

Modalities present in the dataset

property subjects: Subjects

Collections of subjects in dataset

property tree: Mapping[str, Any]

Tree view of all files in dataset

class bidsschematools.types.protocols.DimInfo(*args, **kwargs)

Bases: Protocol

Metadata about dimensions data.

property freq: int

These fields encode which spatial dimension (1, 2, or 3).

property phase: int

Corresponds to which acquisition dimension for MRI data.

property slice: int

Slice dimensions.

class bidsschematools.types.protocols.Electrodes(*args, **kwargs)

Bases: Protocol

Electrodes file

property path: str

Path to associated electrodes.tsv file

class bidsschematools.types.protocols.Events(*args, **kwargs)

Bases: Protocol

Events file

property onset: Sequence[str] | None

Contents of the onset column

property path: str

Path to associated events file

class bidsschematools.types.protocols.Gzip(*args, **kwargs)

Bases: Protocol

Parsed contents of gzip header

property comment: str | None

Comment

property filename: str | None

Filename

property timestamp: float

Modification time, unix timestamp

class bidsschematools.types.protocols.M0scan(*args, **kwargs)

Bases: Protocol

M0 scan file

property path: str

Path to associated M0 scan file

class bidsschematools.types.protocols.Magnitude(*args, **kwargs)

Bases: Protocol

Magnitude image file

property path: str

Path to associated magnitude file

class bidsschematools.types.protocols.Magnitude1(*args, **kwargs)

Bases: Protocol

Magnitude1 image file

property path: str

Path to associated magnitude1 file

class bidsschematools.types.protocols.NiftiHeader(*args, **kwargs)

Bases: Protocol

Parsed contents of NIfTI header referenced elsewhere in schema.

property axis_codes: Sequence[Literal['R', 'L', 'A', 'P', 'S', 'I']]

Orientation labels indicating primary direction of data axes defined with respect to the object of interest.

property dim: Sequence[int]

Data seq dimensions.

property dim_info: DimInfo

Metadata about dimensions data.

property mrs: Mapping[str, Any] | None

NIfTI-MRS JSON fields

property pixdim: Sequence[float]

Grid spacings (unit per dimension).

property qform_code: int

Use of the quaternion fields.

property sform_code: int

Use of the affine fields.

property shape: Sequence[int]

dim[0] + 1]

Type:

Data array shape, equal to dim[1

property voxel_sizes: Sequence[float]

dim[0] + 1]

Type:

Voxel sizes, equal to pixdim[1

property xyzt_units: XyztUnits

Units of pixdim[1..4]

class bidsschematools.types.protocols.Ome(*args, **kwargs)

Bases: Protocol

Parsed contents of OME-XML header, which may be found in OME-TIFF or OME-ZARR files

property PhysicalSizeX: float | None

Pixels / @PhysicalSizeX

property PhysicalSizeXUnit: str | None

Pixels / @PhysicalSizeXUnit

property PhysicalSizeY: float | None

Pixels / @PhysicalSizeY

property PhysicalSizeYUnit: str | None

Pixels / @PhysicalSizeYUnit

property PhysicalSizeZ: float | None

Pixels / @PhysicalSizeZ

property PhysicalSizeZUnit: str | None

Pixels / @PhysicalSizeZUnit

class bidsschematools.types.protocols.Sessions(*args, **kwargs)

Bases: Protocol

Collections of sessions in subject

property ses_dirs: Sequence[str]

Sessions as determined by ses-* directories

property session_id: Sequence[str] | None

The session_id column of sessions.tsv

class bidsschematools.types.protocols.Subject(*args, **kwargs)

Bases: Protocol

Properties and contents of the current subject

property sessions: Sessions

Collections of sessions in subject

class bidsschematools.types.protocols.Subjects(*args, **kwargs)

Bases: Protocol

Collections of subjects in dataset

property participant_id: Sequence[str] | None

The participant_id column of participants.tsv

property sub_dirs: Sequence[str]

Subjects as determined by sub-* directories

class bidsschematools.types.protocols.Tiff(*args, **kwargs)

Bases: Protocol

TIFF file format metadata

property version: int

TIFF file format version (the second 2-byte block)

class bidsschematools.types.protocols.XyztUnits(*args, **kwargs)

Bases: Protocol

Units of pixdim[1..4]

property t: Literal['unknown', 'sec', 'msec', 'usec']

String representing the unit of inter-volume intervals.

property xyz: Literal['unknown', 'meter', 'mm', 'um']

String representing the unit of voxel spacing.