Software

Scientific software, running live in your browser.

This site is built with the open-source Julia tools I help maintain. Therapy.jl builds the website and navigation, WasmMakie.jl draws the interactive 3D plot below directly in your browser, and Snapshot.jl embeds two live Pluto.jl notebooks right on this page without needing a Julia server.

WasmMakie.jl · 3D Plot

3D Coronary Vascular Tree

A 3D model of coronary arteries wrapping the heart muscle, computed and shaded live in your browser from Julia. Drag to rotate, scroll to zoom.

Vasculature.jl↗
Drag to orbit · Scroll to zoom
branches5
angle °28

Snapshot.jl · Pluto Notebook 1

X-Ray Physics & CT Image Contrast

See how X-ray tube voltage, filtering, and energy choices change what a CT scan shows, using live sliders inside an embedded Pluto notebook.

BasisSimulator.jl↗
basissim_ct_physics.jlPluto Notebook · Snapshot.jl

Polychromatic CT Physics & Virtual Monoenergetic Imaging

Clinical CT scanners emit a polychromatic X-ray spectrum rather than a single monoenergetic beam. In BasisSimulator.jl, we propagate full energy-resolved spectra through Beer-Lambert attenuation and reconstruct both raw energy-integrating scans and Virtual Monoenergetic Images (VMI).

Every slider below drives pure-Julia WasmMakie physics directly in your browser via Snapshot.jl + WasmTarget.jl with no Julia server.

1. Tungsten Source Spectrum & Beam Hardening

As X-rays traverse aluminum filtration and patient tissue, lower-energy photons are preferentially absorbed via the photoelectric effect ($\mu_{\text{pe}} \propto Z^3 / E^3$). The transmitted beam shifts toward higher effective energy, an effect known as beam hardening.

Tube peak voltage (kVp) = 120

Aluminum filtration (mm Al) = 3.5

Water phantom thickness (cm) = 16.0

2. Virtual Monoenergetic (VMI) Iodine vs. Calcium Contrast

By decomposing polychromatic measurements into physical basis materials (e.g., water and calcium or iodine), we synthesize monochromatic attenuation at any target energy $E_0$:

$$\text{HU}(E_0) = 1000 \cdot \frac{\mu(E_0) - \mu_{\text{water}}(E_0)}{\mu_{\text{water}}(E_0)}$$

Sweep the target VMI energy $E_0$ and iodine lumen concentration below to observe how low-keV reconstructions dramatically amplify iodine contrast near its 33.2 keV K-edge while high-keV reconstructions suppress dense calcification blooming.

Target VMI energy $E_0$ (keV) = 65

Iodine concentration (mg I/mL) = 9.0

3. Reproducible CT Virtual Trials

The same forward-physics principles power full 3D fan-beam and helical cone-beam simulations in BasisSimulator.jl across NVIDIA CUDA, Apple Metal, AMD ROCm, and CPU backends (SoftwareX, 2026).

using PlutoUI, WasmMakie
build_spectrum_plot (generic function with 1 method)
function build_spectrum_plot(kvp_i::Int64, al_t::Float64, water_t::Float64)
    kvp = Float64(kvp_i)
    fig = WasmMakie.Figure(size = (720.0, 340.0))
    ax = WasmMakie.Axis(
        fig[1, 1];
        title = "Polychromatic X-Ray Spectrum & Beam Hardening",
        xlabel = "Photon Energy (keV)",
        ylabel = "Normalized Flux",
    )

    n = Int64(130)
    es = Vector{Float64}(undef, n)
    s_raw = Vector{Float64}(undef, n)
    s_filt = Vector{Float64}(undef, n)
    s_trans = Vector{Float64}(undef, n)

    max_raw = 1.0e-9
    max_filt = 1.0e-9
    max_trans = 1.0e-9
    i = Int64(1)
    while i <= n
        e = 12.0 + 132.0 * Float64(i - Int64(1)) / Float64(n - Int64(1))
        es[i] = e
        if e < kvp
            # Kramers Bremsstrahlung + tungsten K-alpha/K-beta characteristic lines
            brem = (kvp - e) / kvp * (e / 30.0)^0.35
            char_ka = kvp > 69.5 ? 0.42 * exp(-((e - 59.3) / 1.4)^2) : 0.0
            char_kb = kvp > 69.5 ? 0.16 * exp(-((e - 67.2) / 1.4)^2) : 0.0
            raw = brem + char_ka + char_kb
        else
            raw = 0.0
        end

        # Approximate linear attenuation for Al (mm^-1) and H2O (cm^-1)
        mu_al = 0.035 + 14500.0 / (e * e * e)
        mu_h2o = 0.165 + 1900.0 / (e * e * e)
        filt = raw * exp(-mu_al * al_t)
        trans = filt * exp(-mu_h2o * water_t)

        s_raw[i] = raw
        s_filt[i] = filt
        s_trans[i] = trans
        if raw > max_raw; max_raw = raw; end
        if filt > max_filt; max_filt = filt; end
        if trans > max_trans; max_trans = trans; end
        i = i + Int64(1)
    end

    # Compute mean energies and normalize spectra for clear shape comparison
    sum_f = 0.0; num_f = 0.0
    sum_t = 0.0; num_t = 0.0
    j = Int64(1)
    while j <= n
        num_f = num_f + es[j] * s_filt[j]
        sum_f = sum_f + s_filt[j]
        num_t = num_t + es[j] * s_trans[j]
        sum_t = sum_t + s_trans[j]
        s_raw[j] = s_raw[j] / max_raw
        s_filt[j] = s_filt[j] / max_filt
        s_trans[j] = s_trans[j] / max_trans
        j = j + Int64(1)
    end
    mean_f = sum_f > 0.0 ? num_f / sum_f : 60.0
    mean_t = sum_t > 0.0 ? num_t / sum_t : 70.0

    WasmMakie.lines!(ax, es, s_raw; color = (:gray, 0.55), linestyle = :dash, linewidth = 1.6, label = "Unfiltered W")
    WasmMakie.lines!(ax, es, s_filt; color = WasmMakie.Cycled(1), linewidth = 2.3, label = "After Al filter")
    WasmMakie.lines!(ax, es, s_trans; color = WasmMakie.Cycled(2), linewidth = 2.4, label = "Post-phantom")
    WasmMakie.vlines!(ax, [mean_f]; color = WasmMakie.Cycled(1), linestyle = :dot)
    WasmMakie.vlines!(ax, [mean_t]; color = WasmMakie.Cycled(2), linestyle = :dot)
    WasmMakie.axislegend(ax; position = :rt)
    return fig
end
build_vmi_contrast_plot (generic function with 1 method)
function build_vmi_contrast_plot(vmi_i::Int64, iod_mg::Float64)
    vmi_e = Float64(vmi_i)
    fig = WasmMakie.Figure(size = (720.0, 340.0))
    ax = WasmMakie.Axis(
        fig[1, 1];
        title = "Virtual Monoenergetic Attenuation Curves (HU)",
        xlabel = "VMI Energy E₀ (keV)",
        ylabel = "CT Number (HU)",
    )

    n = Int64(90)
    es = Vector{Float64}(undef, n)
    hu_iod = Vector{Float64}(undef, n)
    hu_ca = Vector{Float64}(undef, n)
    hu_myo = Vector{Float64}(undef, n)
    hu_lip = Vector{Float64}(undef, n)

    i = Int64(1)
    while i <= n
        e = 38.0 + 92.0 * Float64(i - Int64(1)) / Float64(n - Int64(1))
        es[i] = e
        mu_w = 0.165 + 1900.0 / (e * e * e)
        # Iodine mass attenuation above K-edge (33.2 keV) scaled by mg/mL
        mu_i = mu_w + (iod_mg / 1000.0) * (0.25 + 480000.0 / (e * e * e))
        # Calcified plaque (~200 mg/cm^3 hydroxyapatite)
        mu_c = mu_w + 0.20 * (0.14 + 92000.0 / (e * e * e))
        # Myocardium soft tissue & lipid plaque
        mu_m = mu_w * 1.052
        mu_l = 0.153 + 980.0 / (e * e * e)

        hu_iod[i] = 1000.0 * (mu_i - mu_w) / mu_w
        hu_ca[i] = 1000.0 * (mu_c - mu_w) / mu_w
        hu_myo[i] = 1000.0 * (mu_m - mu_w) / mu_w
        hu_lip[i] = 1000.0 * (mu_l - mu_w) / mu_w
        i = i + Int64(1)
    end

    WasmMakie.lines!(ax, es, hu_iod; color = WasmMakie.Cycled(1), linewidth = 2.4, label = "Iodine Lumen")
    WasmMakie.lines!(ax, es, hu_ca; color = WasmMakie.Cycled(2), linewidth = 2.4, label = "Calcified Plaque")
    WasmMakie.lines!(ax, es, hu_myo; color = WasmMakie.Cycled(3), linewidth = 1.9, label = "Myocardium")
    WasmMakie.lines!(ax, es, hu_lip; color = WasmMakie.Cycled(4), linewidth = 1.9, label = "Lipid Core")
    WasmMakie.vlines!(ax, [vmi_e]; color = (:black, 0.7), linestyle = :dash)
    WasmMakie.hlines!(ax, [0.0]; color = (:gray, 0.45), linestyle = :dot)
    WasmMakie.axislegend(ax; position = :rt)
    return fig
end

Snapshot.jl · Pluto Notebook 2

Blood Flow & 3D Coronary Vessels

A second live Pluto notebook embedded on the same page with its own independent controls and table of contents.

Snapshot Composition↗
vasculature_mmd_explorer.jlPluto Notebook · Snapshot.jl

Vascular Tree Hemodynamics & Myocardial Perfusion

In Vasculature.jl, synthetic coronary networks grow inside anatomical organs by minimizing intravascular volume subject to Murray's Law and Poiseuille's Law, then solve steady-state flow and contrast advection to produce ground-truth digital perfusion phantoms.

This second embedded Pluto notebook runs an independent WasmGC runtime and its own scoped PlutoUI.TableOfContents() right alongside the CT Physics notebook above.

1. Murray's Law Scaling Across Arterial Generations

At every vascular bifurcation, parent radius $r_0$ relates to daughter radii $r_1, r_2$ through the power-law optimality condition

$$r_0^\gamma = r_1^\gamma + r_2^\gamma$$

where $\gamma \approx 3.0$ minimizes the combined metabolic cost of blood volume and viscous dissipation. Adjust $\gamma$ and the bifurcation symmetry ratio below to see how lumen tapering governs downstream Poiseuille resistance ($R \propto L / r^4$).

Murray exponent $\gamma$ = 3.0

Daughter symmetry ratio $r_2 / r_1$ = 0.8

2. 3D Myocardial Perfusion Territory (WasmMakie.Axis3)

When a proximal coronary artery develops a focal stenosis, downstream myocardial blood flow (mL/min/g) falls non-linearly across the subtended vascular territory. Drag the stenosis severity and 3D camera azimuth sliders below to inspect the ischemic deficit in real time.

Coronary diameter stenosis (%) = 45

3D Camera azimuth (deg) = 230

using PlutoUI, WasmMakie
build_murray_plot (generic function with 1 method)
function build_murray_plot(gamma::Float64, alpha::Float64)
    fig = WasmMakie.Figure(size = (720.0, 330.0))

    # Left: Radius tapering across generations
    ax1 = WasmMakie.Axis(
        fig[1, 1];
        title = "Vessel Radius Tapering",
        xlabel = "Branching Generation k",
        ylabel = "Radius (mm)",
    )
    # Right: Mean intravascular pressure profile
    ax2 = WasmMakie.Axis(
        fig[1, 2];
        title = "Hemodynamic Pressure Drop",
        xlabel = "Branching Generation k",
        ylabel = "Pressure (mmHg)",
    )

    ng = Int64(10)
    gens = Vector{Float64}(undef, ng)
    r_major = Vector{Float64}(undef, ng)
    r_minor = Vector{Float64}(undef, ng)
    pres = Vector{Float64}(undef, ng)

    # r1/r0 = (1 + alpha^gamma)^(-1/gamma)
    scale_maj = (1.0 + alpha^gamma)^(-1.0 / gamma)
    scale_min = alpha * scale_maj

    rmaj = 1.85
    rmin = 1.85
    pcur = 100.0
    k = Int64(1)
    while k <= ng
        gens[k] = Float64(k - Int64(1))
        r_major[k] = rmaj
        r_minor[k] = rmin
        pres[k] = pcur

        # Poiseuille pressure drop increases sharply in small arterioles
        dp = 4.2 * (1.85 / rmaj)^1.15
        pcur = max(22.0, pcur - dp)
        rmaj = rmaj * scale_maj
        rmin = rmin * scale_min
        k = k + Int64(1)
    end

    WasmMakie.lines!(ax1, gens, r_major; color = WasmMakie.Cycled(1), linewidth = 2.4, label = "Major path")
    WasmMakie.lines!(ax1, gens, r_minor; color = WasmMakie.Cycled(2), linewidth = 2.2, linestyle = :dash, label = "Minor daughter")
    WasmMakie.scatter!(ax1, gens, r_major; color = WasmMakie.Cycled(1), markersize = 6.5)
    WasmMakie.axislegend(ax1; position = :rt)

    WasmMakie.lines!(ax2, gens, pres; color = WasmMakie.Cycled(3), linewidth = 2.4, label = "Mean P(k)")
    WasmMakie.scatter!(ax2, gens, pres; color = WasmMakie.Cycled(3), markersize = 6.5)
    WasmMakie.hlines!(ax2, [30.0]; color = (:gray, 0.55), linestyle = :dash)
    return fig
end
build_perfusion_3d (generic function with 1 method)
function build_perfusion_3d(sten_i::Int64, az_i::Int64)
    sten = Float64(sten_i) / 100.0
    az = Float64(az_i) * 0.017453292519943295

    fig = WasmMakie.Figure(size = (720.0, 410.0))
    ax = WasmMakie.Axis3(
        fig[1, 1];
        title = "Myocardial Blood Flow Surface (mL/min/g)",
        xlabel = "Anterior-Posterior",
        ylabel = "Lateral-Septal",
        zlabel = "MBF",
        azimuth = az,
        elevation = 0.42,
        perspectiveness = 0.25,
    )

    nx = Int64(24)
    ny = Int64(24)
    xs = Vector{Float64}(undef, nx)
    ys = Vector{Float64}(undef, ny)
    i = Int64(1)
    while i <= nx
        xs[i] = -3.0 + 6.0 * Float64(i - Int64(1)) / Float64(nx - Int64(1))
        i = i + Int64(1)
    end
    j = Int64(1)
    while j <= ny
        ys[j] = -3.0 + 6.0 * Float64(j - Int64(1)) / Float64(ny - Int64(1))
        j = j + Int64(1)
    end

    # Nonlinear Gould-curve flow drop above ~40% stenosis
    deficit = 2.4 * (sten * sten * sten)
    zs = Vector{Float64}(undef, nx * ny)
    j = Int64(1)
    while j <= ny
        yj = ys[j]
        i = Int64(1)
        while i <= nx
            xi = xs[i]
            # Healthy stress myocardial blood flow ≈ 2.6 mL/min/g with gentle spatial variation
            base_mbf = 2.55 + 0.14 * sin(0.7 * xi) * cos(0.7 * yj)
            # Subtended LAD anterior ischemic territory centered at (0.8, 0.5)
            d2 = ((xi - 0.8) / 1.35)^2 + ((yj - 0.5) / 1.15)^2
            mbf = max(0.35, base_mbf - deficit * exp(-d2))
            zs[i + (j - Int64(1)) * nx] = mbf
            i = i + Int64(1)
        end
        j = j + Int64(1)
    end

    sf = WasmMakie.surface!(ax, xs, ys, zs, nx, ny; colormap = :inferno, colorrange = (0.3, 2.8))
    WasmMakie.wireframe!(ax, xs, ys, zs, nx, ny; color = (0.0, 0.0, 0.0, 0.20), linewidth = 0.55)
    WasmMakie.Colorbar(fig[1, 2], sf; label = "mL/min/g")
    return fig
end

Directory

Packages

MolloiLab · Medical Imaging

github.com/MolloiLab ↗

BasisSimulator.jl

Simulates how X-rays form CT images and reconstructs scans across CPUs and all major GPUs (SoftwareX, 2026).

Vasculature.jl

Generates 3D branching blood vessel networks, models blood flow, and builds digital organ phantoms on CPUs and GPUs.

XrayAttenuation.jl

Looks up standard NIST X-ray absorption curves for elements, compounds, and body tissues.

GroupTherapyOrg · Interactive Julia & Web Tools

github.com/GroupTherapyOrg ↗

SpaceStation.jl

A desktop and remote workspace built around Pluto notebooks, with multi-file tabs, terminals, and coding-agent tools.

Therapy.jl

Builds fast, interactive websites in pure Julia, including file-based routing and embedded Pluto notebooks.

Snapshot.jl

Exports interactive Pluto notebooks into standalone web pages whose sliders run directly in your browser with no server.

WasmMakie.jl

Draws interactive 2D and 3D Makie plots directly on web canvases from compiled Julia.

WasmTarget.jl

Compiles Julia code directly into small, standalone WebAssembly modules that run inside any modern browser.