brain_deer.infrastructure.bids.entities

BIDS filename parsing and lightweight item records.

Classes

BIDSItem

One indexed file in a BIDS dataset (metadata only until loaded).

Functions

split_bids_extension(→ tuple[str, str])

Return (stem, extension) handling .nii.gz.

parse_bids_filename(→ tuple[dict[str, str], str, str])

Parse a BIDS-style basename into entities, suffix, and extension.

infer_datatype(→ str)

Infer BIDS datatype folder from a file path.

item_from_path(→ Optional[BIDSItem])

Build a BIDSItem from an on-disk path, or None if not BIDS-like.

role_key_for_entities(→ str)

Stable layer identity across subjects: entities except sub, plus suffix.

role_key_for_item(→ str)

Role key for a BIDSItem (subject-independent).

role_key_from_bids_meta(→ str)

Recover a role key from a layer's info['bids'] metadata.

display_name_for_item(→ str)

Human-readable layer name for the Files tab (role-stable, no sub-).

Module Contents

class brain_deer.infrastructure.bids.entities.BIDSItem

One indexed file in a BIDS dataset (metadata only until loaded).

brain_deer.infrastructure.bids.entities.split_bids_extension(filename: str) → tuple[str, str]

Return (stem, extension) handling .nii.gz.

brain_deer.infrastructure.bids.entities.parse_bids_filename(filename: str) → tuple[dict[str, str], str, str]

Parse a BIDS-style basename into entities, suffix, and extension.

brain_deer.infrastructure.bids.entities.infer_datatype(path: pathlib.Path, dataset_root: pathlib.Path) → str

Infer BIDS datatype folder from a file path.

brain_deer.infrastructure.bids.entities.item_from_path(path: pathlib.Path, dataset_root: pathlib.Path) → BIDSItem | None

Build a BIDSItem from an on-disk path, or None if not BIDS-like.

brain_deer.infrastructure.bids.entities.role_key_for_entities(entities: dict[str, str], suffix: str, *, kind: str = '') → str

Stable layer identity across subjects: entities except sub, plus suffix.

Used as loaded_files keys for BIDS layers so subject switches can hot-swap payloads without tearing down scene settings (opacity, colormap, projections, …).

brain_deer.infrastructure.bids.entities.role_key_for_item(item: BIDSItem) → str

Role key for a BIDSItem (subject-independent).

brain_deer.infrastructure.bids.entities.role_key_from_bids_meta(bids: dict) → str

Recover a role key from a layer’s info['bids'] metadata.

brain_deer.infrastructure.bids.entities.display_name_for_item(item: BIDSItem) → str

Human-readable layer name for the Files tab (role-stable, no sub-).

Subject identity lives in bids metadata and the BIDS panel — not in the layer key — so switching subjects can reuse the same row.