//! # rtx-neuro-pinn //! //! Physics-Informed Neural Networks for MEG/EEG source localization. //! //! This crate provides PINN-based solutions to the MEG/EEG inverse problem, //! using bioelectromagnetic physics constraints to improve source estimation. //! //! ## Key Features //! //! - **Maxwell Residuals**: Quasi-static Maxwell equations for neural currents //! - **Learnable Conductivity**: Joint estimation of tissue conductivity and sources //! - **Physics Constraints**: Divergence-free current enforcement //! - **Multi-Scale**: Handles arbitrary head geometries //! //! ## Physics Model //! //! The quasi-static Maxwell equations for neural currents: //! //! ```text //! ∇·(σ∇Φ) = ∇·Jp //! //! where: //! Φ(r) = electric potential at position r //! σ(r) = tissue conductivity (can be learned) //! Jp(r) = primary current density (neural sources) //! ``` //! //! ## Example //! //! ```ignore //! use rtx_neuro_pinn::{SourcePINN, SourcePINNConfig, HeadModel}; //! //! // Create head model with tissue layers //! let head = HeadModel::spherical(3) //! .with_conductivity("brain", 0.33) //! .with_conductivity("skull", 0.01) //! .with_conductivity("scalp", 0.43); //! //! // Create PINN solver //! let mut pinn = SourcePINN::new(SourcePINNConfig { //! hidden_layers: vec![64, 128, 64], //! learn_conductivity: true, //! ..Default::default() //! })?; //! //! // Train with sensor measurements //! pinn.train(&sensor_data, &head, 1000)?; //! //! // Estimate sources //! let sources = pinn.estimate_sources(&sensor_data)?; //! ``` #![warn(missing_docs)] pub mod conductivity; pub mod error; pub mod head_model; pub mod maxwell; pub mod network; pub mod solver; // Re-export main types pub use conductivity::{ConductivityModel, LearnableConductivity, TissueLayer}; pub use error::{PinnError, PinnResult}; pub use head_model::{HeadGeometry, HeadModel, SensorArray}; pub use maxwell::{CurrentDensity, MaxwellResidual, QuasiStaticMaxwell}; pub use network::{FourierFeatures, SourceNetwork, SourceNetworkConfig}; pub use solver::{SourceEstimate, SourcePINN, SourcePINNConfig, TrainingResult}; #[cfg(test)] mod tests { use super::*; #[test] fn test_basic_head_model() { let head = HeadModel::spherical(3); assert_eq!(head.n_layers(), 3); } #[test] fn test_maxwell_residual() { // Test that residual computation works let residual = QuasiStaticMaxwell::new(0.33); assert!(residual.conductivity() > 0.0); } }