Running Focus

scripts/run_focus.jl computes transcranial transmit delays (geometric or HASA) for 2D and 3D domains, optionally verifying focus quality with k-Wave. It supports both water and CT-backed skull media. scripts/compare_focus_estimators.jl runs both estimators side-by-side and writes a comparison figure.

Single Focusing Case

Default skull-backed HASA case:

julia --project=. scripts/run_focus.jl \
  --estimator=hasa \
  --aberrator=skull \
  --slice-index=250

Centered target at 60 mm below the transducer:

julia --project=. scripts/run_focus.jl \
  --dimension=2 \
  --estimator=hasa \
  --aberrator=skull \
  --placement=fixed_transducer \
  --slice-index=250 \
  --focus-mm=60:0

3D water-backed HASA setup dry enough for checking the focusing delays without k-Wave:

julia --project=. scripts/run_focus.jl \
  --dimension=3 \
  --estimator=hasa \
  --aberrator=water \
  --focus-mm=60:0:0 \
  --receiver-aperture-y-mm=60 \
  --receiver-aperture-z-mm=60 \
  --run-kwave=false

3D skull-backed k-Wave outward propagation without inward verification:

julia --project=. scripts/run_focus.jl \
  --dimension=3 \
  --estimator=hasa \
  --aberrator=skull \
  --outward-propagation=kwave \
  --verify-inward-kwave=false \
  --focus-mm=30:0:0 \
  --slice-index=250 \
  --skull-transducer-distance-mm=5 \
  --receiver-aperture-y-mm=20 \
  --receiver-aperture-z-mm=20

Target 30 mm below the inner skull:

julia --project=. scripts/run_focus.jl \
  --dimension=2 \
  --estimator=hasa \
  --aberrator=skull \
  --placement=fixed_focus_depth \
  --slice-index=250 \
  --focus-mm=60:0 \
  --focus-depth-from-inner-skull-mm=30

Compare Estimators

julia --project=. scripts/compare_focus_estimators.jl \
  --medium=skull_in_water \
  --slice-index=250

Main Options

  • --ct-path: DICOM folder for CT-backed skull runs.
  • --slice-index: CT slice used for the 2D focusing medium.
  • --frequency-mhz: transmit frequency.
  • --dimension: 2 or 3.
  • --focus-mm: target coordinates. Use depth:lateral in 2D and depth:y:z in 3D.
  • --receiver-aperture-mm: transducer aperture width. In 3D, --receiver-aperture-y-mm and --receiver-aperture-z-mm override each axis independently.
  • --estimator: geometric or hasa.
  • --aberrator: none, water, or skull.
  • --placement: auto, fixed_transducer, or fixed_focus_depth (2D only).
  • --focus-depth-from-inner-skull-mm: target depth below the inner skull for fixed-depth placement (2D only).
  • --skull-transducer-distance-mm: gap between the outer skull surface and the transducer plane.
  • --outward-propagation: angular_spectrum or kwave.
  • --verify-inward-kwave: set false to skip the return pressure simulation after computing transmit delays.
  • --run-kwave: legacy shorthand; setting it to false also skips inward verification.
  • --kwave-use-gpu: set true to run k-Wave on GPU.
  • --transverse-mm: transverse grid extent (mm). In 3D, --transverse-y-mm and --transverse-z-mm override each axis independently.
  • --dx-mm, --dz-mm: lateral and axial grid spacing. --dy-mm overrides lateral spacing for the y axis in 3D.
  • --axial-mm: axial domain extent; defaults to auto (derived from focus depth and padding).
  • --axial-padding: multiplicative padding applied to the focus depth when computing the axial domain size (default 1.5).
  • --out-dir: override the automatically generated output directory.

scripts/run_focus.jl writes summary.json, result.jld2, and pressure.png. scripts/compare_focus_estimators.jl writes summary.json and comparison.png. Focus runs also write sensor_timings.png, which visualizes the computed transmit delay and normalized amplitude at the active sensor/aperture elements.