Difference between revisions of "Automatic DBS lead topology correction"

From MGH/MIT Parallel Transmission Resources
Jump to navigation Jump to search
(Created page with "=== Citation === Guérin B, Gebhardt M, Cauley S, Adalsteinsson E, Wald LL (2014). "[http://onlinelibrary.wiley.com/doi/10.1002/mrm.24800/pdf Local specific absorption rate (S...")
 
 
(20 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
[[File:Before_top_corr.jpg|400px|thumb|right|Bilateral DBS wireframe before topology correction]]
 +
[[File:After_top_corr.jpg|400px|thumb|right|Bilateral DBS wireframe after topology correction]]
 +
 
=== Citation ===
 
=== Citation ===
Guérin B, Gebhardt M, Cauley S, Adalsteinsson E, Wald LL (2014). "[http://onlinelibrary.wiley.com/doi/10.1002/mrm.24800/pdf Local specific absorption rate (SAR), global SAR, transmitter power, and excitation accuracy trade‐offs in low flip‐angle parallel transmit pulse design.]" Magnetic Resonance in Medicine 71(4): 1446-1457.
+
Coming up soon.
 
 
 
=== What this code does ===
 
=== What this code does ===
This Matlab code (no MEX, no GPU code) computes least-squares and magnitude least-squares pTx spoke pulses. The MLS problem can be solved using the phase adoption approach of Setsompop et al. or a full optimization strategy (see the file spokes_3/run_spokes.m and options therein). Spokes can be optimized for several frequencies (spatio-spectral design) in order to build in robustness to off-resonance effects.
+
This codes takes as input a wireframe model of a DBS lead and returns in output the wireframe model that is the closest to the initial path (in the L2 sense) but for which:
 +
* The distance between any two segments of the path is greater than Dmin, where Dmin is a distance defined by the user.
 +
* At every point of the path, the curvature is smaller than Kmax, where Kmax is the maximum curvature defined by the user.
 +
By wireframe path, I mean a piecewise linear curve in 3D space that represents the centerline path of the DBS lead. Every segment is linear and the wireframe path model is therefore simply defined by a set of ordered points in 3D space.
 +
 
 +
I refer to this process of enforcing (i) a minimum distance between any two segments of the path and (ii) a maximum curvature at every point of the path as "topology correction". This is because if the two segments are too close to each other (distance constraint violation) or if the path bends too quickly (curvature constraint violation), once the path is thickened to the actual lead diameter this will result in self-intersections of the cable model. This topology correction process is formulated as a constrained optimization problem solved using an active-set approach. The technique is accelerated using a GPU, but even then computation is relatively slow: Count a few minutes for a lead with ~300 points.  
  
 
=== Download files ===
 
=== Download files ===
The code can be downloaded [https://ptx.martinos.org/images/f/f2/SpokesMinExcErrLocGlobSARPuPow_fmincon_v12.zip here]. A test dataset can be downloaded [https://ptx.martinos.org/images/e/e2/Spokes_3.zip here]. If you wonder how I obtained the field maps, ROI and SODA (=slice information) files, download [https://ptx.martinos.org/images/c/c0/Prescan_data.zip this file].
+
The code, examples and additional scripts for creation of DBS leads in HFSS can be downloaded [https://ptx.martinos.org/images/0/09/DBS_RemoveLead_Intersections_WEB.zip here].
  
 
=== Instructions ===
 
=== Instructions ===
==== Pre-scan data format ====
+
Download the zip file using the link above and unzip it.
The format of the pre-scan data (e.g., B0 map, B1+ maps, slice information in the SODA file) matches the Siemens pTx "Step 2" data format. To take a closer look at this, download the prescan_data.zip file,
+
 
* An ROI file in NIFTI format.
+
==== Running an example ====
* A B0 map in NIFTI format.
+
The subfolder EXAMPLE/ contains an example of how to run the code. The master script is RUN_OPT.m. All the options used in this script are commented and should be easy to understand. There are several things to note in this script:
* An FLD file containing the B1+ maps for the slice considered as obtained by pushing "save dataset" in the B1 mapping tab of the Siemens pTx "Step 2" interface.
+
* Both the left and right DBS leads are loaded in Matlab and are connected in a single wireframe dataset. The topology correction process is run on this "super-lead" in order to remove gamma distance violations not only between the segments of a given lead, but also between segments belonging to different leads. Once the topology correction has been performed, the left and right leads can be separated again.
To get the ROI and B0 maps, I use the Siemens product gre_fieldmapping sequence (make sure to chose "save magnitude/phase" in order to get both the B0 and ROI maps in the same scan). The B0, B1 and ROI datasets must have the same number of pixels and same dimensions.
+
* The topology correction process itself is performed by the Matlab function deform_path_LINEAR.m.
==== Spokes optimization ====
+
 
Unzip the code folder and add it to your path. Unzip the data folder and run the script run_spokes.m. There are several options in it that are straightforward to understand (e.g., LS/MLS, spatio-spectral design). The frequencies of the spatio-spectral design are expressed in Hz and are offset with respect to the Larmor frequency (i..e, +50 means Larmor frequency+50 Hz). Most of the spoke options (such as slice-thickness, slice-selection gradient, time-bandwidth product etc...) are specified in the text file spokes_def.txt and can be changed there.
+
==== Additional scripts ====
 +
The subfolder SCRIPTS/ contain a few general purpose scripts that are useful to model DBS implants:
 +
* CREATE_ELECTRODE_CONTACTS.m: This script takes an input wireframe lead model and creates four linear segments that are the centerline of four electrodes located at 1.5 mm, 4.5 mm, 7.5 mm and 10.5 mm from the tip of the lead. Each electrode centerline is 2 mm long. To change the number of electrodes and their length, simply change the associated parameters in the script.
 +
* CREATE_HELIX_CONDUCTOR.m: This code creates a helicoidal conductor centerline that curves around a prescribed input path with a given pitch and radius. This is useful to model Medtronic leads that have a helicoidal center conductor.
 +
* CREATE_HFSS_SCRIPT_linear.m: This scripts takes an input path and create a VBS script for creation of a linear polyline in the FEM modeling software Ansys HFSS. You will most likely have to change the name of the project in this script to run it in your simulation file (the default name is "Project1").
 +
* SMOOTH_PATH.m: This is a script that "smoothes" a 3D path by first under-sampling it (user-define undersampling rate) and then re-sampling it using cubic splines (user-defined over-sampling rate).
 +
* STITCH_LEAD_PATH.m: This scripts takes two 3D path and "stitches" them by joining them with a cubic segment.
 +
* STRAIGHTEN_ELECTRODE_TIP.m: This script replaces the tip of an input 3D path by a straight line. This is useful to model the tip of a DBS lead with electrodes placed along a straight line. The length of the tip can be changed in the script.

Latest revision as of 16:57, 19 March 2018

Bilateral DBS wireframe before topology correction
Bilateral DBS wireframe after topology correction

Citation

Coming up soon.

What this code does

This codes takes as input a wireframe model of a DBS lead and returns in output the wireframe model that is the closest to the initial path (in the L2 sense) but for which:

  • The distance between any two segments of the path is greater than Dmin, where Dmin is a distance defined by the user.
  • At every point of the path, the curvature is smaller than Kmax, where Kmax is the maximum curvature defined by the user.

By wireframe path, I mean a piecewise linear curve in 3D space that represents the centerline path of the DBS lead. Every segment is linear and the wireframe path model is therefore simply defined by a set of ordered points in 3D space.

I refer to this process of enforcing (i) a minimum distance between any two segments of the path and (ii) a maximum curvature at every point of the path as "topology correction". This is because if the two segments are too close to each other (distance constraint violation) or if the path bends too quickly (curvature constraint violation), once the path is thickened to the actual lead diameter this will result in self-intersections of the cable model. This topology correction process is formulated as a constrained optimization problem solved using an active-set approach. The technique is accelerated using a GPU, but even then computation is relatively slow: Count a few minutes for a lead with ~300 points.

Download files

The code, examples and additional scripts for creation of DBS leads in HFSS can be downloaded here.

Instructions

Download the zip file using the link above and unzip it.

Running an example

The subfolder EXAMPLE/ contains an example of how to run the code. The master script is RUN_OPT.m. All the options used in this script are commented and should be easy to understand. There are several things to note in this script:

  • Both the left and right DBS leads are loaded in Matlab and are connected in a single wireframe dataset. The topology correction process is run on this "super-lead" in order to remove gamma distance violations not only between the segments of a given lead, but also between segments belonging to different leads. Once the topology correction has been performed, the left and right leads can be separated again.
  • The topology correction process itself is performed by the Matlab function deform_path_LINEAR.m.

Additional scripts

The subfolder SCRIPTS/ contain a few general purpose scripts that are useful to model DBS implants:

  • CREATE_ELECTRODE_CONTACTS.m: This script takes an input wireframe lead model and creates four linear segments that are the centerline of four electrodes located at 1.5 mm, 4.5 mm, 7.5 mm and 10.5 mm from the tip of the lead. Each electrode centerline is 2 mm long. To change the number of electrodes and their length, simply change the associated parameters in the script.
  • CREATE_HELIX_CONDUCTOR.m: This code creates a helicoidal conductor centerline that curves around a prescribed input path with a given pitch and radius. This is useful to model Medtronic leads that have a helicoidal center conductor.
  • CREATE_HFSS_SCRIPT_linear.m: This scripts takes an input path and create a VBS script for creation of a linear polyline in the FEM modeling software Ansys HFSS. You will most likely have to change the name of the project in this script to run it in your simulation file (the default name is "Project1").
  • SMOOTH_PATH.m: This is a script that "smoothes" a 3D path by first under-sampling it (user-define undersampling rate) and then re-sampling it using cubic splines (user-defined over-sampling rate).
  • STITCH_LEAD_PATH.m: This scripts takes two 3D path and "stitches" them by joining them with a cubic segment.
  • STRAIGHTEN_ELECTRODE_TIP.m: This script replaces the tip of an input 3D path by a straight line. This is useful to model the tip of a DBS lead with electrodes placed along a straight line. The length of the tip can be changed in the script.