StimTrack: An open-source software for manual transcranial magnetic stimulation coil positioning

Home / Mental health / StimTrack: An open-source software for manual transcranial magnetic stimulation coil positioning

1. Introduction

Transcranial magnetic stimulation (TMS) is a non-invasive and painless technique to stimulate the human brain with an electromagnetic coil placed on the scalp. TMS is widely used as a tool to assess corticospinal excitability, a commonly used marker for corticospinal plasticity (Hallett, 2000). With the coil placed over the primary motor cortex a twitch in a contralateral muscle can be elicited, which when measured using electromyography (EMG) is named a motor evoked potential (MEP) (Rossini et al., 2015). Frequently, MEPs are recorded with the coil held steady over the position at which the greatest MEPs for the muscle studied may be elicited. The position and orientation of the coil over this ‘motor hotspot’ needs to be accurately maintained within and between sessions as they both affect the magnitude of the evoked response (Conforto et al., 2004; Laakso et al., 2014; Mills et al., 1992).

Traditionally the motor hotspot is marked either directly on the scalp or on a swim cap and coil positioning over the hotspot is performed manually (Devanne et al., 1997; Herwig et al., 2003). With this method, the capability to accurately maintain (within-session) and replicate (between-session) coil position and orientation is limited. As a result, rigid holders or mechanical arms have been used to aid and maintain coil placement during long TMS sessions (Chronicle et al., 2005; Schubert et al., 1997; Taube et al., 2008). However, this solution requires the participant to keep the head as still as possible. To help participants, researchers have attempted to fix the head with respect to the coil using a head resting frame (Richter et al., 2013) or by strapping coil to the head (e.g. (Barsi et al., 2008)).

Neuronavigated TMS is commonly employed to reduce variability in coil position and orientation in space and over time (Herwig et al., 2001). Navigated TMS makes use of anatomical or functional magnetic resonance imaging (MRI) data and an optically tracked frameless stereotaxic system. This allows the researcher to maintain the stimulation site with millimetre accuracy (Schönfeldt-Lecuona et al., 2005). Furthermore, when using navigated TMS, stimulation sites can be maintained <2 mm from the target among 20 repeated trials, compared with 60 mm for non-navigated TMS (Julkunen et al., 2009).

Although neuronavigation systems provide accurate and precise coil placement, this technique is still underutilised. Neuronavigation systems typically suggest using a (participant specific) MRI, that are often not available or not required to locate the motor hotspot. Indeed, the size of the MEP response and the induced movement are important hints that can be used to determine the hotspot location. In addition, current neuronavigation systems do typically not provide the investigator with online access to the coil position and orientation data, only providing the ability to use data offline. This is potentially important in trials when the coil might be expected to move with respect to the head (e.g., during walking) (Barthélemy et al., 2012). Online access to the coil position and orientation would allow for better control of stimulation delivery which could then allow one to stop stimulation automatically should the coil move with respect to the scalp.

The aim of this study was to develop a user-friendly open-source software tool providing a platform for online monitoring of the position and orientation of any type of TMS coil. This software tool (StimTrack) assists with maintaining coil position and orientation with respect to the participant’s head, recalls previous coil positions for comparison over multiple sessions, and interrupts the stimulation when the coil is placed incorrectly. Three experiments were performed to test correct functioning of StimTrack: we assessed (1) the repeatability in hotspot finding by using a custom-built testing platform; (2) the accuracy of the stimulation site by comparing StimTrack to a commercial neuronavigation system; and (3) the test-retest reliability of TMS-derived measures by collecting TMS data from 19 healthy participants.

2. Methods

2.1. StimTrack

An optical tracking system (Polaris Vicra, Northern Digital Inc.) and two passive tools fitted with spherical, retro-reflective markers, on the participant’s forehead and on the coil handle (Fig. 1), are used to monitor the relative pose between the coil and the participant’s head.

Fig. 1

Fig. 1. The coil (panel A) and head (panel B) tools used to monitor the relative pose between the coil and the participant’s head. The figure also shows the pointer used for the definition of two local reference frames: the selected points are indicated by the red arrows in the two panels. Shown in Panel A is a double cone coil, but the software can work with any coil. (For interpretation of the references to colour in this figure legend, the reader is referred to the web version of this article.)

To set up StimTrack for monitoring any coil’s position and orientation two steps need to be taken:

1) Definition of the coil and head local reference frames (RFs)

Coil and head local RF are constructed based on specific sites pointed out on the coil and head using a pointer. To define the coil local RF, four sites on the coil are selected (Fig. 1A): three points describe the transversal plane, while the fourth defines the origin. To build the head local RF, three landmarks are selected (Fig. 1B): the nasion (defined as the origin) and the left and right tragus. When the pointer is correctly placed on each landmark, the operator presses the corresponding button in the Graphical User Interface (GUI) (Fig. 2A). When all the points are selected, the coil and head local RFs are constructed (Tcoilcoil_tooland Theadhead_tool, respectively). If the participant has been previously involved in a TMS session, it is possible to compare the position of the 3 landmarks on the head with those already saved.

Fig. 2

Fig. 2. StimTrack GUI for monitoring TMS coil positioning. Panel A includes all the control elements of the GUI which are used to define the coil and head local RFs, to identify the hotspot, and to activate the online monitoring modality. Panel B includes three graphical sketches to help the operator visualise and maintain the coil orientation with respect to the target hotspot. The black horizontal line shows the target orientation, while the green line represents the actual orientation. Panels C and D show the distance between the hotspot and the origin of the coil local RF and the variation of the pitch, roll and yaw angles in real-time, respectively. Finally, panel E shows the distance to target projected on the transversal plane. Panels C, D, and E are green when the coil is within the accepted distance and orientation to the target; they turn red when the distance or orientation tolerance is exceeded. (For interpretation of the references to colour in this figure legend, the reader is referred to the web version of this article.)

2) Hotspot identification

When the coil is placed over the hotspot, the homogeneous transformation matrix between the coil local RF and the head local RF (Thotspothead) is stored when the ‘Record Hotspot’ button is pressed (Fig. 2A). The GUI also allows to load a previously identified hotspot.

Once local RFs and hotspot are defined, StimTrack is set up to provide continuous feedback about coil position and orientation with respect to the hotspot. At each time step, the rotation matrix Thotspotcoil, defining the position and orientation of the coil local RF with respect to the hotspot, is computed as follows:

(1)Tcoilhotspot=TheadhotspotTheadtoolhead(Theadtoolcoiltool)−1(Tcoiltoolcoil)−1

where Tcoiltoolheadtool is directly provided by the tracking system.

The translation vector and the orientation angles derived from Thotspotcoil are fed back online and represent the error of the coil pose with respect to the hotspot previously stored.

When the coil is not correctly placed over the hotspot (distance to hotspot >5 mm and/or variation of roll, pitch and yaw angles >5°), StimTrack prevents unnecessary stimuli by blocking the trigger to the stimulator.

StimTrack was developed in C++ and the IGSTK libraries were used to communicate with the tracking system. The user manual, providing a detailed description of all functionalities, as well as the source code of StimTrack are available as supplementary material.

2.2. Validation protocols and data analysis

Three experiments were performed to validate StimTrack functionalities.

The first experiment was designed to assess repeatability as an operator locates a motor hotspot within and between different sessions using StimTrack. To rule out any human factors this experiment was performed using a custom-built platform rather than human participants. The platform contained four different positions to mount two passive tools (normally placed on the TMS coil and participant’s forehead). Moreover, seven points were marked to be used for calibration of the coil and head local RFs. First, the coil and head local RFs were calibrated by registering the respective landmarks, then the hotspot position was recorded without moving any tools. This means that the hotspot always corresponded to the initial position and orientation of the coil local RF. To evaluate the variability of the matrix Thotspothead due to the re-calibration of the coil and head local RFs, the coordinates of the same landmarks were registered 10 times not moving the passive tools, 10 times after repositioning the coil tool on a different holder, and 10 times after repositioning the head tool on a different holder. The procedure was repeated for 3 different sets of coil and head landmarks, which means simulating 3 different hotspots, i.e., 3 different matrices Thotspothead. Repeatability was computed for the norm of the translation vector and for the rotation angles derived from Thotspothead using the Gauge repeatability and reproducibility method (Burdick et al., 2005). In total a dataset of 90 samples was available for this analysis (10 times × 3 test-conditions × 3 hotspots).

In the second experiment, we assessed StimTrack accuracy by comparing to a commercial neuronavigation software package (BrainSight, Rogue Research Inc.). In this experiment, a flat figure-of-8 coil and a dummy head were used. First the passive tools were attached to the coil handle and to the forehead of the dummy and the landmarks were registered in both systems. Subsequently, a stimulation target (or hotspot) was stored in both systems. Defining one hotspot as the target, the coil was then moved to 10 different positions on the head and the distance and orientation of the coil relative to the hotspot were stored. This procedure, including repositioning of the passive tools and re-registration of coil and dummy head, was repeated for five distinctive hotspots. The accuracy was evaluated by using the Bland-Altman method (Bland and Altman, 1986) on the distance to hotspot and on the variation of the yaw, pitch, and roll angles. On these parameters, a repeated-measures ANOVA was applied to compare errors computed by the two systems.

The third experiment was a TMS experiment in human participants to evaluate StimTrack’ feasibility. The protocol was approved by the ethical committee of the Clinical and Scientific Institutes Maugeri (number: 931CE; date of approval: 10/03/2014) and conducted in conformity with ethical and human principles of research. All participants gave their written consent to participate. A test-retest protocol was performed in 19 healthy participants, with the two sessions one-week apart. In all sessons participants were comfortably seated and relaxed with hip, knee and ankle joint angles of about 110°, 110° and 90°. TMS measures were obtained using the Magstim Rapid2 stimulator (Magstim Company Ltd., Whitland, Dyfed, UK) with a “double-cone” coil to stimulate the primary motor cortex. Surface EMG of the tibialis anterior (TA) muscle was recorded using a signal amplifier (Porti 32™, TMS International) and sampled at 2048 Hz. The first session started with the hotspot identification: the coil was moved in small steps over the leg cortical motor area in order to find the position and orientation which evoked the maximal MEPs in the TA muscle. Afterwards, three stimulus-response (SR) curves, which represent the growth of the MEP size as a function of the stimulation intensity (Devanne et al., 1997), were obtained with the TA muscle at rest, following the acquisition protocol described in (Mathias et al., 2014). For each SR curve, a train of stimuli was delivered with an inter-stimulus interval of 3s; the stimulation intensity varied pseudo-randomly on a pulse-by-pulse basis in an online adjustable range. The operator could adjust the minimum and maximum stimulation intensity accordingly to the online display of the SR curve in order to identify the threshold on one end and the point where the MEP plateaus on the other end. The operator manually stopped the acquisition 3–5 stimuli after the curve had reached a steady state (i.e., it did not change with successive stimuli). Subsequent SR curves were acquired with an interval of 2–5 min. On the second session, the coil was replaced over the same hotspot using StimTrack, and 3 SR curves were acquired. In each session the maximal evoked response(Mmax) of the TA muscle was measured delivering supramaximal stimuli to the peroneal nerve. For each MEP, the peak-to-peak amplitude (MEPpp) was computed in a window 20–80 ms after stimulation. MEPs were normalised to Mmax in order to reduce the variability due to electrodes replacement and to allow inter-subject comparison as recommended in (Groppa et al., 2012). Normalized MEPpp values were plotted as function of the stimulation intensity and modelled using a four-parameter Boltzmann sigmoid function as described in (Devanne et al., 1997). Motor Threshold (MT), computed as the x-intercept of the tangent to the sigmoid function at the point of maximal slope (Carroll et al., 2001), and the area under the curve (AUC) (Carson et al., 2013) were derived from each SR curve. Once verified the normality of data by means of the Shapiro-Wilk test, the Intraclass Correlation Coefficient (ICC) was computed to evaluate both intra- and inter-session reliability for MT and AUC. The reliability was considered poor to moderate, good, and excellent if ICC was <0.75, between 0.75-0.9, and >0.9, respectively (Portney and Watkins, 2009).

3. Results

3.1. Experiment 1

Table 1 reports the mean values and the standard deviation of the norm of the translation vector and of the rotation angles extracted from the matrix Thotspothead for the 3 simulated hotspots and the 3 test-conditions. A repeatability of 0.7 mm for the translation vector and of <1° for the rotation angles were achieved.

Table 1. Platform-based validation trials (Experiment 1) of StimTrack: mean values and standard deviation of the norm of the translation vector and of the rotation angles extracted from the matrix Thotspothead for the 3 simulated hotspots and the 3 test-conditions. Repeatability values are also reported.

Test-condition 1 Test-condition 2 Test-condition 3 Repeatability
||νT|| [mm]
Hotspot 1 79.6 (0.5) 79.8 (0.4) 80.3 (0.9) 0.7 mm
Hotspot 2 114.1 (0.9) 113.7 (1.0) 114.3 (0.5)
Hotspot 3 139.2 (0.8) 140.0 (0.4) 138.5 (0.6)
Roll [°]
Hotspot 1 126.0 (0.8) 126.8 (1.2) 126.8 (0.7) 0.6°
Hotspot 2 −90.2 (0.3) −90.4 (0.5) −90.0 (0.3)
Hotspot 3 90.2 (0.4) 89.9 (0.4) 90.4 (0.3)
Pitch [°]
Hotspot 1 −0.0 (0.3) −0.2 (0.5) 0.0 (0.4) 0.5°
Hotspot 2 0.2 (0.7) 0.2 (0.4) 0.0 (0.5)
Hotspot 3 0.8 (0.6) −0.4 0.7) 0.6 (0.3)
Yaw [°]
Hotspot 1 89.3 (0.4) 88.7 (0.7) 88.7 (0.8) 0.7°
Hotspot 2 −173.4 (1.1) −173.8 (0.7) −172.4 (0.9)
Hotspot 3 107.4 (0.5) 106.7 (0.5) 107.5 (0.5)

Test-condition 1: tools fixed; test-condition 2: coil tool moved; test-condition 3: head tool moved.

3.2. Experiment 2

The Bland-Altman method showed a mean difference [95% limits of agreement] between StimTrack and BrainSight of 0.2 mm [−2.5;2.8] for the distance to target, and −0.9° [−6.9;5.1], 0.7° [−3.7;5.0], and 0.4° [−4.5;5.2] for the variation of the roll, pitch, and yaw angles, respectively (Fig. 3).

Fig. 3

Fig. 3. Bland-Altman plots comparing StimTrack and BrainSight (Experiment 2). In each panel, mean difference (solid line) and 95% limits of agreement (dashed lines) are reported.

Fig. 4 shows the mean value and the standard deviation of the distance to hotspot, the variation of Roll, Pitch and Yaw angles obtained by the two systems (BrainSight in light grey and StimTrack in dark grey). A significant difference was found only for the variation of the pitch angle, with a mean difference (95% CI) between the two systems of 0.94° (0.54; 1.34).

Fig. 4

Fig. 4. Mean value and standard deviation of the Distance to Hotspot, Variation of Roll, Pitch and Yaw angles obtained by BrainSight and StimTrack (Experiment 2). * Indicates statistically significant difference (p-value < 0.001, two-way repeated measures ANOVA).

3.3. Experiment 3

Nineteen healthy adult participants (mean age of 62.4 ± 4.4 years old; 8 males; 13 right dominant leg) were enrolled. SR curves were constructed with on average 70 stimuli. Typical SR curves of one subject are shown in Fig. 5.

Fig. 5

Fig. 5. The three SR curves acquired on the first (upper panel) and second (lower panel) day from one representative participant (Experiment 3). In each panel, the normalized MEPpp data (dots) and the fitted curves (solid lines) are reported.

Table 2 reports the results of the intra- and inter-session reliability analysis on the motor threshold and area under the curve. An excellent reliability was found for both conditions and parameters.

Table 2. Results of the Intra-and inter-session reliability analysis (Experiment 3) on Motor Threshold and Area under the Curve.

Day 1 Day 2 Intra-session Day 1 Inter-session
SR curve 1* SR curve 2* SR curve 3* SR curve 1* SR curve 2* SR curve 3* ICC [95% CI] ICC [95% CI]
MT [%MSO] 56.2 (13.1) 55.8 (12.8) 55.9 (13.5) 53.4 (8.8) 56.1 (12.0) 54.9 (11.4) 0.928 [0.854; 0.969] 0.911 [0.771; 0.965]
AUC [–] 11.2 (10.0) 10.6 (9.7) 10.5 (8.4) 9.2 (8.6) 8.8 (7.82) 8.8 (8.9) 0.965 [0.928; 0.985] 0.937 [0.827; 0.976]

SR curve: Stimulus-Response curve; MT: Motor Threshold; MSO: Maximum Stimulator Output; AUC: Area Under the SR Curve; ICC: Intraclass Correlation Coefficient; CI: Confidence Interval.

*

Mean (standard deviation).

4. Discussion

Consistent TMS coil placement is important to minimise measurement variability when quantifying corticospinal excitability. The aim of this study was to develop an open-source software tool providing a platform for online monitoring of the position and orientation of any type of TMS coil, compatible with any TMS stimulators. StimTrack provides an intuitive and easy to use, interface that can help researchers monitor coil position and orientation without the need for extensive calibration procedures, such as MRI co-registration, and calibration platforms specific to each coil. StimTrack also allows online access to the data stream, thus opening up many new opportunities to deliver the stimulation based on a current position, such as halting the stimulation in the event of an incorrect coil placement and navigated TMS coil placement specific to the requirements of the individual research laboratory (see below). StimTrack achieves high repeatability in coil repositioning and a target accuracy comparable to that of a commercial neuronavigation system (BrainSight, Rogue Research Inc.). The excellent intra- and inter-session reliability obtained on the parameters computed on SR curves acquired using StimTrack, demonstrated that it can be efficiently used in practice. Thus, when researchers aim to apply TMS over the motor cortex, StimTrack is a potential open-source alternative to commercial neuronavigation systems that allows the user direct online access to the data steam and the ability to modify the code to suit the experiment.

4.1. Repeatability and accuracy of coil positioning

A repeatability of coil position of 0.7 mm and of <1° for coil orientation with respect to the predefined coil placement over the hotspot was achieved. Accuracy of coil positioning was validated against a commercial neuronavigation system using the exact same setup but requiring a (generic) MRI scan to start the registration procedure. For the BrainSight system the accuracy of coil placement is ∼3 mm (personal communication, Rogue Resolutions), but this is greatly influenced by registration errors when registering facial landmarks. We found small differences in the target accuracy between the BrainSight system and StimTrack (position: ∼0.2 mm and orientation: <1°). Despite a significant difference of <1° was found for the variation of the pitch angle, one can consider it negligible given the human error involved in registration of the landmarks which was performed separately for the two systems.

4.2. Obtaining TMS measures aided by navigation

The benefit of using navigation to aid consistent coil positioning has been widely acknowledged (Danner et al., 2008; Gugino et al., 2001; Julkunen et al., 2012, 2009; , 2009). In the last section, we highlighted the good repeatability and accuracy of coil placement with respect to the hotspot, however in an artificial setting. To demonstrate StimTrack is also useful in a laboratory setting, an experiment was performed in healthy human participants during which the motor threshold and the area under the SR curve were studied. For both, an excellent inter- and intra-session reliability (ICC > 0.9) was found. These results are similar to those previously obtained for the TA muscle (Cacchio et al., 2011, 2009) indicating that StimTrack can be reliably used to obtain TMS measures both within and between sessions. If and to what extent the software or neuronavigation in general may reduce MEP variability remains unclear given the conflicting reports (Julkunen et al., 2009; Jung et al., 2010) and the many other physiological and non-physiological factors that affect TMS measurements (Schmidt et al., 2015).

4.3. Potential applications and future developments

The StimTrack software could be a valuable tool for researchers using TMS to assess changes in corticospinal excitability whilst ensuring the TMS coil is accurately positioned over the stimulation site. The main restriction is the need for an optical tracking system, but one does not need to have an MRI scan or a commercial software license. Moreover, it is compatible with all types of TMS coils and stimulators. In addition, the source code is available as supplementary material, so as any researcher can modify it to their needs.

We believe StimTrack could be very useful in a number of experimental paradigms. For example, at present it is a considerable challenge to maintain accurate coil position and orientation during dynamic motor tasks such as reaching, walking, running or jumping. Despite the use of methods to fix the coil with respect to the head (Barthélemy et al., 2012; Schubert et al., 1997; Taube et al., 2008), it is usually the case that many more stimuli must be delivered than would otherwise be necessary as a substantial number of trials must be excluded in post processing. In order to restrict the system such that stimuli were only delivered when the coil was correctly positioned, we implemented an external trigger signal to prohibit stimulation when coil position or orientation exceeded predefined limits. In future, a further development of StimTrack could allow the investigator to combine coil position/orientation data with EMG data on a pulse by pulse basis. This would allow, for example, the online generation of corticospinal excitability maps where the MEP is plotted against 2-D position information to produce a contour plot of excitability e.g. (van de Ruit et al., 2015; Wassermann et al., 1992). Furthermore, StimTrack could be adapted to track more than one coil simultaneously or could be integrated with addition code for the online control of the stimulator intensity and firing rates.