Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Example: Transcranial FWI

Crate: kwavers
Run: cargo run -p kwavers --example transcranial_fwi
Source: crates/kwavers/examples/transcranial_fwi.rs

What This Example Demonstrates

This example demonstrates adjoint-state full-wave inversion for transcranial ultrasound. Its input is explicit: KWAVERS_SEISMIC_INPUT_MODE=synthetic selects the self-contained skull phantom, while ct:<path> selects a real CT NIfTI volume. A CT read failure is returned as an input error rather than silently switching models.

ComponentAPIValue
DomainDX, NX, NY, NZDefines a 64×2×64 coronal head cross-section at 3 mm spacing
Skull phantomseismic_imaging::medium::SkullModelRoutes layered synthetic or explicit CT intensities through the validated provider-owned Hill model
SourceDomainRickerWaveletStreams causal pressure samples from Aequitas-typed frequency, time, and pressure
FWI loopforward FDTD → residual → adjoint → gradient updateImplements the standard adjoint-state inversion workflow

Key Code Snippet

const DX: f64 = 3.0e-3;
/// Grid dimensions (2-D coronal slice embedded in 3-D; ny=2 satisfies FDTD
/// staggered-stencil minimum while keeping the second y-plane acoustically
/// transparent — identical medium properties are assigned to both planes).
const NX: usize = 64;
const NY: usize = 2;
const NZ: usize = 64;

/// Skull phantom geometry — all radii in voxels from grid centre (32, 0, 32).
///

Expected Output (if applicable)

The run prints provider-derived HU and sound-speed ranges plus inversion summaries to stdout. No dataset is downloaded and no file is generated implicitly.

Book Chapter

← Transcranial Ultrasound: Physics, Aberration Correction, and Therapy