Precise electrode localization is important for maximizing the utility of intracranial EEG data. Electrodes are typically localized from post-implantation CT artifacts, but algorithms can fail due to low signal-to-noise ratio, unrelated artifacts, or high-density electrode arrays. Minimizing these errors usually requires time-consuming visual localization and can still result in inaccurate localizations. In addition, surgical implantation of grids and strips typically introduces non-linear brain deformations, which result in anatomical registration errors when post-implantation CT images are fused with the pre-implantation MRI images. Several projection methods are currently available, but they either fail to produce smooth solutions or do not account for brain deformations.To address these shortcomings, we propose two novel algorithms for the anatomical registration of intracranial electrodes that are almost fully automatic and provide highly accurate results. We first presentGridFit, an algorithm that simultaneously localizes all contacts in grids, strips, or depth arrays by fitting flexible models to the electrodes’ CT artifacts. We observed localization errors of less than one millimeter (below 8% relative to the inter-electrode distance) and robust performance under the presence of noise, unrelated artifacts, and high-density implants when we ran ~6000 simulated scenarios. Furthermore, we validated the method with real data from 20 intracranial patients.As a second registration step, we introduceCEPA, a brain-shift compensation algorithm that combines orthogonal-based projections, spring-mesh models, and spatial regularization constraints. When tested with real data from 15 patients, anatomical registration errors were smaller than those obtained for well-established alternatives. Additionally,CEPAaccounted simultaneously for simple mechanical deformation principles, which is not possible with other available methods. Inter-electrode distances of projected coordinates smoothly changed across neighbor electrodes, while changes in inter-electrode distances linearly increased with projection distance. Moreover, in an additional validation procedure, we found that modeling resting-state high-frequency activity (75–145 Hz ) in five patients further supported our new algorithm.Together,GridFitandCEPAconstitute a versatile set of tools for the registration of subdural grid, strip, and depth electrode coordinates that provide highly accurate results even in the most challenging implantation scenarios. The methods presented here are implemented in the iElectrodes open-source toolbox, making their use simple, accessible, and straightforward to integrate with other popular toolboxes used for analyzing electrophysiological data.