88 lines
3.0 KiB
Rust
88 lines
3.0 KiB
Rust
//! FreeSurfer anatomy file reading for brain surface visualization
|
|
//!
|
|
//! This crate provides readers for FreeSurfer subject anatomy files:
|
|
//! - Surface meshes (.pial, .white, .inflated, .sphere, .orig)
|
|
//! - Annotation/parcellation labels (.annot files)
|
|
//! - Curvature data (.curv, .sulc, .thickness)
|
|
//!
|
|
//! # Example
|
|
//!
|
|
//! ```ignore
|
|
//! use rtx_neuro_anatomy::{FreeSurferSubject, Hemisphere, SurfaceType};
|
|
//!
|
|
//! // Open a FreeSurfer subject directory
|
|
//! let mut subject = FreeSurferSubject::open("/path/to/subject")?;
|
|
//!
|
|
//! // Load the left pial surface
|
|
//! let pial = subject.load_surface(Hemisphere::Left, SurfaceType::Pial)?;
|
|
//! println!("Loaded {} vertices, {} faces", pial.n_vertices(), pial.n_faces());
|
|
//!
|
|
//! // Load parcellation labels
|
|
//! let aparc = subject.load_annotation(Hemisphere::Left, "aparc")?;
|
|
//! println!("Loaded {} regions", aparc.color_table.n_regions());
|
|
//!
|
|
//! // Load curvature for coloring
|
|
//! let curv = subject.load_curvature(Hemisphere::Left, "curv")?;
|
|
//! println!("Curvature range: {:?}", curv.range());
|
|
//! ```
|
|
//!
|
|
//! # FreeSurfer Directory Structure
|
|
//!
|
|
//! ```text
|
|
//! subject/
|
|
//! ├── surf/
|
|
//! │ ├── lh.pial # Left pial surface
|
|
//! │ ├── rh.pial # Right pial surface
|
|
//! │ ├── lh.white # Left white matter surface
|
|
//! │ ├── rh.white # Right white matter surface
|
|
//! │ ├── lh.inflated # Left inflated surface
|
|
//! │ ├── rh.inflated # Right inflated surface
|
|
//! │ ├── lh.curv # Left curvature
|
|
//! │ ├── rh.curv # Right curvature
|
|
//! │ ├── lh.sulc # Left sulcal depth
|
|
//! │ └── rh.sulc # Right sulcal depth
|
|
//! ├── label/
|
|
//! │ ├── lh.aparc.annot # Left Desikan-Killiany atlas
|
|
//! │ ├── rh.aparc.annot # Right Desikan-Killiany atlas
|
|
//! │ ├── lh.aparc.a2009s.annot # Left Destrieux atlas
|
|
//! │ └── rh.aparc.a2009s.annot # Right Destrieux atlas
|
|
//! └── mri/
|
|
//! └── ... # MRI volumes (not yet supported)
|
|
//! ```
|
|
|
|
#![warn(missing_docs)]
|
|
|
|
pub mod annotation;
|
|
pub mod curvature;
|
|
pub mod error;
|
|
pub mod subject;
|
|
pub mod surface;
|
|
|
|
// Re-export main types for convenience
|
|
pub use annotation::{Annotation, AnnotationEntry, ColorTable};
|
|
pub use curvature::Curvature;
|
|
pub use error::{AnatomyError, Result};
|
|
pub use subject::{FreeSurferHandle, FreeSurferSubject};
|
|
pub use surface::{Hemisphere, SurfaceMesh, SurfaceType};
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn test_hemisphere_prefix() {
|
|
assert_eq!(Hemisphere::Left.prefix(), "lh");
|
|
assert_eq!(Hemisphere::Right.prefix(), "rh");
|
|
}
|
|
|
|
#[test]
|
|
fn test_surface_type_filename() {
|
|
assert_eq!(SurfaceType::Pial.filename(&Hemisphere::Left), "lh.pial");
|
|
assert_eq!(SurfaceType::White.filename(&Hemisphere::Right), "rh.white");
|
|
assert_eq!(
|
|
SurfaceType::Inflated.filename(&Hemisphere::Left),
|
|
"lh.inflated"
|
|
);
|
|
}
|
|
}
|