1 Introduction

Minimally-invasive surgical interventions use thin, tubular, and flexible instruments inserted through the skull to target small regions of interest with the aim of acquiring data (e.g. electroencephalography, biopsy) or delivering therapy (e.g. injection, stimulation, ablation). The accurate placement of these instruments is important for patient safety, accurate diagnosis, and treatment efficacy [1, 11, 22]. Preoperative trajectory planning aims to minimise target point errors whilst avoiding critical structures [9, 18]. However, accurate surgical implantation may be difficult to achieve as instruments may deflect during insertion. Deflection may be caused by instrument design (mechanical properties, tip shape), tissue properties (stiffness, inhomogeneity, anisotropy), insertion forces (depth, velocity, steering) and physiological processes [11, 17]. The prediction of instrument trajectories inserted into deformable tissue is a challenging problem and an active area of research [5, 9, 17].

Needle-Tissue Interaction Models. Modelling of trajectory deflection is mostly based on mechanical modelling of tissue-needle interaction. These methods require accurate extraction of the mechanical properties of tissue and instrument together with insertion measurements (e.g. forces, velocities) to accurately predict instrument deflection. Typically such methods use approximations or simplifications derived from hand-crafted modelling techniques to account for unknown parameters. Different instrument models have been proposed including cantilever beams [17], Finite Element Methods (FEM) [5, 9], Timoshenko formulation, and Cosserat rods [12, 19]. A mechanical model proposed by [17] predicts needle deflection during needle-tissue interaction by modelling forces at the tip (dependent on tissue stiffness) and friction forces along the needle shaft. A simulation-based approach for haptic radiofrequency ablation proposed by [9] iteratively computes instrument deflection during insertion using a FEM.

Machine Learning Models. Several approaches use data-driven machine learning models to predict trajectories (e.g. vehicles, rigged skeleton models) based on spatio-temporal data. These model-free approaches require large amounts of data that must be general enough to predict unseen cases. While, the application of machine learning to predict instrument bending has to the best of our knowledge not yet been presented, these approaches represent a promising avenue to learn features of bending from real world data (i.e. previous examples of instrument trajectories and medical images). Machine learning techniques have long been applied to prediction of spatio-temporal data, most recently with Deep Learning techniques [7]. Recurrent Neural Networks (RNNs), in particular Long Short-Term Memory (LSTM) and Gated Recurrent Units (GRUs), have been applied to predict trajectories by taking into account data at previous timesteps and learning in sequences. An example of this is the prediction of the direction of white matter fibre streamlines from diffusion weighted imaging (DWI) [15].

Our Contributions. We present a novel machine learning regression approach to predict global instrument bending from image features. Instruments are modelled as elastic rods with 3DOF bending and twisting. This method is applied to predicted intra-cranial electrode bending using features extracted from structural T1-weighted (T1-w) and diffusion MRI (dMRI).

Fig. 1.
figure 1

Top: Imaging modalities: (a) post-implantation CT scan, (b) MRI, (c) probabilities from segmentation, (d) parcellation, (e) dMRI. Bottom: (f) SEEG electrode segmentation and interaction of electrodes with surface models including: (g) scalp, (h) cortex (in translucent pink), white matter (in white) and (i) deep grey matter (in blue).

2 Methods

Image Acquisition and Preprocessing. Prior to electrode implantation, MRI data was acquired either on a 3T GE Signa HDx, consisting of a 3D-T1-w and single-shell dMRI scan (as in [20]), or on a 3T GE MR750, using a T1-w MPRAGE and a multi-shell dMRI scan (as in [13]). dMRI was corrected for susceptibility-induced and eddy-current induced distortions using FSLs topup and eddy, respectively. The T1-w MRI was used to compute a brain parcellation and segmentation probabilities using geodesic information flows (GIF) [2] (Fig. 1). Smoothed 3D polygon meshes of the scalp [4] and superficial grey, white, and deep grey matter were generated from the parcellation. dMRI was modelled as a multi-tissue constrained-spherical deconvolution (MT-CSD) [10] with the Dhollander algorithm [3] implemented in MRtrix3 [21]. We characterise fibre direction and density using the ‘fixel’ framework [16]. Rigid registration of the CT image to the T1-w MRI was performed by minimising normalised mutual information (NMI) [14]. Similarly, dMRI images were registered by minimising the NMI between the T1-w MRI and b0 dMRI scan. A CT image was acquired immediately after electrode implantation.

Instrument Segmentation and Interpolation. Automatic segmentation of SEEG electrode contacts was performed [8] (Fig. 1). We interpolated instrument position from the electrode contact positions at 1 mm intervals using a shape-preserving piecewise cubic Hermite interpolation (PCHIP) [6]. For each position, the following set of features were calculated (Fig. 2, top).

Fig. 2.
figure 2

Top: Interpolation points (red circles) along trajectory with structural, white matter fibre tracks-related and trajectory-related features. Bottom: Elastic rod model where interpolated points are particles. Material frames and their rate of change (Darboux vectors) are computed to characterise local/global bending.

  • Structural: voxel probability of being background, cerebral spin fluid, grey matter, white matter, deep grey matter and brain stem; and the brain region.

  • White matter fibre tracks: number and direction of crossing fibres, fibre density and angle of the fibre with respect to the trajectory.

  • Trajectory: number of regions traversed, length of region at position, angle with respect to surfaces scalp, superficial grey, white, and deep grey matter, distance to grey matter, distance to cortex, distance to previous and next region, and distance from scalp to cortex and from cortex to white matter.

Instrument Bending Model. Instruments were modelled as Cosserat elastic rods in the Position-based Dynamics library. Particles were placed at the interpolated instrument position. Ghosts particles were placed orthogonally half-way between each particle. A material frame is computed between particles with a unit vector aligned tangentially to the direction of the rod and two orthonormal vectors. The rate of change between two consecutive material frames was computed as a Darboux vector [12] (Fig. 2, bottom), where the x, y and z components indicate lateral bending, upward/downward bending and twisting, respectively. For each particle two Darboux vectors were computed: (a) local bending (between material frames of neighbouring particles) and (b) global bending (between the material frame corresponding to the first particle and the current particle).

Training Model. An Ordinary Least Squares multiple regression was executed (Statsmodels library) to determine which features have a statistically significant effect on bending. Three regression models were built and evaluated: (a) Random Forest (RF), (b) Feed-Forward Neural Network (FFNN) and (c) LSTM (see Table 1). Global bending at the electrode tip was used as the predicted output of the regression model. Local bending and previous global bending are used as input features.

Table 1. Training model architecture

3 Experimental Design and Validation

We trained our models from 32 post-implantation SEEG cases (296 electrodes, 13107 interpolation points) comprising two different surgical approaches, placing a guiding stylet close to or far from target point. Through multiple linear regression, we found a significant effect on instrument bending of the features listed in Table 2 (\(R^2=0.313\)). The data from these features (27 in total) was normalised. We created dichotomous variables for the treating categorical variables.

Table 2. Features with significant effect (\(p<0.05\)) on instrument bending
Table 3. Performance of bending prediction of (a) RF, FFNN and LSTM models

A 5-fold cross validation was performed for each model (i.e. RF, FFNN and LSTM). For each fold, we split the data into three sets. A validation set contains a trajectory randomly selected from 15 SEEG cases (i.e. 15 trajectories in total). The remaining data is split into a train set containing 80% and a test set containing 20%. We then conducted two experiments using these three sets: (a) model validation and (b) trajectory accuracy. In experiment (a), we trained our regressor models using the train set and evaluated the inference scores against the test set. The models were trained and average prediction scores across folds are reported in Table 3.

In experiment (b), we selected 30 trajectories from the validation set across folds (15, 4, 4, 4, 3 respectively). Using the trained models of the respective folds, the insertion of an electrode was simulated iteratively starting with the first six interpolated points (sequence length for LSTM) at 1 mm intervals from the electrode bolt. Details of the simulation loop can be found in Algorithm 1.

figure a
Fig. 3.
figure 3

Prediction accuracy. Top: Mean average error (MAE) of predicted trajectories (RF, FFNN, LSTM) with respect to True trajectory. X-axis indicates the MAE of True trajectory with respect to Plan (rigid) trajectory. Size of circle indicates standard deviation (see two examples for reference). Bottom: 3D rendering of planned (in white), true (in yellow) and predicted (RF in red, FFNN in green, LSTM in blue) electrode trajectories of two examples highlighted in scatter plot above.

We then evaluated the accuracy of the trajectory bending prediction (Fig. 3). Distances between true and predicted trajectories were measured. RF had the lowest MAE (\(\mu =0.49, \sigma =0.43\)), followed by FFNN (\(\mu =0.71, \sigma =0.41\)) and by LSTM (\(\mu =0.93, \sigma =0.65\)). Under the current training paradigm, we observed that LSTMs tend to accumulate error (given the current accuracy of the 5-fold cross validation in Table 3). Further analysis and method development is required to keep predicted electrode bending within realistic values.

4 Conclusion

We present a novel machine learning regression model to predict local instrument bending from image features. The instrument is modelled as an elastic rod, with 3DOF, that traverses soft tissue, characterised as inhomogeneous and anisotropic. Our method allows for the prediction of orientation and position along the instrument trajectory. The main limitation of our current work is that we study instrument bending in a specific application (SEEG electrode implantation). In future work, we will validate our method in other applications. Additionally, we will integrate our model into a trajectory planning algorithm with the aim of improved pre-operative planning.