pub struct SimpleVariable {
pub name: String,
pub source: String,
pub values: Vec<f64>,
pub str_values: Vec<String>,
pub index: Vec<StringEntities>,
pub entities: StringEntities,
pub is_numeric: bool,
}Expand description
A simple variable with no timing information.
Represents a column from a BIDS tabular file such as participants.tsv,
sessions.tsv, or scans.tsv. Each variable has a name, source file
identifier, string values, and an entity index that maps each row to
its BIDS entities (e.g., which subject each value belongs to).
Values are stored as both strings and parsed floats (NaN for non-numeric).
The is_numeric flag indicates whether all values are parseable as f64.
Corresponds to PyBIDS’ SimpleVariable class.
§Example
use bids_variables::SimpleVariable;
use std::collections::HashMap;
let index = vec![
HashMap::from([("subject".into(), "01".into())]),
HashMap::from([("subject".into(), "02".into())]),
];
let var = SimpleVariable::new("age", "participants",
vec!["25".into(), "30".into()], index);
assert_eq!(var.len(), 2);
assert!(var.is_numeric);Fields§
§name: String§source: String§values: Vec<f64>§str_values: Vec<String>§index: Vec<StringEntities>§entities: StringEntities§is_numeric: boolImplementations§
Source§impl SimpleVariable
impl SimpleVariable
pub fn new( name: &str, source: &str, values: Vec<String>, index: Vec<StringEntities>, ) -> Self
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn clone_with(&self, data: Option<Vec<String>>, name: Option<&str>) -> Self
pub fn clone_with(&self, data: Option<Vec<String>>, name: Option<&str>) -> Self
Clone with optional data/name replacement.
Sourcepub fn filter(&self, filters: &StringEntities) -> Self
pub fn filter(&self, filters: &StringEntities) -> Self
Filter rows matching given entity criteria.
Sourcepub fn to_rows(&self) -> Vec<StringEntities> ⓘ
pub fn to_rows(&self) -> Vec<StringEntities> ⓘ
Convert to tabular rows.
Trait Implementations§
Source§impl Clone for SimpleVariable
impl Clone for SimpleVariable
Source§fn clone(&self) -> SimpleVariable
fn clone(&self) -> SimpleVariable
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for SimpleVariable
impl RefUnwindSafe for SimpleVariable
impl Send for SimpleVariable
impl Sync for SimpleVariable
impl Unpin for SimpleVariable
impl UnsafeUnpin for SimpleVariable
impl UnwindSafe for SimpleVariable
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more