BackgroundElectric fields (E-fields) induced by transcranial magnetic stimulation (TMS) can be modeled using partial differential equations (PDEs) with boundary conditions. However, existing numerical methods to solve PDEs for computing E-fields are usually computationally expensive. It often takes minutes to compute a high-resolution E-field using state-of-the-art finite-element methods (FEM).MethodsWe developed a self-supervised deep learning (DL) method to compute precise TMS E-fields in real-time. Given a head model and the primary E-field generated by TMS coils, a self-supervised DL model was built to generate a E-field by minimizing a loss function that measures how well the generated E-field fits the governing PDE and Neumann boundary condition. The DL model was trained in a self-supervised manner, which does not require any external supervision. We evaluated the DL model using both a simulated sphere head model and realistic head models of 125 individuals and compared the accuracy and computational efficiency of the DL model with a state-of-the-art FEM.ResultsIn realistic head models, the DL model obtained accurate E-fields with significantly smaller PDE residual and boundary condition residual than the FEM (p<0.002, Wilcoxon signed-rank test). The DL model was computationally efficient, which took about 0.30 seconds on average to compute the E-field for one testing individual. The DL model built for the simulated sphere head model also obtained an accurate E-field whose difference from the analytical E-fields was 0.004, more accurate than the solution obtained using the FEM.ConclusionsWe have developed a self-supervised DL model to directly learn a mapping from the magnetic vector potential of a TMS coil and a realistic head model to the TMS induced E-fields, facilitating real-time, precise TMS E-field modeling.