Two approaches to defining almost-invariant surfaces for magnetic fiel
ds with imperfect magnetic surfaces are compared. Both methods are bas
ed on treating magnetic field-line flow as a 1 1/2-dimensional Hamilto
nian (or Lagrangian) dynamical system. In the quadratic-flux minimizin
g surface approach, the integral of the square of the action gradient
over the toroidal and poloidal angles is minimized, while in the ghost
surface approach a gradient flow between a minimax and an action-mini
mizing orbit is used. In both cases the almost-invariant surface is co
nstructed as a family of periodic pseudo-orbits, and consequently it h
as a rational rotational transform. The construction of quadratic-flux
minimizing surfaces is simple, and easily implemented using a new mag
netic field-line tracing method. The construction of ghost surfaces re
quires the representation of a pseudo field line as an (in principle)
infinite-dimensional vector and also is inherently slow for systems ne
ar integrability. As a test problem the magnetic field-line Hamiltonia
n is constructed analytically for a topologically toroidal, non-integr
able ABC-flow model, and both types of almost-invariant surface are co
nstructed numerically.