1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//! BIDS Statistical Models implementation.
//!
//! This crate implements the [BIDS-StatsModels](https://bids-standard.github.io/stats-models/)
//! specification for defining reproducible neuroimaging analysis pipelines as
//! declarative JSON documents. It corresponds to PyBIDS' `bids.modeling` module.
//!
//! # Overview
//!
//! A BIDS Stats Model defines a directed acyclic graph (DAG) of analysis nodes,
//! each operating at a specific level of the BIDS hierarchy (run, session,
//! subject, dataset). Data flows from lower levels to higher levels through
//! edges, with contrasts propagating upward.
//!
//! # Components
//!
//! - [`StatsModelsGraph`] — The top-level model graph loaded from a JSON file.
//! Validates structure, wires edges between nodes, and executes the full
//! analysis pipeline. Can export to Graphviz DOT format.
//!
//! - [`StatsModelsNode`] — A single analysis node with a statistical model
//! specification, variable transformations, contrasts, and dummy contrasts.
//! Nodes group data by entity values and produce [`StatsModelsNodeOutput`]s.
//!
//! - [`TransformSpec`] and [`apply_transformations()`] — The `pybids-transforms-v1`
//! transformer implementing Rename, Copy, Factor, Scale, Threshold, Select,
//! Delete, Replace, Split, Concatenate, Orthogonalize, Lag, and more.
//!
//! - [`HrfModel`], [`spm_hrf()`], [`glover_hrf()`] — Hemodynamic response function
//! kernels (SPM and Glover canonical forms with optional time and dispersion
//! derivatives). Uses a pure-Rust `gammaln` implementation matching SciPy's
//! cephes to machine epsilon.
//!
//! - [`auto_model()`] — Automatically generates a BIDS Stats Model JSON for
//! each task in a dataset, with Factor(trial_type) at the run level and
//! pass-through nodes at higher levels.
//!
//! - [`GlmSpec`], [`MetaAnalysisSpec`] — Statistical model specifications with
//! design matrix construction, VIF computation, and formatted output.
//!
//! # Example
//!
//! ```no_run
//! use bids_modeling::StatsModelsGraph;
//!
//! let mut graph = StatsModelsGraph::from_file(
//! std::path::Path::new("model-default_smdl.json")
//! ).unwrap();
//! graph.validate().unwrap();
//! println!("DOT graph:\n{}", graph.write_graph());
//!
//! // Execute the model
//! let outputs = graph.run();
//! for output in &outputs {
//! println!("Node: {}, Contrasts: {}", output.node_name, output.contrasts.len());
//! }
//! ```
pub use auto_model;
pub use StatsModelsGraph;
pub use ;
pub use ;
pub use ;
pub use ;