pub struct Config {
pub name: String,
pub entities: Vec<Entity>,
pub default_path_patterns: Option<Vec<String>>,
}Expand description
Configuration for a BIDS layout, defining entities and path patterns.
Corresponds to PyBIDS’ Config class. Can be loaded from JSON config files
(like bids.json) or constructed programmatically.
§Example
use bids_core::Config;
let config = Config::bids();
assert_eq!(config.name, "bids");
assert!(config.entity_count() > 20);
assert!(config.get_entity("subject").is_some());Fields§
§name: String§entities: Vec<Entity>§default_path_patterns: Option<Vec<String>>Implementations§
Source§impl Config
impl Config
Sourcepub fn from_file(path: &Path) -> Result<Self>
pub fn from_file(path: &Path) -> Result<Self>
Load a config from a JSON file.
§Errors
Returns an error if the file cannot be read or contains invalid JSON.
Sourcepub fn bids() -> Self
pub fn bids() -> Self
Load the built-in BIDS config.
§Panics
Panics if the embedded bids.json is malformed (should never happen).
Sourcepub fn derivatives() -> Self
pub fn derivatives() -> Self
Load the built-in derivatives config.
§Panics
Panics if the embedded derivatives.json is malformed (should never happen).
Sourcepub fn load(name_or_path: &str) -> Result<Self>
pub fn load(name_or_path: &str) -> Result<Self>
Load a named config ("bids", "derivatives") or from a file path.
§Errors
Returns an error if the name is unrecognized and the path doesn’t exist or contains invalid JSON.
Sourcepub fn entities_mut(&mut self) -> &mut Vec<Entity>
pub fn entities_mut(&mut self) -> &mut Vec<Entity>
Get mutable references to all entity definitions.
Sourcepub fn get_entity(&self, name: &str) -> Option<&Entity>
pub fn get_entity(&self, name: &str) -> Option<&Entity>
Look up an entity definition by name.
Sourcepub fn entity_count(&self) -> usize
pub fn entity_count(&self) -> usize
Returns the number of entity definitions in this config.