Skip to main content

Crate bids

Crate bids 

Source
Expand description

Comprehensive Rust tools for BIDS (Brain Imaging Data Structure) datasets.

This is the umbrella crate that re-exports all bids-* sub-crates, providing a single dependency for full BIDS dataset support. It is the Rust equivalent of the PyBIDS Python package.

§Quick Start

use bids::{BidsLayout, BidsFile};

let layout = BidsLayout::new("/path/to/bids/dataset").unwrap();
let files = layout.get()
    .suffix("bold")
    .extension(".nii.gz")
    .subject("01")
    .collect()
    .unwrap();

for f in &files {
    println!("{}: {:?}", f.filename, f.entities);
}

§Crate Organization

  • Core (core) — Fundamental types: files, entities, metadata, config, errors
  • I/O (io) — TSV/JSON reading, path building, file writing
  • Layout (layout) — Dataset indexing and fluent query API
  • Variables (variables) — BIDS variable system for statistical modeling
  • Modeling (modeling) — BIDS-StatsModels, HRF functions, transformations
  • Reports (reports) — Auto-generated methods sections
  • Domain crates — Modality-specific support (EEG, MEG, PET, etc.)
  • Infrastructure — NIfTI parsing, signal filtering, formula parsing, schema validation

§Feature Flags

FeatureDescription
ndarrayEnable ndarray integration for EEG (Array2) and NIfTI (ArrayD)
safetensorsEnable safetensors export for ML frameworks
mmapEnable memory-mapped NIfTI access via memmap2
arrowEnable Apache Arrow / Parquet export for dataset manifests

Re-exports§

pub use bids_core as core;
pub use bids_io as io;
pub use bids_layout as layout;
pub use bids_variables as variables;
pub use bids_validate as validate;
pub use bids_derive as derive;
pub use bids_modeling as modeling;
pub use bids_reports as reports;
pub use bids_beh as beh;
pub use bids_eeg as eeg;
pub use bids_ieeg as ieeg;
pub use bids_meg as meg;
pub use bids_micr as micr;
pub use bids_motion as motion;
pub use bids_mrs as mrs;
pub use bids_nirs as nirs;
pub use bids_perf as perf;
pub use bids_pet as pet;
pub use bids_dataset as dataset;
pub use bids_filter as filter;
pub use bids_formula as formula;
pub use bids_inflect as inflect;
pub use bids_nifti as nifti;
pub use bids_schema as schema;

Modules§

prelude
Convenience prelude importing the most commonly used types.

Structs§

BidsFile
Represents a single file in a BIDS dataset.
BidsLayout
The main entry point for interacting with a BIDS dataset.
BidsMetadata
Ordered metadata dictionary for a BIDS file.
BidsReport
Generate publication-quality data acquisition methods from a BIDS dataset.
BidsVersion
A parsed BIDS specification version (SemVer).
Config
Configuration for a BIDS layout, defining entities and path patterns.
ContrastInfo
Information about a statistical contrast.
DatasetDescription
Contents of a BIDS dataset_description.json file.
Entity
Represents a single entity defined in configuration.
GradientTable
Combined b-value + b-vector gradient table for a DWI acquisition.
PaddedInt
Integer type that preserves zero-padding.
QueryFilter
A filter for querying files by entity values.
StatsModelsGraph
Rooted directed acyclic graph representing a BIDS-StatsModel specification.

Enums§

BidsError
Errors that can occur when working with BIDS datasets.
Compatibility
Result of checking a dataset’s BIDS version against the library’s supported version.
CopyMode
How to copy a file to a new location.
EntityValue
A typed entity value, preserving the original representation where needed.
HrfModel
Hemodynamic Response Function (HRF) model type.
InvalidFilters
How to handle unrecognized entity names in query filters.
Query
Special query values for entity filtering.
Scope
Scope for queries.

Constants§

MIN_COMPATIBLE_VERSION
The minimum BIDS version that this release can read without data loss.
SUPPORTED_BIDS_VERSION
The BIDS specification version that this release of bids-rs targets.

Traits§

TimeSeries
Trait for read-only access to multichannel time-series data.

Functions§

collect_associated_files
Group BIDSFiles with multiple files per acquisition (multi-echo, multi-part, etc.).
convert_json_keys
Convert CamelCase keys to snake_case recursively in a JSON value.
matches_entities
Check whether a file’s entities match the target entities.

Type Aliases§

Entities
A map from entity names to their typed values for a single file.
Result
A specialized Result type for BIDS operations.
StringEntities
A map from entity names to string values (used in variables/collections).