In this paper, we propose an approach to find the optimal position of an electrode, for assisting surgeons in planning Deep Brain Stimulation. We first show how we formalized the rules governing this surgical procedure into geometric constraints. Then we explain our method, using a formal geometric solver, and a template built from 15 MRIs, used to propose a space of possible solutions and the optimal one. We show our results for the retrospective study on 8 implantations from 4 patients, and compare them with the trajectory of the electrode that was actually implanted. The results show a slight difference with the reference trajectories, with a better evaluation for our proposition.