Skip to main content

StatsModelsGraph

Struct StatsModelsGraph 

Source
pub struct StatsModelsGraph {
    pub name: String,
    pub description: String,
    pub nodes: Vec<StatsModelsNode>,
    pub edges: Vec<StatsModelsEdge>,
    /* private fields */
}
Expand description

Rooted directed acyclic graph representing a BIDS-StatsModel specification.

A StatsModelsGraph is loaded from a JSON file conforming to the BIDS-StatsModels specification. It contains analysis nodes at different levels of the BIDS hierarchy (run, session, subject, dataset) connected by edges that define how contrasts and data flow between levels.

§Lifecycle

  1. Load — Parse from JSON file or value via from_file() or from_json()
  2. Validate — Check structure via validate()
  3. Load data — Populate nodes with variables from a layout via load_collections()
  4. Execute — Run the analysis pipeline via run()
  5. Export — Generate DOT graph via write_graph()

Corresponds to PyBIDS’ StatsModelsGraph class.

Fields§

§name: String§description: String§nodes: Vec<StatsModelsNode>§edges: Vec<StatsModelsEdge>

Implementations§

Source§

impl StatsModelsGraph

Source

pub fn from_json(model_json: &Value) -> Result<Self>

Load from a JSON model spec (path or parsed value).

Source

pub fn from_file(path: &Path) -> Result<Self>

Load from a file path.

Source

pub fn validate(&self) -> Result<()>

Validate the model structure.

Source

pub fn get_node(&self, name: &str) -> Option<&StatsModelsNode>

Get a node by name.

Source

pub fn root_node(&self) -> &StatsModelsNode

Get the root node.

Source

pub fn load_collections(&mut self, layout: &BidsLayout)

Load collections from a layout into all nodes.

Source

pub fn write_graph(&self) -> String

Write graph structure as a DOT file (text-based graphviz).

Source

pub fn render_graph(&self, output_path: &Path, format: &str) -> Result<()>

Render graph to a file using the dot command (requires graphviz installed).

Source

pub fn run(&self) -> Vec<StatsModelsNodeOutput>

Run the entire graph recursively.

Trait Implementations§

Source§

impl Debug for StatsModelsGraph

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.