The invention provides a three-dimensional
magnetic field coil design method suitable for magnetic compensation of a brain magnetic test area. The method comprises the following steps: S1, constructing an analytical model
cylindrical coordinate system in the brain magnetic test area; s2, constructing a
magnetic field analytical equation; s3, linearly superposing the
barrel bottom fan-shaped coil pair and the
barrel side
saddle-shaped coil to form a radial coil based on a
magnetic field analytical equation, and superposing the
barrel side annular coil pair to form an axial coil, then optimizing the structural parameters of the radial coil and the axial coil based on an intelligent optimization
algorithm, and constructing to obtain three groups of shimming coils and five groups of mutually independent
linear gradient coils; and S4, describing interference magnetic field distribution in the brain magnetic test area through a vector spherical
harmonic function, and adjusting the magnitude of current flowing in the coil so as to be matched with the interference magnetic field distribution. The method has the beneficial effects that the compensation coil capable of being highly matched with the magnetic field distribution trend of the brain magnetic test area under the interference condition can be designed, and the
residual magnetic field in the single-end-opened cylindrical
alloy barrel is accurately compensated.