---
title: "Cardiovascular lab: catheters, cuffs, dilution curves and valves"
heading: A catheter system's natural frequency and damping from its dimensions with and without a bubble, systolic, mean and diastolic pressures from an oscillometric envelope, cardiac output from a dye curve with recirculation removed, and valve areas from gradients
eyebrow: S15 · Lesson 30 · Cardiovascular lab
xp: 60
---

::: hook
Lessons 23 to 28 measured the circulation with catheters, cuffs, indicators and flowmeters, each through a formula. A monitor runs those formulas on raw data: a catheter's dimensions, a cuff's oscillation amplitudes, a dye concentration sampled every tenth of a second. In this lab you'll write the processing a bedside monitor does, and find where each method's assumptions bend the answer.
:::

::: play
- A catheter and transducer form a second-order system. The curve is its amplitude ratio against frequency for the natural frequency and damping ratio on the sliders.
- Pressure waveforms carry harmonics to 20 Hz or so. Without a bubble a good system's $f_n$ is far above that; a tiny bubble drags it down near the harmonics and exaggerates them.
- Damping near 0.64 keeps the response flat over the widest fraction of $f_n$.
:::

```sim plot
view: graph
x: f = 1..200 log
y: A = 0..4
slider: n = 10..200 = 80 log
slider: z = 0.05..1 = 0.13
plot: 1/sqrt((1 - (f/n)^2)^2 + (2*z*f/n)^2) | label: amplitude ratio
```

::: predict
## A 1 m saline catheter of 0.5 mm radius feeds a transducer of compliance 0.01 mm³ per 100 mmHg. A 1 mm³ air bubble gets into the line. What happens to the natural frequency?

- [ ] It barely changes
- [ ] It halves
- [x] It falls by a factor of nearly four
- [ ] It rises

::: reveal
The bubble's compliance, $V_b/P$ = 1 mm³/101 kPa = 9.9 × 10⁻¹⁵ m³/Pa, is 13 times the transducer's 7.5 × 10⁻¹⁶ m³/Pa, so the total compliance rises fourteenfold, and $f_n$, which goes as its inverse square root, falls 3.8 times: from 163 Hz to 43 Hz, as in lesson 23. Task 1 computes both from the dimensions.
:::
:::

::: nameit
## What the lab computes

- **Catheter dynamics**: for a catheter of radius r and length L feeding a transducer with volume elasticity $E_d = \Delta P/\Delta V$ (a bubble's compliance, $V_b/P_\text{atm}$, adds to the transducer's), $f_n = \frac r2\sqrt{E_d/\pi\rho L}$ and $\zeta = \frac{4\eta}{r^3}\sqrt{L/\pi\rho E_d}$.
- **Oscillometry**: the mean pressure is the cuff pressure at the largest oscillation; systolic and diastolic pressures are where the amplitude falls to 0.55 and 0.85 of the peak, above and below the mean, found by linear interpolation between samples.
- **Indicator dilution**: fit a line to ln c over the downslope between 70% and 30% of the peak, giving the exponential time constant τ; the area is the trapezoid sum up to the last fitted point plus the extrapolated tail $c_\text{last}\tau$, and the cardiac output is the dose over the area.
- **Valves**: the flow during ejection, F = (cardiac output)/(heart rate × ejection time), and the area $F/(c_d\sqrt{2\Delta P/\rho})$.
:::

::: check
kind: python

## Write `catheter(r, L, Ed, rho=1000, eta=0.001)` returning ($f_n$, ζ), and `with_bubble(Ed, Vb, Patm=101325)` returning the combined elasticity.

```python starter
def catheter(r, L, Ed, rho=1000, eta=0.001):
    return 100.0, 0.1

def with_bubble(Ed, Vb, Patm=101325):
    return Ed
```

```python solution
import math

def catheter(r, L, Ed, rho=1000, eta=0.001):
    fn = r / 2 * math.sqrt(Ed / (math.pi * rho * L))
    z = 4 * eta / r ** 3 * math.sqrt(L / (math.pi * rho * Ed))
    return fn, z

def with_bubble(Ed, Vb, Patm=101325):
    return 1 / (1 / Ed + Vb / Patm)
```

```python tests
Ed = 1 / (0.01e-9 / (100 * 133.32))
fn, z = catheter(0.5e-3, 1.0, Ed)
assert abs(fn - 162.86) < 0.1 and abs(z - 0.01563) < 1e-4, "No bubble: 163 Hz and ζ = 0.016."
fb, zb = catheter(0.5e-3, 1.0, with_bubble(Ed, 1e-9))
assert abs(fb - 43.28) < 0.1 and abs(zb - 0.0588) < 1e-3, "A 1 mm³ bubble: 43 Hz and ζ = 0.059."
```

::: right
Right. The bubble is far more compliant than the transducer, so it sets the natural frequency.
:::
:::

::: check
kind: python

## Write `oscillometric(P, A)` for cuff pressures P falling with sample index and oscillation amplitudes A, returning (systolic, mean, diastolic).

```python starter
def oscillometric(P, A):
    i = max(range(len(A)), key=lambda k: A[k])
    return P[i] + 30, P[i], P[i] - 15
```

```python solution
def oscillometric(P, A):
    i = max(range(len(A)), key=lambda k: A[k])
    peak = A[i]

    def interp(k, k2, level):
        return P[k] + (level - A[k]) * (P[k2] - P[k]) / (A[k2] - A[k])

    sys = dia = None
    for k in range(i - 1, -1, -1):
        if (A[k] - 0.55 * peak) * (A[k + 1] - 0.55 * peak) <= 0:
            sys = interp(k, k + 1, 0.55 * peak)
            break
    for k in range(i, len(P) - 1):
        if (A[k] - 0.85 * peak) * (A[k + 1] - 0.85 * peak) <= 0:
            dia = interp(k, k + 1, 0.85 * peak)
            break
    return sys, P[i], dia
```

```python tests
import math
P = [200 - 0.5 * k for k in range(301)]
A = [math.exp(-((p - 93) / 30) ** 2) for p in P]
s, m, d = oscillometric(P, A)
assert m == 93.0, "The peak is at the mean pressure, 93 mmHg."
assert abs(s - (93 + 30 * math.sqrt(-math.log(0.55)))) < 0.01 and abs(d - (93 - 30 * math.sqrt(-math.log(0.85)))) < 0.01, "116 over 81 mmHg, as lesson 24's envelope predicts."
```

::: right
Right. The monitor measures only the mean directly; systolic and diastolic come from empirical ratios.
:::
:::

::: check
kind: python

## Write `stewart_hamilton(t, c, dose)`: fit an exponential to the downslope between 70% and 30% of the peak, extrapolate the tail, and return (cardiac output in L/min, area, τ), with c in mg/L, t in seconds and the dose in mg.

```python starter
def stewart_hamilton(t, c, dose):
    area = sum((c[k] + c[k + 1]) / 2 * (t[k + 1] - t[k]) for k in range(len(t) - 1))
    return dose / area * 60, area, 0.0
```

```python solution
import math

def stewart_hamilton(t, c, dose):
    i = max(range(len(c)), key=lambda k: c[k])
    pk = c[i]
    run = []
    for k in range(i, len(c)):
        if 0.3 * pk <= c[k] <= 0.7 * pk:
            run.append(k)
        elif run:
            break
    xs = [t[k] for k in run]
    ys = [math.log(c[k]) for k in run]
    n = len(xs)
    mx, my = sum(xs) / n, sum(ys) / n
    slope = sum((x - mx) * (y - my) for x, y in zip(xs, ys)) / sum((x - mx) ** 2 for x in xs)
    tau = -1 / slope
    k1 = run[-1]
    area = sum((c[k] + c[k + 1]) / 2 * (t[k + 1] - t[k]) for k in range(k1)) + c[k1] * tau
    return dose / area * 60, area, tau
```

```python tests
import math
t = [0.1 * k for k in range(600)]
K = 5 / (5 / 60) / (2 * 2.0 ** 3)
first = [K * x * x * math.exp(-x / 2.0) for x in t]
c = [a + 0.3 * K * max(0, x - 12) ** 2 * math.exp(-max(0, x - 12) / 2.0) for a, x in zip(first, t)]
co, area, tau = stewart_hamilton(t, c, 5)
assert abs(co - 5) / 5 < 0.05, "Within 5% of the true 5 L/min despite recirculation."
assert co < 5, "The fitted exponential decays more slowly than this curve's real tail, so the area comes out large and the output small."
naive = 5 / sum((c[k] + c[k + 1]) / 2 * 0.1 for k in range(599)) * 60
assert naive < 3.9, "Integrating the recirculation too would understate the output by over 20%."
```

::: right
Right. Extrapolation removes most of recirculation's error, but a gamma-shaped curve isn't exactly exponential, leaving a few percent.
:::
:::

::: check
kind: python

## Write `valve_area(co, hr, sep, dp_mmhg, cd=0.85, rho=1060)` in cm², from cardiac output (L/min), heart rate (per minute), ejection time (s) and mean gradient (mmHg).

```python starter
import math

def valve_area(co, hr, sep, dp_mmhg, cd=0.85, rho=1060):
    return co / math.sqrt(dp_mmhg)
```

```python solution
import math

def valve_area(co, hr, sep, dp_mmhg, cd=0.85, rho=1060):
    flow = co / 1000 / hr / sep
    u = math.sqrt(2 * dp_mmhg * 133.322 / rho)
    return flow / (cd * u) * 1e4
```

```python tests
a = valve_area(6.4, 78, 0.31, 7330 / 133.322)
assert abs(a - 0.8373) < 0.001, "Webster's Example 7.6: 0.84 cm²."
assert abs(valve_area(6.4, 78, 0.31, 4 * 7330 / 133.322) - a / 2) < 1e-9, "Four times the gradient at the same flow means half the area."
```

::: right
Right. The area depends on flow and gradient together, so a weak heart can hide a tight valve behind a small gradient.
:::
:::

::: explain
## Why is the mean arterial pressure the most reliable number an oscillometric cuff reports?

::: model
The cuff senses the artery's volume pulsations through the air in its bladder. The wall of the artery is most compliant when the pressure across it is near zero, that is, when the cuff pressure equals the pressure inside on average, so the oscillations are largest there: the peak marks the mean arterial pressure by physics. Systolic and diastolic pressures have no such marker in the envelope; the monitor estimates them where the amplitude falls to empirically chosen fractions of the peak, and those fractions shift with arterial stiffness and the envelope's shape, so they vary from person to person.
:::
:::
