Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
6ebee2c
Improve documentation with pedagogical approach
waltsims Aug 3, 2025
9596dde
Fix index
waltsims Aug 3, 2025
d577c30
Fix links
waltsims Aug 3, 2025
0465ec9
use :ghfile:
waltsims Aug 3, 2025
888a3c4
fix links
waltsims Aug 3, 2025
bfd555c
Restructure
waltsims Aug 3, 2025
494fc8c
update index
waltsims Aug 3, 2025
41458cf
Fix badge
waltsims Aug 4, 2025
7176f82
Merge branch 'master' into feature/improve-documentation-pedagogical
waltsims Aug 4, 2025
2925e9d
fix link
waltsims Aug 4, 2025
068ef86
ignore license links
waltsims Aug 4, 2025
6e4011a
try again
waltsims Aug 4, 2025
2678a35
3rd time
waltsims Aug 4, 2025
08d5daa
Update README.md
djps Sep 11, 2025
cffd5be
Update link-check.yml - explicitly exclude problematic link
djps Sep 11, 2025
2e3b3d1
📝 Add docstrings to `feature/improve-documentation-pedagogical` (#638)
coderabbitai[bot] Sep 11, 2025
3aa3410
Apply suggestion from @coderabbitai[bot]
waltsims Sep 11, 2025
1b96388
Apply suggestion from @coderabbitai[bot]
waltsims Sep 11, 2025
1e4fe0d
Apply suggestion from @coderabbitai[bot]
waltsims Sep 11, 2025
dfa441f
Apply suggestion from @coderabbitai[bot]
waltsims Sep 11, 2025
7eb14fa
simplify conf.py
waltsims Sep 11, 2025
7cab8d4
Fix docs formatting
waltsims Sep 11, 2025
c13eb82
remove refferences to gpuArray
waltsims Sep 11, 2025
5af3ee8
Make links more robust.
waltsims Sep 11, 2025
bfd69dd
clean docs
waltsims Sep 11, 2025
8fb9ad0
fix char
waltsims Sep 11, 2025
9ebbfd2
update uv lock
waltsims Sep 11, 2025
9f979de
Merge branch 'master' into feature/improve-documentation-pedagogical
waltsims Sep 11, 2025
3bae077
fix docs
waltsims Sep 11, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/link-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Markdown Link Validator

on:
pull_request:
push:
branches: [ main, master ]

jobs:
linkChecker:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Check links with lychee
# See https://github.com/lycheeverse/lychee-action
uses: lycheeverse/lychee-action@v2
with:
# Check all markdown and reStructuredText files
args: >-
--verbose
--no-progress
--max-concurrency 12
--max-retries 3
--retry-wait-time 4
--accept 200,206,403,429
--exclude-path "docs/get_started/legacy_licenses/gpl-3.0.rst"
"**/*.md" "**/*.rst"
# Fail the build on any broken link
fail: true
env:
# Exclude localhost and badges
LY_CHEE_EXCLUDE: "http://localhost,https://localhost,https://127.0.0.1,https://img.shields.io"
6 changes: 3 additions & 3 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# k-Wave-python
# k-wave-python

[![Support](https://dcbadge.vercel.app/api/server/Yq5Qj6D9vN?style=flat)](https://discord.gg/Yq5Qj6D9vN)
[![Support](https://img.shields.io/discord/1234942672418897960?style=flat&logo=discord)](https://discord.gg/your-invite-code)
[![Documentation Status](https://readthedocs.org/projects/k-wave-python/badge/?version=latest)](https://k-wave-python.readthedocs.io/en/latest/?badge=latest)
[![codecov](https://codecov.io/gh/waltsims/k-wave-python/graph/badge.svg?token=6ofwtPiDNG)](https://codecov.io/gh/waltsims/k-wave-python)
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/waltsims/k-wave-python/master)
Expand All @@ -19,7 +19,7 @@ to leverage pythonic practices.

![](_static/example_bmode.png)

A large [collection of examples](../examples/) exists to get started with k-wave-python. All examples can be run in Google Colab notebooks with a few clicks. One can begin with e.g. the [B-mode reconstruction example notebook](https://colab.research.google.com/github/waltsims/k-wave-python/blob/master/examples/us_bmode_linear_transducer/us_bmode_linear_transducer.ipynb).
A large [collection of examples](../examples/) exists to get started with k-wave-python. All examples can be run in Google Colab notebooks with a few clicks. One can begin with e.g. the [B-mode reconstruction example notebook](https://colab.research.google.com/github/waltsims/k-wave-python/blob/HEAD/examples/us_bmode_linear_transducer/us_bmode_linear_transducer.ipynb).

This example file steps through the process of:
1. Generating a simulation medium
Expand Down
41 changes: 40 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,46 @@
"sphinx.ext.napoleon",
"sphinx.ext.viewcode",
"sphinx_mdinclude",
"sphinx.ext.extlinks", # Enables :ghfile: external links
]

# Provide a simple GitHub branch/sha fallback for linking to example files.
# Priority: explicit override via _GITHUB_BRANCH →
# READTHEDOCS_GIT_IDENTIFIER (commit) →
# READTHEDOCS_GIT_BRANCH / GITHUB_REF_NAME →
# "master".
import os


def _detect_current_branch() -> str:
"""Return a branch/commit identifier for GitHub links with minimal logic.

Order: _GITHUB_BRANCH override → READTHEDOCS_GIT_IDENTIFIER (commit) →
READTHEDOCS_GIT_BRANCH / GITHUB_REF_NAME → "master".
"""
return (
os.getenv("_GITHUB_BRANCH")
or os.getenv("READTHEDOCS_GIT_IDENTIFIER")
or os.getenv("READTHEDOCS_GIT_BRANCH")
or os.getenv("GITHUB_REF_NAME")
or "master"
)


_GITHUB_BRANCH = _detect_current_branch()

# Define an extlink so we can write :ghfile:`examples/foo.py` in .rst/.md
extlinks = {
"ghfile": (
f"https://github.com/waltsims/k-wave-python/blob/{_GITHUB_BRANCH}/%s",
"%s", # pass-through caption
),
"ghdir": (
f"https://github.com/waltsims/k-wave-python/tree/{_GITHUB_BRANCH}/%s",
"%s",
),
}

source_suffix = [".rst", ".md"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Either add MyST or drop “.md” from source_suffix; otherwise builds will error.
Without a Markdown parser, Sphinx can’t parse .md top-level sources.

Minimal fix (preferred):

 extensions = [
@@
-    "sphinx.ext.extlinks",  # Enables :ghfile: external links
+    "sphinx.ext.extlinks",  # Enables :ghfile: external links
+    "myst_parser",          # Enables Markdown sources
 ]
@@
-source_suffix = [".rst", ".md"]
+source_suffix = {".rst": "restructuredtext", ".md": "markdown"}

Quick check script:


🏁 Script executed:

#!/bin/bash
# List .md sources that would require a Markdown parser
fd -e md docs -H | rg -v '/README\.md$' || true
# Verify myst_parser is enabled and dependency present
rg -n 'myst_parser' docs/conf.py || echo "myst_parser not found in conf.py"
fd -H 'requirements*' docs | xargs -I{} sh -c 'echo "== {} =="; rg -n "myst-?parser" {} || true'

Length of output: 32


Enable Markdown parsing (myst_parser) or remove ".md" from source_suffix

docs/conf.py currently lists ".md" as a top-level source but myst_parser is not enabled (myst_parser not found in conf.py); Sphinx will fail to build. Apply one of the fixes below.

 extensions = [
@@
-    "sphinx.ext.extlinks",  # Enables :ghfile: external links
+    "sphinx.ext.extlinks",  # Enables :ghfile: external links
+    "myst_parser",          # Enables Markdown sources
 ]
@@
-source_suffix = [".rst", ".md"]
+source_suffix = {".rst": "restructuredtext", ".md": "markdown"}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
source_suffix = [".rst", ".md"]
extensions = [
"sphinx.ext.extlinks", # Enables :ghfile: external links
"myst_parser", # Enables Markdown sources
]
source_suffix = {".rst": "restructuredtext", ".md": "markdown"}
🤖 Prompt for AI Agents
In docs/conf.py around line 73, source_suffix includes ".md" but myst_parser is
not enabled; either add "myst_parser" to the Sphinx extensions list (e.g., add
'myst_parser' to the extensions variable and ensure myst-parser is installed in
the environment) so Sphinx can parse Markdown, or remove ".md" from
source_suffix to only allow supported formats (e.g., change source_suffix to
[".rst"]). Ensure you pick one of these two fixes and update the file
accordingly.

templates_path = ["_templates"]
exclude_patterns = ["README.md", "_build", "Thumbs.db", ".DS_Store"]
Expand All @@ -36,9 +74,10 @@
html_theme = "furo"
html_theme_options = {
"source_repository": "https://github.com/waltsims/k-wave-python",
"source_branch": "master",
"source_branch": _GITHUB_BRANCH,
"source_directory": "docs/",
}

html_static_path = ["_static"]

# -- Options for todo extension ----------------------------------------------
Expand Down
179 changes: 179 additions & 0 deletions docs/examples_guide.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
Examples: k-Wave-Python Step-by-Step
=======================

The k-Wave Python examples are organized to help you progress from basic wave physics to advanced applications. Each example demonstrates the four-component framework (Grid, Medium, Source, Sensor) with increasing complexity.

Start with the :doc:`get_started/first_simulation` tutorial, then follow this suggested learning path:

Basic Wave Propagation (IVP - Initial Value Problems)
-----------------------------------------------------

**Start Here**: Learn fundamental wave physics using initial pressure distributions (the simplest source type).

.. list-table::
:header-rows: 1
:widths: 40 40 20

* - Example
- Core Concept
- Topics
* - :ghdir:`examples/ivp_photoacoustic_waveforms/`
- 2D vs 3D wave propagation physics
- **IVP** • Wave spreading • Compact support

Simple Transducers & Sources
-----------------------------

**Next Step**: Introduction to time-varying sources and practical transducer modeling.

.. list-table::
:header-rows: 1
:widths: 40 40 20

* - Example
- Core Concept
- Topics
* - :ghdir:`examples/us_defining_transducer/`
- Basic ultrasound transducer setup
- **US** • Transducer basics • Time-varying sources
* - :ghdir:`examples/at_circular_piston_3D/`
- Simple focused geometry
- **AT** • 3D focusing • Geometric sources
* - :ghdir:`examples/at_circular_piston_AS/`
- Computational efficiency with symmetry
- **AT** • Axisymmetric • Computational optimization

Medical Imaging Applications
----------------------------

**Practical Applications**: See how basic concepts combine into real-world medical imaging systems.

.. list-table::
:header-rows: 1
:widths: 40 40 20

* - Example
- Application
- Topics
* - :ghdir:`examples/us_beam_patterns/`
- Understanding acoustic beam formation
- **US** • Beam focusing • Field patterns
* - :ghdir:`examples/us_bmode_linear_transducer/`
- Complete ultrasound imaging pipeline
- **US** • Medical imaging • Signal processing
* - :ghdir:`examples/pr_2D_FFT_line_sensor/`
- Photoacoustic image reconstruction
- **PR** • Image reconstruction • FFT methods
* - :ghdir:`examples/pr_2D_TR_line_sensor/`
- Alternative reconstruction approach
- **PR** • Time reversal • Reconstruction

Advanced Transducer Modeling (AT - Array Transducers)
-----------------------------------------------------

**Complex Geometries**: Learn sophisticated techniques for modeling complex transducer arrays using Cartesian space methods.

.. list-table::
:header-rows: 1
:widths: 40 40 20

* - Example
- Advanced Technique
- Topics
* - :ghdir:`examples/at_array_as_source/`
- kWaveArray for complex geometries
- **AT** • Array modeling • Anti-aliasing
* - :ghdir:`examples/at_array_as_sensor/`
- Complex sensor array geometries
- **AT** • Sensor arrays • Flexible positioning
* - :ghdir:`examples/at_linear_array_transducer/`
- Multi-element linear arrays
- **AT** • Linear arrays • Element spacing
* - :ghdir:`examples/at_focused_bowl_3D/`
- 3D focused ultrasound therapy
- **AT** • Therapeutic US • 3D focusing
* - :ghdir:`examples/at_focused_annular_array_3D/`
- Multi-element focused systems
- **AT** • Annular arrays • Complex focusing

Advanced Imaging & Reconstruction (PR - Pressure/Photoacoustic Reconstruction)
-------------------------------------------------------------------------------

**3D Reconstruction**: Advanced reconstruction techniques for photoacoustic and pressure field imaging.

.. list-table::
:header-rows: 1
:widths: 40 40 20

* - Example
- Reconstruction Method
- Topics
* - :ghdir:`examples/pr_3D_FFT_planar_sensor/`
- 3D FFT-based reconstruction
- **PR** • 3D imaging • Planar arrays
* - :ghdir:`examples/pr_3D_TR_planar_sensor/`
- 3D time reversal reconstruction
- **PR** • 3D time reversal • Volumetric imaging
* - :ghdir:`examples/us_bmode_phased_array/`
- Advanced ultrasound beamforming
- **US** • Phased arrays • Electronic steering

Sensor Physics & Directivity (SD - Sensor Directivity)
------------------------------------------------------

**Sensor Modeling**: Understanding how sensor size, shape, and directivity affect measurements.

.. list-table::
:header-rows: 1
:widths: 40 40 20

* - Example
- Physics Concept
- Topics
* - :ghdir:`examples/sd_directivity_modelling_2D/`
- How sensor size affects measurements
- **SD** • Directivity • Finite sensor size
* - :ghdir:`examples/sd_focussed_detector_2D/`
- Directional sensor sensitivity
- **SD** • Focused detection • Sensor design
* - :ghdir:`examples/sd_focussed_detector_3D/`
- 3D focused sensor modeling
- **SD** • 3D detection • Sensor focusing

Computational Optimization (NA - Numerical Analysis)
----------------------------------------------------

**Advanced Numerics**: Optimize simulations and understand computational aspects.

.. list-table::
:header-rows: 1
:widths: 40 40 20

* - Example
- Optimization Topic
- Topics
* - :ghdir:`examples/na_controlling_the_pml/`
- Boundary conditions and efficiency
- **NA** • PML boundaries • Computational domains

Understanding the Prefixes
--------------------------

- **IVP** = Initial Value Problems (wave propagation from initial pressure)
- **US** = Ultrasound (medical and therapeutic ultrasound applications)
- **AT** = Array Transducers (complex geometries using Cartesian space methods)
- **PR** = Pressure/Photoacoustic Reconstruction (image reconstruction techniques)
- **SD** = Sensor Directivity (sensor physics and measurement effects)
- **NA** = Numerical Analysis (computational optimization and methods)

Learning Strategy
-----------------

1. **Start with IVP**: Understand basic wave physics
2. **Move to simple US/AT**: Learn transducer basics
3. **Apply to imaging**: See concepts in real applications (US, PR)
4. **Master advanced AT**: Handle complex geometries
5. **Understand sensors**: Learn about measurement physics (SD)
6. **Optimize**: Improve computational efficiency (NA)

Each example builds on the four-component framework, but with increasing sophistication in how the components are configured and used.
Loading
Loading