Modelling and real-time dynamic simulation of flexible needles for prostate biopsy and brachytherapy

ABSTRACT Percutaneous needle insertion constitutes a widely adopted technique for performing minimally invasive operations. Robot-assisted needle placement and virtual surgical training platforms have the potential to significantly improve the accuracy of these operations. For this, the development of mathematical models that provide a complete characterization of the underlying dynamics of medical needles is considered of paramount importance. In this paper, we develop two three-dimensional nonlinear rigid/flexible dynamic models of brachytherapy and local anaesthetic transperineal biopsy (LATP) needles. The proposed models relax the assumptions of previous investigations, quantify the vibrational behaviour and the rigid-body dynamics of medical needles and allow for real-time haptic and visual feedback information. Their accuracy and computational efficiency are assessed and validated using commercial software. The results show that, among the examined methods, the Rigid Finite Element Method provides the most accurate and numerically efficient solution for capturing the dynamics of flexible medical needles.


Introduction
In the last few decades, minimally invasive surgery (MIS) and localized therapy have become integral parts of modern medical practices as they offer significant advantages over conventional open surgery, such as decreased recovery time, lower risk of infection and reduced patient discomfort [1].One of the most widely used MIS procedures is percutaneous needle insertion, with a plethora of diagnostic and therapeutic applications, such as neurosurgery, deep brain stimulation, epidural anaesthesia, tissue biopsy and prostate brachytherapy [2].
The success of the aforementioned operations is highly dependent on the accuracy of needle placement, while imprecise targeting often leads to severe complications, such as false negatives in biopsy or ablation of healthy tissue [1].However, accurate percutaneous needle placement is a highly challenging task.The limited visual feedback during the operation, combined with factors such as tissue anisotropy, heterogeneity and variability in anatomical structures among patients make navigation through tissue particularly complicated and decrease the procedure's overall accuracy [3].
In recent years, there has been significant effort to provide robust solutions for increasing the accuracy of needle placement procedures.Research has mainly focused on the development of robotic systems that allow autonomous or semi-autonomous navigation and accurate needle placement to targeted locations inside soft tissue [4,5].Furthermore, the development of high-fidelity visual/haptic surgical simulators has allowed the training of junior surgeons in a variety of surgical scenarios and the preoperative planning of complex procedures by experienced doctors, leading to an overall improvement of the needle's placement accuracy [2,6,7].
A key requirement for the implementation of robotic guidance or simulated training solutions is the formulation of mathematical models that can accurately describe the dynamics of needle insertion.A common practice found in the literature is the division of the needle insertion modelling problem into three separate components [8]: [a)] the modelling of the soft tissue [9][10][11], the characterization of the interaction forces between the needle and the surrounding medium [1,12,13] and the modelling of the flexible needle [8,14,15].This division allows the development of decoupled mathematical models for the needle and the tissue, while needle-tissue interaction is often modelled based on experimentally derived generalized force profiles at the needle's base during needle insertion procedures [1].
This work focuses on the formulation of accurate and computationally efficient models of flexible medical needles.These are of paramount importance as they not only provide an accurate description of the needle's behaviour but also allow for the minimization of the stochasticity that is present during the aforementioned experimentally derived models of needle-tissue interaction.As a result, accurate needle models can significantly improve the identification accuracy of needle-tissue interaction dynamics, and, thus, constitute a key prerequisite for the systematic modelling of needle insertion procedures.

Related work
A complete characterization of flexible medical needles aims to identify the relationship between the spatio-temporal behaviour of the needle's geometry and the specified motion trajectory at its base (e.g.insertion velocity, axial and lateral rotation), under the effect of some arbitrary loading conditions acting on its shaft.Furthermore, complete needle models provide information about the reaction forces at the needle's base, due to the combined effect of the input driving constraints and the input loading conditions.The following paragraphs provide a review of various computational methods that have been developed to tackle some or all of these modelling requirements.
In the study by Webster et al. [16], a novel non-holonomic model, based on a variation of the kinematic bicycle model, was proposed.The model allowed for a computationally efficient estimation of the needle's deflection given the insertion and rotation speed of its base.However, the model did not provide any information about the vibrational behaviour of the needle and the profiles of the associated reaction forces.Furthermore, due to its various modelling assumptions, the method led to significant deviations when compared with experimental studies [14].Extensions of this model have been used in the literature for the development of kineto-dynamic path planning algorithms [17,18].
The need for more accurate needle models and information about the dynamic properties of needle insertion has led to a transition from kinematic to mechanicsbased modelling approaches.Researchers [15,19,20] developed quasi-static needle models, based on the linear Euler-Bernoulli beam theory, to describe needle deflection during percutaneous insertion procedures.While this modelling approach offered simplicity and computational efficiency, its linearity assumption led to invalid solutions when large deflections were considered [8,21].To account for the geometric nonlinearity and minimize the targeting error of linear modelling approaches, DiMaio and Salcudean [22] and Goksel et al. [8] developed quasi-static methods based on nonlinear 2D and 3D Finite Element Method (FEM).Similarly, Adagolodjo et al. [23] presented a geometrically nonlinear quasi-static model of flexible needles based on FEM and the corotational formulation.These models provided both computational efficiency and high accuracy when compared with experimental results for describing the steady-state responses of both large and small needle's deflections.
Both linear and nonlinear models described above estimate needle's deflection assuming a quasi-static needle insertion.In other words, it is assumed that the needle is inserted at a rate that does not allow for any oscillatory transients to occur and deflection is approximated by a sequence of steady-state responses.This assumption, however, does not provide any information about the vibrational behaviour of the needle and does not account for the correlation between its deflection and the system's input parameters, such as its insertion velocity and the rate of axial rotation.This poses significant limitations as needle insertion is a highly dynamic procedure [24].As shown in the study by Podder et al. [25,26,], during brachytherapy operations, input parameters, such as the insertion velocity, span a wide range of values and considerably affect the needle's deflection and vibration.More specifically, few studies [20,[27][28][29][30] have proven the strong coupling of parameters such as the needle insertion speed, vibration and axial rotation to the needletissue interaction force and, subsequently, to its deflection.Furthermore, axial needle rotation and vibration can be used for minimizing needle deflection during needle insertion procedures [20,[31][32][33].Incorporation of such parameters naturally requires a dynamic model of flexible needles and not a quasi-static one.Therefore, accounting for the underlying needle dynamics is crucial for the complete characterization of needle insertion and, subsequently, for the development of accurate simulation solutions and precise control algorithms [24].
Due to these limitations, it is necessary to develop modelling methodologies that incorporate the underlying needle dynamics.Khadem et al. [14] proposed a novel dynamic model of a rigid/flexible 2D needle based on the Rayleigh-Ritz approximation technique and the linear Euler-Bernoulli beam theory.This work was one of the first to introduce the importance of dynamic modelling in needle insertion procedures, but it had significant limitations due to modelling assumptions, such as the beam's linearity and unmodelled torsional dynamics.In the study by Martsopoulos et al. [34], both the Rayleigh-Ritz and the FEM approaches were employed for capturing the threedimensional dynamics of a rigid/flexible model of brachytherapy needles.However, the proposed models were based on infinitesimal strain theory and, thus, they did not account for geometric nonlinearities and large needle deflections.Similarly, Haddadi and Hashtrudi-Zaad [24] extended the static angular spring FEM approach of Goksel et al. [8]: the model captured the dynamics of needle insertion, while accounting for geometric nonlinearities due to large deflection, but it was only limited to 2D applications.

Contributions
Extending the work of Khadem et al. [14,24], Haddadi and Hashtrudi-Zaad [] and Martsopoulos et al. [34], this paper develops and compares two different modelling approaches that aim to provide a complete characterization of the three-dimensional dynamics of flexible medical needles.For this, we employ the theory of flexible multibody dynamics (FMD), as it provides a plethora of computational tools that allow a systematic characterization of the needle's spatio-temporal behaviour, under arbitrary driving constraints and loading conditions.The two formulations are examined based on three criteria: accuracy, computational efficiency and suitability to provide robust and stable solutions for the particular properties of the examined system (e.g.properties of numerical stiffness and shear locking due to the thinness of the needle are considered).The proposed methods are derived and solved using a systematic approach that allows direct comparisons to be performed.Special attention is paid to the computational efficiency of the methods, with the development of efficient solution strategies and numerical integration schemes, while concurrent execution and parallel programming concepts are also considered.Three simulation scenarios are developed and compared with commercial software solutions.
To the best of the authors' knowledge, this is the first work to investigate and employ the theory of FMD for modelling the dynamics of flexible medical needles, and to provide a systematic comparison among different modelling techniques, while accounting for the challenges that are unique to needle insertion procedures.It is also the first to investigate both large rigid body motion of the needle's base and large needle's deflections and relax the modelling assumptions of previous research works (e.g.linearity assumptions, unmodelled dynamics, 2D models).Furthermore, to the best of the authors' knowledge, this work is the first to apply the DDM and RFEM methods for modelling the dynamics of flexible needles.Even though approaches similar to the RFEM method have been used by Goksel et al. [8] and Haddadi and Hashtrudi-Zaa [24], there was no explicit reference to the RFEM.Instead, in both cases, the authors proposed the modelling of a flexible needle with a set of rigid bodies interconnected with angular springs.The meshing methodology of the RFEM was not taken into account, while the parameters of the angular springs were based on experimental data and not on the theory of continuum mechanics, as proposed by Wittbrodt et al. [35].Furthermore, contrary to the RFEM, the springs had only rotational and no translational degrees of freedom.
We believe that this work provides a well-rounded modelling approach without the need for any simplifications that compromise the overall accuracy of the system.Our aim is that the flexibility that this model provides will be used for finding further correlations between the movement of the needle's base and the forces acting on it during its interaction with the soft tissue.Furthermore, we hope that the computational efficiency of this model will allow its integration with needle-tissue interaction models and the derivation of model-based control algorithms for automating needle insertion procedures.

Medical needles and flexible multibody dynamics
This section provides an overview of different FMD formulations and presents some essential considerations for choosing the appropriate approach for modelling the dynamics of flexible medical needles.Shabana [36] a detailed review of available techniques of FMD systems theory is presented.The key difference between the methods lies in the selection of the generalized coordinates and the associated coordinate frames that are chosen to describe the system's configuration.This allows the separation of the available formulations into two main categories: the local and the absolute frame approaches [37].
In the local frame approaches, the deformation field of a flexible body is described with the help of nodal coordinates that are measured with respect to some local frame of reference, while its rigid body motion is defined based on the inertial description of the frame's position and orientation.Some of the most widely used local frame approaches are the floating frame of reference (FFR), the convected coordinate system (CCS) and the large rotation vector (LRV) [36].As discussed by Shabana [36], the CCS formulation results in inexact modelling of the rigid body dynamics of flexible structures, while the LRV formulation leads to numerical singularities and locking problems when analysing slender flexible bodies, such as the ones considered in this application.
In the majority of the research in the literature, the FFR formulation is combined with classical linear finite-element methodologies or other linear implementations of the assumed modes method, such as the Rayleigh-Ritz or the Galerkin's methods.Even though these approaches allow the description of arbitrarily large rigid body motions, they are only valid when small deformations of the flexible components are considered [38, pp. 309].To address this, there have been various studies on the combination of the FFR formulation with the finite strain theory, to allow the analysis of geometric nonlinearities and large deflections [39][40][41][42][43].The nonlinearity is added to the system with the addition of the higher-order terms on the flexible body's elastic potential energy.Even though this methodology allows the straightforward incorporation of the system's geometric nonlinearity and a computationally efficient solution, it suffers from the numerical problem of element locking, as described by Reddy [44].While numerical remedies have been proposed to address this problem, such as the reduced-order Gaussian integration [45, pp. 279-280], due to their heuristic nature, they introduce uncertainty to the problem and, thus, are not considered in our work.
To allow the description of both large rigid body motion and large deformation, a new set of methods, known as absolute frame approaches, were developed [36].Using these techniques, the pose and the deformation field of a flexible body is described using inertially defined nodal coordinates.The most widely used technique of this category is the absolute nodal coordinate formulation (ANCF), proposed by Shabana [46].For beam elements, the choice of nodal coordinates in ANCF relaxes the assumptions of Euler-Bernoulli and Timoshenko beam theories and allows large deflections and cross-sectional deformations to be considered [47].While the method requires a larger number of generalized coordinates and leads to highly nonlinear expressions for the system's generalized elastic forces, it results in a constant mass matrix which significantly simplifies the associated equations of motion and accelerates computations [48].
Whilst ANCF seems to meet the requirements of flexible needle modelling, as defined in Section 1, the method has reportedly led to significant numerical and convergence problems when dealing with thin and stiff structures, such as the ones considered in our work [49][50][51].This phenomenon, known as Poisson locking, stems from the coupling between the high-frequency cross-sectional deformation modes (found in thin and stiff elements) and the other deformations (e.g.axial and bending) [49].To address this, different approaches have been proposed in the literature, such as the development of higher-order thin elements [52], the uncoupling between the shear deformation and antisymmetric bending [50] and the redefinition of the system's degrees of freedom (DOFs) [53].While some of the proposed techniques have the potential to alleviate the problem of Poisson locking, they introduce additional modelling complexity [50] or remove the initial benefits of the ANCF, such as the formulations of Gruber et al. [53] and von Dombrowski [54] that lead to a non-constant mass matrix.
As an alternative to the ANCF, our work proposes the modelling of flexible needles with the use of the discrete deformation mode (DDM) formulation, presented by Jonker and Meijaard [55].A comparative analysis between DDM and a modified (locking-free) version of ANCF in the study by Schwab and Meijaard [50] shows that the DDM (which also belongs to the family of the absolute frame approaches) allows for an accurate and computationally efficient description of large reference motion and deformation of thin flexible elements without introducing further modelling complexity.Furthermore, we also propose the modelling of flexible medical needles with the help of the rigid finite element method (RFEM).This technique, which also belongs to the absolute frame approaches, is well suited for the current application, as it has successfully been applied for capturing the nonlinear dynamics of slender structures [56,57] without leading to the aforementioned numerical problems.
The importance of modelling both large rigid body motion and large needle deformation for prostate biopsy and brachytherapy procedures can be clarified with the help of Figure 1.In these procedures, and especially LATP biopsies that use a precision point transperineal access system [58], the surgeon's hand performs large rigid body motions in order to guide the needle in the desired location.As illustrated in Figure 1, this can cause significant overall needle deflections, while needle deflections inside the tissue could still remain small.
As a result, it is crucial to provide a mathematical model that captures both large rigid body motion and large needle deflections.The reason for this is twofold: • One of the possible applications of a high-fidelity needle model is the development of haptic simulators for training junior surgeons in LATP biopsies.It is, thus, important to provide a mathematical model that captures the dynamics of the needle insertion in its entirety without introducing any limiting assumptions.This would give trainees the ability to test even the 'extreme' regions of their input space as they would do in a real training environment.
• A highly accurate dynamic model of needle insertion can provide insights into the identification of needle-tissue interaction forces, as it captures the correlations between the needle's state (deflection) and the imposed trajectory at its base.Introduction of modelling assumptions, such as the quasi-static needle insertion or small needle deflections, does not allow the investigation of these correlations, as they restrict the system's input and state space.Thus, to understand the real dynamics of needle insertion procedures, it is critical to remove these assumptions and investigate the true correlation between input (imposed trajectory) and output (deflection/forces).By improving our understanding of these correlations, there is the potential to build improved algorithms for robot-assisted needle insertion procedures (e.g. by building better model-based control algorithms).

Needle-tissue interaction
This section analyses existing needle-tissue interaction models and formulations.As discussed by Rossa and Tavakoli [59], during needle insertion the deformed needle shaft compresses the surrounding tissue which, in turn, applies forces to the former influencing its deflection.As a result, needle deflection and tissue deformation are coupled effects that influence each other [59].
There are two main approaches for identifying these interactions, which, in this work, are referred to as constrained and unconstrained approaches.In the constrained approach, the needle and tissue are studied as a unified system.Needle-tissue interactions are imposed as kinematic constraints between the two mediums, and the system's equations for both the needle and tissue are solved simultaneously [22,60,61].The reaction forces between the two bodies are then obtained with the help of LaGrange multipliers.However, this approach presents some shortcomings.First, in cases where the tissue is modelled with the help of FEM, this technique requires that the tissue mesh is adapted at each time step to match the discretization of the needle and allow the enforcement of the kinematic constraints on the corresponding nodes of the tissue and the ones of the needle [22].The computational cost of this remeshing makes the application of this technique unsuitable for interactive applications.One possible solution is using a meshless discretization, as in the study by Xu et al. [62], or using the technique of local constraints presented by Wang and Hirai [63].Second, the model requires knowledge of the exact mechanical properties of the tissue on its interface with the needle.However, monitoring the medium's properties on this interface is not usually plausible or applicable in real-time applications or in vivo tests [64].Finally, coupling the two flexible mediums leads to a high-dimensional set of equations that is challenging to solve in real-time.
In the unconstrained approach, the needle-tissue interaction is modelled with the help of interface force models.These forces, which are functions of both the needle's and tissue's state, are imposed simultaneously but separately on the tissue and the needle, allowing the mathematical decoupling of the two.Furthermore, these models are dependent on a small number of parameters.The unconstrained modelling method is quite popular as it is both simple and computationally efficient, allowing its application to interactive surgery simulation and control.However, it suffers from limited accuracy as the identification of these force profiles is usually based on semi-empirical approaches and experimental observations.A plausible remedy to this is the use of online system identification algorithms for the tuning the model's parameters [65].
One of the most widely used unconstrained models is the one proposed by Okamura et al. [1].Experimental studies reported in the study Okamura et al. [1] showed that the axial forces acting on the needle's base are the summation of stiffness, friction and cutting forces.These forces depend on the relative state (position and velocity) of the tissue and the needle and are distributed along the needle's shaft.Since the work of Okamura et al. [1], significant research has been devoted to the definition of mathematical models that can accurately capture these force profiles.For example, whilst Okamura et al. [1] proposed a modified Karnopp friction model, different friction modelling approaches were then adopted by Asadian et al. [66] and Yang et al. [67].Similar, simplified interaction force models have been developed for modelling the distributed lateral loads acting on the needle's shaft as is inserted inside the tissue.The most popular approach is modelling the lateral tissue forces as virtual springs (both linear and nonlinear) of varying mechanical properties, similar to the Winkler foundation model [19,[68][69][70].
This section provided an overview of existing modelling approaches in needle-tissue interaction.In Section 2, we develop mathematical needle models based on two formulations [a)] the DDM (Section 2.1) and the RFEM (Section 2.2).A simulation algorithm for obtaining the needle's state is analysed in Section 2.3 while needle-tissue interaction models are formulated in Section 2.4.Real-time considerations are discussed in Section 2.5.Section 3 presents the results from three different simulation scenarios, the interpretation of which is provided in Section 4. Concluding remarks are given in Section 5.

Materials and methods
In this work, we focus on moderately flexible medical needles, such as those used in prostate brachytherapy and local anaesthetic transperineal prostate (LATP) biopsy, shown in Figure 2. We propose a model, shown in Figure 2, that considers a) the base of the needle as a rigid body that follows any arbitrary spatial trajectory, imposed by a surgeon or a robotic arm, and the shaft of the needle as a flexible body that is rigidly attached to the base and deforms elastically under a general state/time-dependent field of forces, which corresponds to the interactions between the needle and the surrounding tissue.
To describe the motion of the system shown in Figure 2, we introduce the following frames of reference: let F be the inertial frame of reference and f c a frame rigidly attached to the rigid body's centre of mass C. Furthermore, we introduce a floating frame of reference (FFR) f which is rigidly attached to point A of the rigid body.As shown in Figure 2, the orientation of the frames f c and f is identical and fixed, i.e. there is no relative motion between them.
In the following formulations, the needle is considered as a slender and homogeneous beam with circular cross-section and constant mechanical and geometrical properties along its span.The material of the needle is isotropic and linear.Furthermore, we introduce the notation r f 2 AP=f 1 which describes the position of a vector AP � with respect to frame f 1 expressed in frame f 2 [71, pp. 13-16].The following sections present the kinematic and dynamic description of the aforementioned needle model based on the two proposed FMD formulations, namely, the DDM and the RFEM approaches.In both approaches, we first introduce the kinematic description of the model and then derive expressions for the virtual works of the forces acting on the structure.Next, using D'Alembert's form of the principle of virtual work, we express the dynamic equilibrium of the system and derive the equations of motions.These steps are thoroughly presented in Sections 2.1 and 2.2.

Kinematic description
The DDM method employs a spatial discretization of the needle's geometry into n e beam elements, each of which is described using inertially measured nodal coordinates.More specifically, as shown in Figure 3, a complete characterization of the configuration of the beam element jP½1; n e � can be acquired based on the inertially measured cross-sectional position and orientation at its nodes A j and B j , while intermediate points are defined with the help of interpolation functions.The element's vector of generalized coordinates can be defined as where r A j ¼ r F OA j =F and r B j ¼ r F OB j =F are the inertial positions of the nodal cross-sections' midpoints A j and B j , while θ A j and θ B j are the Euler angles, based on the sequence of intrinsic rotations z 0 -y 0 -x 00 , that define the cross-sectional orientation at nodes A j and B j .These are defined as With the help of the Euler angles θ A j and θ B j , the set of triad unit vectors, shown in Figure 3, are defined as with r ¼ fx; y; zg and D ¼ fA; Bg: describe the orientation of the local frames f A j and f B j with respect to the inertial frame of reference F. The e z B j are constant unit vectors pointing in the associated directions x; y and z.The inertial position of point P j of element j, illustrated in Figure 3, can be obtained with the help of the generalized element coordinates and interpolation functions Expressions for the � i ðx j Þ; i ¼ f1; . . .4g, can be chosen as in the study by Jonker and Meijaard [55], while the scalar x j is the point's distance along the element's elastic line measured using the co-rotational frame introduced by Jonker and Meijaard [55].Based on equation ( 2), the inertial velocity of point P j can be expressed as where The matrices G A j ¼ Gðθ A j Þ and G B j ¼ Gðθ B j Þ in the above expression map the derivatives of the Euler angles _ θ A j and _ θ B j to the respective frame rotational velocities, such that Based on equation (3) the inertial virtual displacement of point P j is given as while the acceleration of point P j takes the form In the above expression, the Coriolis/centrifugal component of acceleration is given as where Similarly, the orientation of the cross-sections along the element's length can be written as where expressions for the interpolation vector functions s � � ðx j Þ, s� θ ðx j Þ and s � ψ ðx j Þ can be found in the study by Schwab and Meijaard [50].If the mapping from the nodal components of the Euler angles to the generalized element's coordinates is defined as � r j ¼ L � r e j , with r ¼ f�; θ; ψg, then the above expressions take the form

Virtual work
Next, we derive the virtual work of the inertial forces of element j.To simplify the associated expressions, it is assumed that the inertial forces caused by the transversal shear deformation of the element's cross-section are negligible due to the needle's thickness.Based on this assumption, the virtual work of the inertial forces of element j can be defined as where m f j is the mass, l ej the length, I p j the polar moment of area and ρ the density of element j.The second term of the above equations employs the first component of the sequence of Euler angles � j to describe the inertial forces due to the element's torsional dynamics.Using equations ( 4), ( 5) and ( 6), the above expression can be rewritten as where The mass matrices M t f j and M r f j are defined as The generalized Coriolis/centrifugal vector takes the form The key component of the DDM method is the deformation modes, which provide a complete characterization of the beam element's deformation field.These modes can be specified using six independent generalized strain expressions, which are functions of the element's inertially defined generalized coordinates [72].The generalized strains, which remain invariant under arbitrary rigid body motions and orthogonal coordinate transformations [72], take the form where � l j ¼k r B j À r A j k and e j l ¼ ðr B j À r A j Þ= � l j .In equation ( 8), the generalized strain � � 1 j ; is used to describe the beam's axial elongation, � � 2 j is for torsion, while � � 3 j ; . . .; � � 6 j describe transversal bending.To account for geometric nonlinearities, second-order terms can be added in (8).The modified second-order generalized strains can be calculated as where expressions for the function ωð� � j ðe j ÞÞ, which incorporates the second-order terms, and the function η j ðe j Þ, which maps the generalized coordinates to generalized strain measures, are given by Jonker and Meijaard [55].Furthermore, if it is assumed that the beam has been divided into a sufficient number of elements so that the strains remain small, then the generalized strains can be associated with the generalized stresses (Voigt notation) using the constitutive law written as [50] σ j ¼ S j � j ; (10) where S j is the element's constant symmetric stiffness matrix, defined by Schwab and Meijaard [50].Based on equation ( 9), the infinitesimal change of the generalized strains can be calculated as With the help of equations ( 9), ( 10) and ( 11), the virtual work of the element's elastic forces can be written as Similarly, the virtual work of the element's damping forces can be written as , where the generalized damping forces Q d j can be modelled using various approaches, as discussed by Yoo et al. [73].
Next, we define the virtual work for the external forces.For this, it is assumed that a random point P i j of element j, located at the beam's elastic line and at a distance x i j from the nodal point A j , is subjected to a point force j F F i ðt; e j ; _ e j Þ and a point moment j M F i ðt; e j ; _ e j Þ, shown in Figure 4a.Then, the virtual work resulting from these forces and moments can be written as Using equations ( 4) and ( 6), the above expression takes the form where The virtual work of the external generalized forces presented in equation ( 13) can be extended to accommodate for n f point forces and n m point moments.In this case, it can be proven that the total virtual work of the external generalized forces is given as Finally, the virtual work of the external generalized constraint forces for element j can be calculated as δW MATHEMATICAL AND COMPUTER MODELLING OF DYNAMICAL SYSTEMS

Dynamic equilibrium
To derive the flexible needle's equations of motion we apply the dynamic equilibrium expression based on D'Alembert's form of the principle of virtual work, which can be written as The virtual works of the above expression can be calculated considering the contributions from the individual elements as Substituting the derived virtual work expressions, the above equation becomes If we introduce the mapping from the local generalized coordinates e j of element j to the flexible beam global generalized coordinates � q, such that e j ¼ L j � q, then the above expression can be written as with Due to the explicit integration of the constraint forces Q c in the above expression, the generalized coordinates of the flexible body can be treated as independent and, thus, its equations of motion can be expressed as

Kinematic description
The main idea of the RFEM method is replacing flexible bodies with a system of rigid finite elements (rfes) that are interconnected via spatial spring-damping elements (sdes) [35, pp. 35].The first step towards describing the kinematics of the proposed method is the division of the flexible body into rfes and sdes.This division can be performed in two stages [35, pp. 37-40].First, the flexible body is divided into n elements, each of which has a length �l ¼ L=n, where L is the needle's total length.The sdes are added at the centre point of the initial elements, as shown in Figure 5.In the secondary division, the initial elements are divided again, so that their edge points are interconnected by the sdes.As shown in Figure 5, intermediate rfes have now length equal to �L, while the first and last rfe have a length of �L=2.The configuration of the flexible body can now be described with the help of the resulting n e rfes.For this, we consider the rfe jP½1; n e � shown in Figure 6.Due to the rigidity assumption, the configuration of the rfe j can be completely characterized with the help of the body frame f j , which is rigidly attached to the element's centre of mass C j shown in Figure 6.More specifically, the inertial position of an arbitrary point P j of element j is given as where r F OC j =F is the origin of frame f j measured in the inertial frame F and R F f j ðθ j Þ the rotation matrix that describes the orientation of frame f j with respect to F. As before, the rotation matrix is parameterized using the set of Euler angles θ j that describe the sequence of intrinsic rotations z 0 -y 0 -x 00 .It should be noted that, due to the rigidity assumption and contrary to the DDM method, the distance r f j C j P j =f j is constant.Thus, a complete characterization of the rfe j configuration can be obtained using the generalized coordinates Based on expression (18), the inertial velocity of point P j is given as The matrix G j ¼ Gðθ j Þ maps the derivatives of the Euler angles _ θ j to the rotational velocity of frame f j , such that Similarly, the inertial acceleration of point P j can be defined as where Furthermore, based on equations ( 18) and ( 20), the inertial virtual displacement of point P j can be written as @e j δe j ¼ Z j ðx j ; e j Þδe j : (22)

Virtual work
Similarly to Section 2.1.2,the virtual work of the inertial forces can be defined as  δW which, using equations ( 21) and ( 22), leads to with The key component of the RFEM is the definition of the elastic forces that act on each rfe.As shown in Figure 7, the rfe j is subject to the elastic forces F e j ; F e jþ1 and the elastic moments M e j ; M e jþ1 due to the deformation of the associated sdes s j and s jþ1 .Based on Figure 7, these forces and moments can be modelled as [56] V The indices el and d refer to spring and damping forces/moments, respectively.These can be modelled as In the above expression, vectors r r j and r l j denote the translational deformation of the sdes s j and s jþ1 respectively, and can be written as Similarly, the elastic moments in equation ( 24) are modelled based on the rotational deformations of the associated sdes s j and s jþ1 , denoted as θ l j and θ r j .Due to the noncommutative property of Euler angles, these can be extracted from the rotation matrices f jþ1 ðθ r j Þ accordingly.From the expression above, the element's generalized elastic forces are nonlinear functions of the system's generalized coordinates.As a result, if these expressions are treated as forces external to the element j, then the virtual work caused by the generalized elastic and damping forces can be written as δW ðelÞ f j ¼ Q T el j δe j and δW ðdÞ where The locator matrix L θ in the above expression maps the element's Euler angles to the element's generalized coordinates such that θ j ¼ L θ e j .Next, the virtual work of the external forces is defined.For this, we consider the point P i j of element j, located at the position defined by the vector x i j with respect to frame f j , which is subject to the point force and point moment pair illustrated in Figure 4b.Then, as illustrated in Section 2.1.2,the virtual work resulting from these forces and moments can be written as Using equation ( 22) and the matrix L θ , the above expression can be written as where Z i j ¼ Zðx i j ; e j Þ.If we consider that the element j is subject to n f point forces and n m point moments, it can be shown that the total virtual work of the external generalized forces is given as

Dynamic equilibrium
The procedure for deriving the equations of motion for the flexible beam is identical to the one presented in Section 2.1.3.First, we define the mapping from element's j local generalized coordinates e j to the beam's global generalized coordinates � q as e j ¼ L j � q.Then, following the steps of Section 2.1.3,it can be shown that the equations of motion of the flexible beam using the RFEM method take the form where the mass matrix and the generalized force vectors can be calculated as in (16).

Simulation algorithm
As illustrated in the previous sections, the two proposed approaches lead to the same set of equations, given in ( 17) and ( 28).This allows the development of a common solution strategy, independent of the method used, as well as the implementation of direct comparisons between them.To provide a more compact form of the above equations we define the vector Then, equations ( 17) and ( 28) can be rewritten as As stated in Section 1, the aim of the solution algorithm is to provide an accurate and computationally efficient description of the needle's three-dimensional dynamics, as the rigid base's centre of mass C follows an arbitrary trajectory imposed by the surgeon's hand or a robotic gripper (driving constraints).Furthermore, the solution algorithm should describe the profiles of the reaction forces F C and moments M C , illustrated in Figure 8, that result from the combined effect of the structure's rigid body motion and vibration.The following sections provide a detailed description of the process for deriving the required solution.

Boundary conditions
Before the proposed algorithm is formulated, some important remarks for equation ( 29) must be made.More specifically, it should be noted that the state vector � q contains the boundary conditions, due to the rigid connection between the flexible needle and the rigid base, as shown in Figure 8.To eliminate the boundary conditions, the state vector � q can be partitioned in the constrained q c PR n c and active q a PR n a coordinates such that The constrained vector q c incorporates the prescribed motion of the associated coordinates (boundary conditions), while the active vector q a describes the free (independent) coordinates that define the beam's motion.Depending on the chosen FMD technique and according to the different sets of generalized coordinates defined in (1) and ( 19), the constrained vector q c can take one of the following forms: If r F OC=F ðtÞ and θðtÞ are known functions, with continuous second derivatives, that describe the position and orientation of frame f c (pose of surgeon's hand or robotic gripper) with respect to the inertial frame of reference F, then, from the above expression and according to Figure 8, it follows that the constrained vector q c is also a known vector function.Furthermore, it follows that the linear and rotational velocity and acceleration of the constrained coordinates can be obtained.

Recursive Newton-Euler method
A widely used approach for solving the equations ( 29) while simultaneously obtaining the generalized reaction forces F C and moments M C profiles is the explicit incorporation of the system's kinematic constraints through the use of the LaGrange multipliers [74, pp. 323-349].While this technique has been widely employed in the FMD literature for solving systems of interconnected bodies, it leads to a higher-dimensional system of coupled differential and algebraic equations, the solution of which requires special numerical treatment that increases the computational complexity.
Taking advantage of the specific properties of the needle insertion application, our work presents an alternative approach that can accelerate the solution of (29), while obtaining the required generalized reaction force profiles.More specifically, as the examined system is only under two sets of kinematic constraints, i.e. [a)] the connection of the flexible needle to the rigid base at point A (Figure 8) and the driving constraints at the base's centre of mass C, it allows the efficient implementation of the generalized recursive Newton-Euler method [75], which can lead to accelerated solutions for a low number of kinematic constraints.
To implement the proposed algorithm, the equations of motion (29), based on the partitioning of (30), can be rewritten as where Note, the components of the vector g ¼ ½g T c ; g T a � T are all known, except for the generalized constrained forces Q c .The key idea for obtaining the system's solution is that the components of the constraint forces corresponding to the active system's coordinates are zero, Q c a ¼ 0 n a .On the other hand, the components Q c c , which result from the reaction forces due to the boundary conditions at point A, are finite and incorporate information about the connection forces F A and moments M A (Figure 8).Based on this observation, equation ( 31) can be written as As the right-hand side of the above equation is known, the equation can be integrated numerically to identify the time evolution of the generalized active coordinates q a .Given that both the constrained and active coordinates are now known, the constrained components of the reaction forces are calculated for the current time step as Based on the above equation, the reaction forces F f C and moments M f C can be calculated with the help of the equations of motion of the rigid base.These can be written as where m r is the rigid body's mass, I f c c its inertial tensor defined in the frame f c and vector α f f =F the rotational acceleration of frame f or f c , with respect to the inertial frame of reference.From the above equations and Figure 8, the generalized reaction forces that act on the needle's base are and The connection forces F A and moments M A in the above expression are derived based on generalized constraint forces of (32).

Needle-tissue interaction forces
As discussed in Section 1.4, needle-tissue interaction is modelled with either constrained methods, by imposing kinematic constraints between the needle and its surrounding medium, or with unconstrained methods, through the development of needle-tissue interaction force models.Our work is independent of the needle-tissue modelling approach and can be combined with either the constrained or the unconstrained method.However, as discussed in Section 1.4, the constrained approach is highly dependent on the tissue modelling and discretization.Thus, to maintain the general nature of the proposed needle model, we will only study the unconstrained approach.Furthermore, we will only focus on the RFEM formulation, but a similar approach can be used for the DDM method.First, we consider the last RFEM element n e , illustrated in Figure 9, which incorporates the needle's bevel tip.Based on the same figure, we define the needle's tip point S t as with l n e the element's length and r n the needle's radius.Similarly, the position of the needle's tip surface centroid N t can be defined with the help of similar triangles as l n e À l n c 0 0 As discussed in Section 1.4, the axial forces acting on the needle can be decomposed as a summation of a cutting/stiffness force acting on the needle's tip and a friction force distributed along the needle's shaft.The stiffness forces are due to the elastic properties of the tissue and occur right before the tissue/capsule puncture.On the other hand, friction and cutting forces occur after the puncture event.
In our work, both cutting and stiffness forces are modelled as point loads acting on the needle's tip.We assume that the stiffness force is applied at the needle's tip point S t and it remains parallel to the element's local axis x e , as shown in Figure 10a.The cutting force is assumed to be normal to the needle's bevel surface and is applied at its centroid N t [68], as illustrated in Figure 10b.
From the above figures, we can define the stiffness F s and cutting F c forces expressed in the local element frame f e as F s f ne ð� q; _ � qÞ ¼ À F s ð� q; _ � qÞ 0 0 Friction forces are distributed along the needle's shaft as it slides inside the tissue postpuncture.During the needle insertion, the needle's shaft is also under the influence of distributed lateral forces due to the tissue compression.Both friction and lateral forces, illustrated in Figure .11, can be considered as traction vectors acting on the needle's surface and can be analysed with the help the needle's tangent plane.More specifically, we first consider the rfe j, shown in Figure 12.Furthermore, we consider an arbitrary point P j that belongs to the surface of the rfe j.The position of the point with respect to the element's local frame f j can be expressed with the help of cylindrical coordinates as where x j is the distance of the point P j along the x f j axis of element j, illustrated in Figure 12, r is the radius of the needle (or that of the element rfe j) and a j is the complementary polar angle illustrated in the same Figure.
Equation (34) is the parametric equation of the surface S j of the element j.The surface is a function of two parameters, namely, the longitudinal distance x j and the angle α j .Using this parametric equation we can define the tangents and normals of the surface.More specifically, the unit vectors n p j and t p j at the point P j shown in Figure 12 are defined as: The unit vector b f j p j at the point P j is defined as Note that vectors t f j p j , n f j p j and b f j p j are defined with respect to the element j frame f j .Finally, observing Figure 12, we can define the infinitesimal surface dS j as dS j ¼ rdα j dx j : To model the traction acting on the needle's surface, we examine the rfe j shown in Figure 13.First, we assume that a mean traction vector Fq j acts on the point P j and it is  transmitted across an infinitesimal area dS j .As shown in Figure 13, this traction vector can be divided into three components, each of which points in the directions defined by the tangent and normal vectors t f j p j , n f j p j and b f j p j .These components represent the distributed contact forces between the needle and the tissue as a result of their relative motion.More specifically, the traction Ff j represents the axial friction due to the longitudinal motion of the element, the traction Fb j represents the rotational friction due to the needle's axial rotation and the traction Fn j represents the lateral resistance due to tissue displacement/compression.Based on Figure 13 and the definition of the tangent and normal surface vectors of element j, we can define the mean traction vector F q j transmitted across the infinitesimal area dS j as  Ff j q j ð� q; _ � q; x j ; α j Þ ¼ À Ff j ð� q; _ � q; x j ; α j Þt p j f j ðx j ; α j Þ À Fn j ð� q; _ � q; x j ; The definition of the mean traction vector transmitted across the infinitesimal area dS j allows the calculation of the total surface force acting on the element j.This is given by integrating over the entire surface S j of the element j Ff j q j ð� q; _ � q; x j ; x l j ð 2π 0 Ff j q j ð� q; _ � q; x j ; α j Þr dα j dx j (36) where x l j and x u j are the lower and upper integration limits for the longitudinal distance of the element j.These values depend on the percentage of the element that is in contact with the tissue.Combining equations ( 35) and ( 36) the total surface force on element j is given as x l j ð 2π 0 Fn j ð� q; _ � q; x j ; α j Þn p j f j ðx j ; α j Þ dα j dx j (38) and x l j ð 2π 0 Fb j ð� q; _ � q; x j ; α j Þb p j f j ðx j ; α j Þdα j dx j : ( Equations ( 33), ( 37), ( 38) and ( 39) can provide a full characterization of the needle-tissue interaction.These can be included in the RFEM needle model, using equation (27).To provide a complete characterization, however, it is essential to define expressions for the functions of stiffness, cutting, axial friction, rotational friction and lateral compression forces.
As discussed in Section 1.4, there is no unique modelling approach for characterizing these forces.For example, in the study by Okamura et al. [1], cutting forces were modelled as constant, while Elgezua et al. [76] proposed a quadratic cutting force model.Similarly, there are various formulations for the distributed loads.For example, friction forces in the study by Okamura et al. [1] were assumed to be uniformly defined over the needle's length ( Ff j ð� q; _ � q; x j ; α j Þ ¼ Ff j ð� q; _ � qÞ) with a magnitude characterized by the modified Karnopp model.Other models, such as the LuGre friction model, have also been proposed [66].Applying a uniformly distributed Karnopp model for the friction forces of the element j in (37) leads to with Ff j ð� q; _ � qÞ defined by Okamura et al. [1].A similar expression can be derived for the rotational friction and lateral tissue resistance of equations ( 39) and (38).For complex distributed load expressions, the surface traction integrals can be computed numerically (e.g. through Gaussian quadrature) and applied as equivalent point loads on the RFEM elements.
This Section provided some guidelines regarding the integration of the proposed needle model with unconstrained needle-tissue interaction forces.However, characterizing the needle-tissue interaction forces is beyond the scope of this work.This preserves the general nature of our work and allows the reader to develop and integrate their own needle-tissue interaction models.

Real-time considerations
As discussed in Section 1, one of the key aims of our work is to provide both highly accurate and computationally efficient mathematical models that allow real-time execution.In this regard, except for the solution strategy presented above, which has been tailored to the requirements of the application to maximize computational efficiency, our work considers three more modelling and implementation aspects that contribute to the acceleration of the overall system's performance.
The first strategy takes advantage of the structure's geometry to decrease the computational complexity of the solution.More specifically, our work only considers beam finite elements for modelling the dynamics of flexible medical needles.The reason for this is twofold.First, beam elements have been specifically designed to tackle the particularities of beam-like structures, such as a biopsy needle and, thus, are expected to have superior performance when compared to generic finite elements, such as tetrahedrals or hexahedrals [8].Second, while 3D beam elements and tetrahedral elements might have the same number of nodal coordinates, tetrahedral-based meshes require the use of a significantly higher number of elements for covering the needle's geometry.Furthermore, the requirement for mesh symmetry leads to a further increase in the number of required tetrahedral elements, while the employed beam elements are inherently symmetric [8].Thus, by considering only beam elements, our work aims to minimize the required computational complexity and accelerate the model's solution.
The second strategy aims to tackle the numerical particularities of the problem.More specifically, due to the thinness of the examined structure, the needle's axial and torsional stiffness is significantly higher than that in the transversal directions.This leads to a high ratio in the eigenvalues of the Jacobian J f ¼ @f =@� q of the vector function f in equation ( 29) and, subsequently, to a significant deviation between the response time scales of the � q vector components.This phenomenon, known as differential equation stiffness, creates significant numerical problems and needs special treatment.
In our work, different approaches have been considered for tackling the stiffness of the differential equations ( 29), while allowing real-time execution.This includes the analysis of explicit, implicit, semi-implicit and multistep numerical integration approaches.Explicit integration techniques are not suitable for stiff differential equations as they lead to solution instability, unless an extremely small integration step size is chosen (which significantly increases the computational time) [77].On the other hand, implicit integration techniques can guarantee stability without the need for extremely small step sizes, at the cost of solving a set of nonlinear algebraic equations at each time step.To cover the numerical requirements of all of the proposed methods, our work employs diagonally implicit Runge-Kutta methods with an inner Newton-Raphson algorithm parallelized in multiple processing cores for improved performance.This technique leads to stable solutions and real-time execution.As will be discussed in Section 4, the numerical properties of the RFEM method also allowed the use of Rosenbrock-Type methods (or linearly implicit Runge-Kutta methods) [77] leading to accuracy, stability and even further computational efficiency.
The third strategy stems from the concurrency that characterizes the proposed algorithms.More specifically, both the DDM and the RFEM methods include concurrent components that can be executed in parallel allowing for a significant improvement in the overall computational efficiency.Examples of these components are the generalized forces and mass properties that can be calculated independently among the different elements.By exposing the concurrency of the proposed algorithms and employing multithreading execution techniques, the integration time of Eq. ( 29) was significantly accelerated.

Results
To demonstrate the performance of the proposed algorithms, three numerical examples are presented in this section.These were designed to give insight into the accuracy and computational efficiency of the proposed methods for both the static and dynamic analysis of the system, while aspects of linear and nonlinear deflection were also considered.
For the validation of the proposed methods, the simulation scenarios were also solved with the help of commercial simulation software.More specifically, the Ansys software was used for the static analysis of the needle's deflection, while dynamic simulations were performed with the help of MSC Adams.The simulations were implemented on a 4-core Intel® Core™ i7-7700HQ CPU running at 2.80 GHz, using the C++ Armadillo library [78] with the Intel Math Kernel Library (MKL) integration.Aspects of algorithmic parallelization were implemented with the help of the OpenMP API [79].
The needle's base was treated as a solid cylinder with length l h = 0.153 m, radius r h = 0.017 m and a mass of m h = 0.09 kg.The flexible needle was modelled as a homogeneous stainless steel beam with a circular cross-section of radius r ¼ 0:635mm and a length of L ¼ 0:2623m.Both the mechanical and geometrical properties of the needle were assumed to remain constant along its span.The properties of the system were based on commercially available bevelled tip LATP needles.Next, the three numerical examples are presented.

Steady-state analysis: tip force loading
First, we examine the steady-state deflection of the flexible needle, using the two proposed FMD approaches.The needle's deflection results from a constant point force loading applied at its tip (point B, Figure 2).To analyse the performance of the proposed techniques, we consider three spatial loading conditions: The gradual increment in the loading allows the analysis of the effect of the large needle deflection on the accuracy of the proposed methods.To examine the accuracy of the methods, the problem is also solved using Ansys (both linear and nonlinear solver).Figure 14 shows the transversal y and z deflection for the three tip force loading conditions a, b and c of (40). Figure 15 shows the error measure êðxÞ ¼ ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi where y v and z v correspond to the deflections calculated from the Ansys nonlinear solver.

Transient analysis: step force loading and sinusoidal base movement
Next, we examine the dynamic behaviour of the flexible needle.For this simulation scenario, the needle's rigid base undergoes a sinusoidal motion, while a step force loading is applied at its tip.More specifically, the input driving constraint has the form where aðtÞ ¼ â sinð2πf d tÞ.The excitation magnitude â and frequency f d were arbitrarily chosen as â ¼ 0:2m and f d ¼ 0:5Hz.The external force vector, applied at the needle's tip B, is chosen as The magnitude F B has a value of 0:6 N, while HðtÞ is the Heaviside function.For the simulation results shown in Figure .16(a-d), a spatial discretization of four elements is chosen for both methods.The system's solution using the MSC Adams software acts as a reference point for testing the accuracy of the proposed approaches.
To analyse the convergence, accuracy and computational efficiency of the two methods, the following error metrics and ratios are introduced.First, the error metrics that  define the time-averaged deviation of the tip position êt and the reaction force êf from the MSC Adams results are defined as where n t is the number of points used for the temporal discretization, ω ¼ fRFEM; DDMg and a ¼ fAdamsg.Next, the computational efficiency of the algorithm is determined using the ratio of the algorithm's execution time to the simulated time.Note that a real-time simulation requires that this ratio is less than one (real-time execution line Figure.17).The proposed error metrics and the execution-time-to-realtime ratio, with respect to the number of elements used for the beam's spatial discretization, are illustrated in Figure.17.

Needle-tissue interaction: Winkler foundation model
The final simulation scenario is illustrated in Figure 18.The transversal needle-tissue interactions are modelled with the help of spring-damper elements along the needle's length.This model, which originates from the Winkler foundation modelling approach [80], has been extensively used in the needle insertion literature to provide a simplified  Let T i be an arbitrary point at the flexible needle, which for the undeformed configuration is written as T 0 i .As illustrated in Figure 18, the displacement of the point due to the needle's deflection can be defined as If we assume that the sping-damper forces are only applied in the inertial z direction, as shown in Figure 18, the total force exerted at point T i can be modelled as where r z �T i is the projection of the displacement vector (46) in the inertial z direction, _ r z �T i is the associated velocity component, while k t and c t are the constants of the spring and damper elements, respectively.The proposed Winkler foundation model was solved using both the DDM and the RFEM approaches, as well as MSC Adams.The stiffness constant was chosen as k t ¼ 300:0N=m, based on the values reported by Glozman and Shoham [81], while the damping ratio was chosen as c t ¼ 2:0Ns=m, based on the estimated stiffness-to-damping ratio for soft tissues reported by Khadem et al. [14].It should be noted that these values are used for providing a qualitative approximation of the types of forces that are present during needle insertion procedures and do not aim to provide an accurate tissue model.The distributed loading was approximated with the help of evenly distributed points that spanned half of the needle's length.For this simulation, the needle's rigid base was constrained to follow an arbitrary trajectory  where aðtÞ ¼ â sinð2πf d tÞ, with â ¼ 0:1m and f d ¼ 0:5Hz.The simulation times are indicative of the time required for a single sample acquisition in LATP procedures.The simulation results are illustrated in Fig. 19.

Discussion
The simulation results presented in Section 3 allow for a direct accuracy and efficiency comparison between the different modelling approaches.As shown in Figure 14, linear modelling techniques pose significant limitations for capturing the deflection profile of the flexible needle in the case of large deformations.More specifically, the linear Ansys solver remains valid only for small deformations (Fig. 14a and 15a), while in the case of large needle deflections (Fig. 14b, 15b, 14c and 15c), the linear approach leads to unrealistic and non-volume preserving deflection profiles.On the other hand, as illustrated in the same figures, due to their inherent geometric nonlinearity, both the DDM and the RFEM methods lead to highly accurate deflection profiles even for large needle deformations.This is also illustrated in Figure 15, in which the DMM and the RFEM methods lead to a near-zero value of the performance measure of equation ( 41), while the linear approach leads to significant errors especially for large needle deflections.Due to their poor accuracy, linear solutions were not included in the subsequent investigations.
The second simulation scenario was designed to provide insight into the dynamic behaviour of the proposed modelling approaches.As illustrated in Fig. 16 and 17, both the DDM and RFEM approaches capture the vibrational behaviour of the needle with high accuracy and quickly converge to the desired solution, leading to a close to zero deviation from the MSC Adams simulation results.It should be noted that both the equations of motion and the associated algorithms were structured in an identical way for the two methods, which allowed the implementation of direct efficiency comparisons between them.As shown in Fig. 17, while both methods can be used for acquiring real-time solutions, the DDM method leads to significantly higher execution times compared to the RFEM (for the same accuracy level).More specifically, comparison of the mean error êt in Fig. 17(a) and 17(b) reveals that for the examined simulation the RFEM approach allows real-time execution using a discretization of up to six elements.On the contrary, a real-time simulation using the DDM approach can only be achieved with no more than three elements, resulting in a comparatively lower accuracy of the method.The same observations can be made for the mean error êf illustrated Fig. 17(c) and 17(d).The performance difference between the two methods can be partly attributed to the fact that DDM requires twice the number of DOFs per element than the RFEM.Additionally, it was observed that, during the implicit integration of the equations of motion, the DDM method generally required more iterations of the inner Newton-Raphson for the solution's convergence, especially in the cases where a rigid body motion was imposed on the system.Further analysis of the system revealed that the source of the numerical problems, which led to more iterations, was inherent to the method as a large condition number was observed on the generalized strain Jacobian defined in equation (11).On the other hand, the RFEM method showed superior numerical behaviour allowing fast integration and stable solutions even with the use of semi-implicit integration schemes that can further improve the overall system's performance.Furthermore, the sparse structure of the system's matrices and the property of the RFEM algorithm for destructuring and concurrent execution allowed further optimizations on the system's numerical efficiency.
The third simulation scenario was designed to analyse the effect of complex loading conditions and driving constraints that resemble those encountered during actual needle insertion procedures.As illustrated in Fig. 19, both methods captured the needle dynamics with high accuracy, leading to negligible errors for both the tip position and the reaction force at the surgeon's hand.It should be noted that the performance plots for this simulation scenario followed a similar to the ones presented in Fig. 17.More specifically, both methods allowed real-time execution, with the RFEM outperforming the DDM method in terms of computational efficiency.In both dynamic simulations, the execution-time-to-realtime ratio reported by MSC Adams was close to one.However, as the software does not give the user ability to extract the exact details of the numerical solution, these results have not been reported in Fig. 17.
A systematic investigation of the different FMD modelling approaches reveals that the RFEM method constitutes one of the most optimal candidates for providing robust and accurate solutions for the examined problem.The properties of the RFEM algorithm, combined with the proposed solution strategy (optimized to the particular properties of the problem) allow high computational efficiency and real-time execution capabilities without the need for modelling assumptions that compromise the overall system's accuracy.Furthermore, even though the parametric nature of our models allows its application to a variety of needle insertion procedures, our focus remains on long, slender and moderately flexible needles, such as the ones used in LATP and prostate brachytherapy procedures.
It should be noted that the computational times reported in the previous examples do not take into account the deformation of the surrounding tissue, but they solely refer to the computational effort for capturing the needle's deflection under a generalized force field that quantitatively emulates the one encountered during needle insertion procedures.Ensuring numerical stability and accuracy when modelling soft tissues undergoing large localized strain induced by the needle is the remaining part of the challenge, as tissue modelling is a highly challenging modelling and computational endeavour.The identification of the tissue properties, the proper modelling of fracture and contact dynamics and the treatment of spatial discontinuities during needle insertion constitute open modelling challenges.
However, this work studies the needle's dynamic model and its vibrational behaviour independent of the tissue and their interaction.It does not attempt to solve the whole problem of needle insertion, but it attempts to provide high fidelity models for the needle's dynamics.Such needle models, are invaluable for identifying the properties of needle insertion as the needle can be seen as a filter through which the generalized needle-tissue interaction forces can be measured.

Conclusions
In this paper, we presented two novel three-dimensional dynamic rigid/flexible models of brachytherapy and LATP needles under a general 3D force field.The proposed models were chosen based on a thorough investigation of different FMD methods and their ability to tackle the numerical particularities of thin flexible medical needles.By employing the theory of FMD and incorporating methods that account for geometric nonlinearities, the proposed approaches minimized the need for introducing modelling assumptions that could compromise their performance.They provided a complete characterization of the system's rigid motion and vibrational behaviour for both small and large deformations and allowed the correlation of the system's state with input parameters, such as insertion velocity and needle orientation.
Furthermore, this work presented a novel simulation algorithm, based on the generalized recursive Newton-Euler formulation that characterized and quantified the correlation between the system's inertial and external forces with the generalized reaction forces acting on its base.The proposed algorithm, tailored to the requirements of the specific application, was combined with parallel architecture implementation strategies to allow for computationally efficient solutions and real-time execution.
The models were assessed in terms of accuracy and computational efficiency and their performance was validated with the help of commercial simulation software.It was shown that linear approaches lead to significant limitations and are not suitable for providing accurate and realistic solutions.On the other hand, both of the employed nonlinear approaches presented high levels of accuracy for both static and dynamic system responses.The RFEM method is shown to be more robust and numerically efficient than the DMM method, and is recommended as the proposed technique for further investigations on medical needle dynamics.
Future work will further analyse the RFEM model in order to validate its performance in experimental studies.The model will also be used in conjunction with computationally efficient and accurate tissue models and will act as the basis for modelling the dynamics of virtual surgical instruments of a fully featured medical simulation solution.Future extensions of our work will also allow the implementation of the proposed model with the help of the graphics processing unit, aiming at further improvement of the model's computational efficiency.

Figure 1 .
Figure 1.Large deflections and large rigid body motion in prostate brachytherapy and biopsy.

Figure 3 .
Figure 3. Spatial DDM element at reference and deformed state.
(a) Free body diagram of element j for the DDM method.(b) Free body diagram of element j for the RFEM method.

Figure 4 .
Figure 4. Free body diagrams for DDM and RFEM methods.

Figure 8 .
Figure 8. Rigid base and flexible needle at connection point A.

Figure 9 .
Figure 9.Last RFEM element and needle tip definition.

Figure 10 .
Figure 10.Stiffness and cutting forces on the last RFEM element.

Figure 12 .
Figure 12.Infinitesimal area and tangent plane vectors for rfe j.

Figure 13 .
Figure 13.Traction on an infinitesimal area of rfe j.
(a) Needle deflection in y and z direction under constant tip force loading a F F tip .(b) Needle deflection in y and z direction under constant tip force loading b F F tip .(c) Needle deflection in y and z direction under constant tip force loading c F F tip .

Figure 14 .
Figure 14.Needle response under the three tip force loading conditions of (40).
(a) Error ê under constant tip force loading a F F tip .(b) Error ê under constant tip force loading b F F tip .(c)Error ê under constant tip force loading c F F tip .

Figure 15 .
Figure 15.Error ê under the three tip force loading conditions of (40).

Figure 16 .
Figure 16.(a) Response of tip's position in x direction.(b) Response of tip's position in z direction.(c) Reaction force at needle's handle in z direction.(d) Reaction moment at needle's handle in y direction.

Figure 17 .
Figure 17.(a)/(b) Mean error êt for the tip position and execution time to real-time ratio with respect to the number of elements for RFEM/DDM.(c)/(d) Mean error êf for the handle force and execution time to real-time ratio with respect to the number of elements for RFEM/DDM.

Figure 18 .
Figure 18.Needle tissue interaction model based on Winkler foundation.

Figure 19 .
Figure 19.(a) Response of tip's position in x direction.(b) Response of tip's position in z direction.(c) Reaction force at needle's handle in z direction.(d) Reaction moment at needle's handle in y direction.(e) Error e t for the tip position.(f) Error e f for the handle force.