It remains unclear whether tractography of pyramidal tracts is correlated with the intraoperative direct electrical subcortical stimulation (DESS), and brain shift further complicates the issue. The objective of this research is to quantitatively verify the correlation between optimized tractography (OT) of pyramidal tracts after brain shift compensation and DESS during brain tumor surgery. OT was performed for 20 patients with lesions in proximity to the pyramidal tracts based on preoperative diffusion-weighted magnetic resonance imaging. During surgery, tumor resection was guided by DESS. A total of 168 positive stimulation points and their corresponding stimulation intensity thresholds were recorded. Using the brain shift compensation algorithm based on hierarchical B-spline grids combined with a Gaussian resolution pyramid, we warped the preoperative pyramidal tract models and used receiver operating characteristic (ROC) curves to investigate the reliability of our brain shift compensation method based on anatomic landmarks. Additionally, the minimum distance between the DESS points and warped OT (wOT) model was measured and correlated with DESS intensity threshold. Brain shift compensation was achieved in all cases, and the area under the ROC curve was 0.96 in the registration accuracy analysis. The minimum distance between the DESS points and the wOT model was found to have a significantly high correlation with the DESS stimulation intensity threshold (r = 0.87, P < 0.001), with a linear regression coefficient of 0.96. Our OT method can provide comprehensive and accurate visualization of the pyramidal tracts for neurosurgical navigation and was quantitatively verified by intraoperative DESS after brain shift compensation.