## 2 Materials and Methods
### General Workflow  
First, the surgeon provides the relevant information in the form of geometric constraints--atlas-based segmentation binary volumetric datasets segmented by regions--and selects an initial zone where possible entry points will be located. By using the DWI images and the procedure explained in Section 2.3, the surgeon defines the tracts to be preserved in an occupancy map format. The occupancy map dataset includes the vector-ordered information of the Cartesian co-ordinates of the tracts so that they can be used within Euclidean distance calculation algorithms. Section 2.3 details how these properly formatted structures are obtained through using ExploreDTI v4.7.9 [24] software. In the next step of the algorithm, the entry angles for each one of the entry points are calculated in Slicer3D(r) v5.6.0 software by using the geometrical information of the T1W images and the atlas-based segmentation. The entry angle is computed to calculate the normal vector for the surface at each of the points. The segmentation of the cranial bone obtained from the initial MRI images is used for this purpose. By starting at each of the entry points, the rapidly exploring random tree (RRT) algorithm is applied to generate trajectories that reach the target, and each of these trajectories is evaluated with the proposed cost function. The proposed algorithm is implemented in Matlab, to which the corresponding information of the calculated entry angles, tract occupancy map, and the start and destination points are fed. The selected path-planning methodology is the RRT algorithm (see Figure 2a), which operates by incrementally growing a tree structure from an initial configuration towards a given goal within a spatial configuration space, which, in this particular case, is a three-dimensional space. At each iteration, the algorithm analyzes the properties of a sample from the space and gradually extends the tree based on encountered constraints complying with the geometric restrictions of the growth interval and bending limit of the selected surgical tool. Through this incremental expansion, the objective is to reach the goal and delineate the path constructed from the performed iterations. Subsequently, the trajectories generated are evaluated, including the Cartesian information of the neural tracts selected by the surgeon from the DWI images. For the trajectory evaluation, a cost function capable of handling the information from both image sources is defined. In Figure 2b, we describe the characteristics to consider for the configuration of both the initial and goal points, as well as the spatial configuration for the proper functioning of the algorithm. The angle of entry is obtained as the angle between the projection of the straight line formed by the first trajectory segment after the entry point and the one that is normal to the surface of the skull at that point. The minimum distance is defined as the Euclidean distance between the entry  
Figure 1: Flow chart of the proposed framework. point and the target point. The total distance is defined as the sum of the segments that make up the curved path. A safety radius (\(r_{c}\)) is established for the calculation of collisions to eliminate unsafe trajectories. Prior to planning, it is indispensable to classify the relevant information to obtain an optimal result. To do so, it is necessary to clinically define the entry area, the objective, the obstacles or regions to be avoided, and other constraints, such as the insertion angle or restricted insertion areas. The primary anatomical regions to avoid include areas with sulci, blood vessels, neural tracts, and ventricles; additionally, the ideal insertion angle should be perpendicular to the surface of the skull; however, a deviation of no greater than 30\({}^{\circ}\) from the perpendicular line to the skull may be permissible. Regarding insertion areas, the facial region should be avoided, except for a potential endonasal entry.