🧠
Neuroimaging
fMRI pipeline analysis with confidence-gated processing and provenance tracking
Neuroimaging with Sounio
Sounio enables reproducible neuroimaging analysis with built-in uncertainty quantification and provenance tracking.
The Reproducibility Challenge
Neuroimaging research faces significant reproducibility issues:
- Pipeline parameters affect results dramatically
- Processing choices are often not documented
- Statistical thresholds vary between studies
- Uncertainty in measurements propagates unpredictably
Sounio’s Solution
use std::neuroimaging::{fMRI, Voxel, BrainRegion}
use std::epistemic::{Knowledge, Provenance}
struct ActivationMap {
voxels: Vec<Knowledge<f64>>,
threshold: f64,
provenance: Provenance,
}
fn analyze_fmri(
scan: fMRI,
pipeline: Pipeline
) -> ActivationMap with IO {
// Each step tracks provenance
let preprocessed = preprocess(scan, pipeline.preproc_params)
let motion_corrected = correct_motion(preprocessed)
let smoothed = spatial_smooth(motion_corrected, pipeline.fwhm)
// GLM with uncertainty propagation
let betas = fit_glm(smoothed, pipeline.design_matrix)
// Confidence-gated thresholding
let significant = betas.filter(|v|
v.value > pipeline.threshold &&
v.confidence > 0.95 // Only include high-confidence activations
)
ActivationMap {
voxels: significant,
threshold: pipeline.threshold,
provenance: betas.provenance, // Full processing history
}
}
Pipeline Provenance
Every analysis step is tracked:
fn preprocess(scan: fMRI, params: PreprocessParams) -> fMRI {
let result = scan
|> slice_timing_correction(params.tr)
|> motion_correction(params.reference)
|> coregistration(params.template)
|> normalization(params.space)
// Provenance automatically includes:
// - Input file checksums
// - Parameter values used
// - Software versions
// - Timestamps
result
}
Confidence-Gated ROI Analysis
fn roi_analysis(
activation: ActivationMap,
atlas: BrainAtlas
) -> Vec<RegionResult> with IO {
var results = vec![]
for region in atlas.regions {
let voxels = activation.voxels_in(region)
let mean_activation = voxels.mean()
if mean_activation.confidence > 0.90 {
results.push(RegionResult {
region: region.name,
activation: mean_activation,
status: "High confidence",
})
} else {
perform IO::warn(
"Low confidence for " + region.name +
" (confidence: " + mean_activation.confidence.to_string() + ")"
)
results.push(RegionResult {
region: region.name,
activation: mean_activation,
status: "Requires validation",
})
}
}
results
}
Multi-Site Studies
fn harmonize_sites(
datasets: Vec<SiteData>
) -> HarmonizedData with IO {
// Track site-specific effects
for site in datasets {
perform IO::log(
"Site: " + site.name +
", Scanner: " + site.scanner_model +
", Subjects: " + site.n_subjects.to_string()
)
}
// ComBat harmonization with uncertainty
let harmonized = combat_harmonize(datasets)
// Verify harmonization quality
if harmonized.site_effect.confidence < 0.80 {
perform IO::warn("Residual site effects may remain")
}
harmonized
}
Features for Neuroimaging
- Full provenance: Every processing step documented
- Uncertainty propagation: From raw signal to final statistics
- Confidence gates: Automatic flagging of uncertain results
- BIDS compatibility: Native support for BIDS format
- Reproducible pipelines: Deterministic processing
BIDS Integration
use std::bids::{BidsDataset, load_participants}
fn main() with IO {
let dataset = BidsDataset::open("./my_study")
for subject in dataset.participants() {
let func = dataset.func(subject, "task-rest")
let anat = dataset.anat(subject, "T1w")
let result = analyze_subject(func, anat)
dataset.write_derivative(subject, result)
}
}
Get Started
sounio new neuro-project --template neuroimaging
cd neuro-project
sounio run examples/fmri_analysis.sio