{ "cells": [ { "cell_type": "markdown", "metadata": { "kernel": "SoS", "tags": [ "scratch" ] }, "source": [ "# Welcome to the Inversion Recovery blog post Jupyter Notebook!\n", "\n", "If this is your first time running a Juptyer Notebook, there's a lot of tutorials available online to help. [Here's one](https://www.dataquest.io/blog/jupyter-notebook-tutorial/) for your convenience.\n", "\n", "## Introduction\n", "\n", "This notebook contains everything needed to reproduce the Inversion Recovery T1 blog post on the [qMRLab website](). In fact, this notebook generated the HTML for the blog post too! This notebook is currently running on a MyBinder server that only you can access, but if you want to be kept up-to-date on any changes that the developpers make to this notebook, you should go to it's [GitHub repository](https://github.com/qMRLab/t1_notebooks) and follow it by clicking the \"Watch\" button in the top right (you may need to create a GitHub account, if you don't have one already).\n", "\n", "## Tips\n", "\n", "Here's a few things you can do in this notebook\n", "\n", "### Code\n", "* Run the entire processing by clicking above on the \"Kernel\" tab, then \"Restart & Run All\". Currently, the processing time is approximately **30-45 minutes**. It will be complete when none of the cells have an asterix \"\\*\" in the square brackets.\n", "* To change the code, you need to click once on code cells. To re-run that cell, click the \"Run\" button above when the cell is selected.\n", " * **Note:** Cells can depend on previous cells, or even on previous runs of the cell itself, so it's best to run all the previous cells beforehand.\n", "* This binder runs on SoS, which allows the mixing of Octave (i.e. an open-source MATLAB) and Python cells. Take a look a the drop down menu on the top right of the cells to know which one you are running.\n", "* To transfer data from cells of one language to another, you need to create a new cell in the incoming language and run `%get (param name) --from (outgoing language)`. See cells below for several examples within this notebook.\n", "\n", "### HTML\n", "* To reproduce the HTML of the blog post, run the entire processing pipeline (see point one in the previous section), then save the notebook (save icon, top left). Now, click on the drop down menu on the left pannel, and select `%sossave --to html --force` . After a few seconds, it should output \"Workflow saved to InversionRecovery.html\" – click on the HTML name, and you're done!\n", "* Cells with tags called \"scratch\" are not displayed in the generated HTML.\n", "* Cells with the tag \"report_output\" display the output (e.g. figures) in the generated HTML.\n", "* Currently in an un-run notebook, the HTML is not formatted like the website. To do so, run the Python module import cell (`# Module imports`) and then very last cell (`display(HTML(...`).\n", "\n", "**If you have any other questions or comments, please raise them in a [GitHub issue](https://github.com/qMRLab/t1_notebooks/issues).**" ] }, { "cell_type": "markdown", "metadata": { "kernel": "SoS", "tags": [ "scratch" ] }, "source": [ "# Note\n", "\n", "The following cell is meant to be displayed for instructional purposes in the blog post HTML when \"All cells\" gets displayed (i.e. the Octave code)." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "kernel": "Octave" }, "outputs": [], "source": [ "% **Blog post code introduction**\n", "% \n", "% Congrats on activating the \"All cells\" option in this interactive blog post =D\n", "%\n", "% Below, several new HTML blocks have appears prior to the figures, displaying the Octave/MATLAB code that was used to generate the figures in this blog post.\n", "%\n", "% If you want to reproduce the data on your own local computer, you simply need to have qMRLab installed in your Octave/MATLAB path and run the \"startup.m\" file, as is shown below.\n", "%\n", "% If you want to get under the hood and modify the code right now, you can do so in the Jupyter Notebook of this blog post hosted on MyBinder. The link to it is in the introduction above." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "kernel": "Python3", "tags": [ "scratch" ] }, "outputs": [], "source": [ "# PYTHON CODE\n", "# Module imports\n", "\n", "import matplotlib.pyplot as plt\n", "import plotly.plotly as py\n", "import plotly.graph_objs as go\n", "import numpy as np\n", "from plotly import __version__\n", "from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot\n", "config={'showLink': False, 'displayModeBar': False}\n", "\n", "init_notebook_mode(connected=True)\n", "\n", "from IPython.core.display import display, HTML" ] }, { "cell_type": "markdown", "metadata": { "kernel": "SoS" }, "source": [ "
" ] }, { "cell_type": "markdown", "metadata": { "kernel": "SoS" }, "source": [ "
\n", "Widely considered the gold standard for T1 mapping, the inversion recovery technique estimates T1 values by fitting the signal recovery curve acquired at different delays after an inversion pulse (180°). In a typical inversion recovery experiment (Figure 1), the magnetization at thermal equilibrium is inverted using a 180° RF pulse. After the longitudinal magnetization recovers through spin-lattice relaxation for predetermined delay (“inversion time”, TI), a 90° excitation pulse is applied, followed by a readout imaging sequence (typically a spin-echo or gradient-echo readout) to create a snapshot of the longitudinal magnetization state at that TI.\n", "
\n", "\n", "\n", "Inversion recovery was first developed for NMR in the 1940s (Hahn 1949; Drain 1949), and the first T1 map was acquired using a saturation-recovery technique (90° as a preparation pulse instead of 180°) by (Pykett and Mansfield 1978). Some distinct advantages of inversion recovery are its large dynamic range of signal change and an insensitivity to pulse sequence parameter imperfections (Stikov et al. 2015). Despite its proven robustness at measuring T1, inversion recovery is scarcely used in practice, because conventional implementations require repetition times (TRs) on the order of 2 to 5 T1 (Steen et al. 1994), making it challenging to acquire whole-organ T1 maps in a clinically feasible time. Nonetheless, it is continuously used as a reference measurement during the development of new techniques, or when comparing different T1 mapping techniques, and several variations of the inversion recovery technique have been developed, making it practical for some applications (Messroghli et al. 2004; Piechnik et al. 2010).\n", "
\n", "\n", "
\n", "The steady-state longitudinal magnetization of an inversion recovery experiment can be derived from the Bloch equations for the pulse sequence {θ180 – TI – θ90 – (TR-TI)}, and is given by:\n", "\n", "
\n", "\n", "\n", "
\n", "where Mz is the longitudinal magnetization prior to the θ90 pulse. If the in-phase real signal is desired, it can be calculated by multiplying Eq. 1 by ksin(θ90)e-TE/T2, where k is a constant. This general equation can be simplified by grouping together the constants for each measurements regardless of their values (i.e. at each TI, same TE and θ90 are used) and assuming an ideal inversion pulse:\n", "
\n", "\n", "\n", "
\n", "where the first three terms and the denominator of Eq. 1 have been grouped together into the constant C. If the experiment is designed such that TR is long enough to allow for full relaxation of the magnetization (TR > 5T1), we can do an additional approximation by dropping the last term in Eq. 2:\n", "
\n", "\n", "\n", "
\n", "The simplicity of the signal model described by Eq. 3, both in its equation and experimental implementation, has made it the most widely used equation to describe the signal evolution in an inversion recovery T1 mapping experiment. The magnetization curves are plotted in Figure 2 for approximate T1 values of three different tissues in the brain. Note that in many practical implementations, magnitude-only images are acquired, so the signal measured would be proportional to the absolute value of Eq. 3.\n", "
\n", "\n", "Practically, Eq. 1 is the better choice for simulating the signal of an inversion recovery experiment, as the TRs are often chosen to be greater than 5T1 of the tissue-of-interest, which rarely coincides with the longest T1 present (e.g. TR may be sufficiently long for white matter, but not for CSF which could also be present in the volume). Equation 3 also assumes ideal inversion pulses, which is rarely the case due to slice profile effects. Figure 3 displays the inversion recovery signal magnitude (complete relaxation normalized to 1) of an experiment with TR = 5 s and T1 values ranging between 250 ms to 5 s, calculated using both equations.\n", "
\n", "\n", "Several factors impact the choice of the inversion recovery fitting algorithm. If only magnitude images are available, then a polarity-inversion is often implemented to restore the non-exponential magnitude curves (Figure 3) into the exponential form (Figure 2). This process is sensitive to noise due to the Rician noise creating a non-zero level at the signal null. If phase data is also available, then a phase term must be added to the fitting equation (Barral et al. 2010). Equation 3 must only be used to fit data for the long TR regime (TR > 5T1), which in practice is rarely satisfied for all tissues in subjects.\n", "
\n", "\n", "\n", "Early implementations of inversion recovery fitting algorithms were designed around the computational power available at the time. These included the “null method” (Pykett et al. 1983), assuming that each T1 value has unique zero-crossings (see Figure 2), and linear fitting of a rearranged version of Eq. 3 on a semi-log plot (Fukushima & Roeder 1981). Nowadays, a non-linear least-squares fitting algorithm (e.g. Levenberg-Marquardt) is more appropriate, and can be applied to either approximate or general forms of the signal model (Eq. 3 or Eq. 1). More recent work (Barral et al. 2010) demonstrated that T1 maps can also be fitted much faster (up to 75 times compared to Levenberg-Marquardt) to fit Eq. 1 – without a precision penalty – by using a reduced-dimension non-linear least squares (RD-NLS) algorithm. It was demonstrated that the following simplified 5-parameter equation can be sufficient for accurate T1 mapping:\n", "
\n", "\n", "\n", "
\n", "where a and b are complex values. If magnitude-only data is available, a 3-parameter model can be sufficient by taking the absolute value of Eq. 4. While the RD-NLS algorithms are too complex to be presented here (the reader is referred to the paper, (Barral et al. 2010)), the code for these algorithms was released open-source along with the original publication, and is also available as a qMRLab T1 mapping model. One important thing to note about Eq. 4 is that it is general – no assumption is made about TR – and is thus as robust as Eq. 1 as long as all pulse sequence parameters other than TI are kept constant between each measurement. Figure 4 compares simulated data (Eq. 1) using a range of TRs (1.5T1 to 5T1) fitted using either RD-NLS & Eq. 4 or a Levenberg-Marquardt fit of Eq. 2.\n", "
\n", "\n", "Figure 5 displays an example brain dataset from an inversion recovery experiment, along with the T1 map fitted using the RD-NLS technique.\n", "
\n", "\n", "The conventional inversion recovery experiment is considered the gold standard T1 mapping technique for several reasons. A typical protocol has a long TR value and a sufficient number of inversion times for stable fitting (typically 5 or more) covering the range [0, TR]. It offers a wide dynamic range of signals (up to [-kM0, kM0]), allowing a number of inversion times where high SNR is available to sample the signal recovery curve (Fukushima 1981). T1 maps produced by inversion recovery are largely insensitive to inaccuracies in excitation flip angles and imperfect spoiling (Stikov et al. 2015), as all parameters except TI are constant for each measurement and only a single acquisition is performed (at TI) during each TR. One important pulse sequence design consideration is to avoid acquiring at inversion times where the signal for T1 values of the tissue-of-interest is nulled, as the magnitude images at this TI time will be dominated by Rician noise which can negatively impact the fit under low SNR circumstances (Figure 6). Inversion recovery can also often be acquired using commonly available standard pulse sequences available on most MRI scanners by setting up a customized acquisition protocol, and does not require any additional calibration measurements.\n", "
\n", "\n", "Despite a widely acknowledged robustness for measuring accurate T1 maps, inversion recovery is not often used in studies. An important drawback of this technique is the need for long TR values, generally on the order of a few T1 for general models (e.g. Eqs. 1 and 4), and up to 5T1 for long TR approximated models (Eq. 3). It takes about to 10-25 minutes to acquire a single-slice T1 map using the inversion recovery technique, as only one TI is acquired per TR (2-5 s) and conventional cartesian gradient readout imaging acquires one phase encode line per excitation (for a total of ~100-200 phase encode lines). The long acquisition time makes it challenging to acquire whole-organ T1 maps in clinically feasible protocol times. Nonetheless, it is useful as a reference measurement for comparisons against other T1 mapping methods, or to acquire a single-slice T1 map of a tissue to get T1 estimates for optimization of other pulse sequences.\n", "
\n", "\n", "Several variations of the inversion recovery pulse sequence were developed to overcome challenges like those specified above. Amongst them, the Look-Locker technique (Look and Locker 1970) stands out as one of the most widely used in practice. Instead of a single 90° acquisition per TR, a periodic train of small excitation pulses θ are applied after the inversion pulse, {θ180 – 𝛕 – θ – 𝛕 – θ – ...}, where 𝛕 = TR/n and n is the number of sampling acquisitions. This pulse sequence samples the inversion time relaxation curve much more efficiently than conventional inversion recovery, but at a cost of lower SNR. However, because the magnetization state of each TI measurement depends on the previous series of θ excitation, it has higher sensitivity to B1-inhomogeneities and imperfect spoiling compared to inversion recovery (Gai et al. 2013; Stikov et al. 2015) . Nonetheless, Look-Locker is widely used for rapid T1 mapping applications, and variants like MOLLI (Modified Look-Locker Inversion recovery) and ShMOLLI (Shortened MOLLI) are widely used for cardiac T1 mapping (Messroghli et al. 2004; Piechnik et al. 2010)\n", "
\n", "\n", "\n", "Another inversion recovery variant that’s worth mentioning is saturation recovery, in which the inversion pulse is replaced with a saturation pulse: {θ90 – TI – θ90}. This technique was used to acquire the very first T1 map (Pykett and Mansfield 1978). Unlike inversion recovery, this pulse sequence does not need a long TR to recover to its initial condition; every θ90 pulse resets the longitudinal magnetization to the same initial state. However, to properly sample the recovery curve, TIs still need to reach the order of ~T1, the dynamic range of signal potential is cut in half ([0, M0]), and the short TIs (which have the fastest acquisition times) have the lowest SNRs.\n", "
\n", "\n", "Barral JK, Gudmundson E, Stikov N, et al. (2010) A robust methodology for in vivo T1 mapping. Magn. Reson. Med. 64(4): 1057–1067.\n", "
\n", "\n", "\n", "Drain LE (1949) A Direct Method of Measuring Nuclear Spin-Lattice Relaxation Times. Proceedings of the Physical Society. Section A 62(5): 301–306.\n", "
\n", "\n", "\n", "Fukushima, E. & Roeder, S., 1981. Experimental Pulse NMR. A Nuts and Bolts Approach, Reading, Massachusetts : Addison-Wesley Publ. Comp., Inc.\n", "
\n", "\n", "\n", "Gai, N.D. et al., 2013. Modified Look-Locker T1 evaluation using Bloch simulations: human and phantom validation. Magn. Reson. Med., 69(2), pp.329–336.\n", "
\n", "\n", "\n", "Hahn, E.L., 1949. An Accurate Nuclear Magnetic Resonance Method for Measuring Spin-Lattice Relaxation Times. Physics Review, 76(1), pp.145–146.\n", "
\n", "\n", "\n", "Look, D.C. & Locker, D.R., 1970. Time Saving in Measurement of NMR and EPR Relaxation Times. The Review of scientific instruments, 41(2), pp.250–251.\n", "
\n", "\n", "\n", "Messroghli, D.R. et al., 2004. Modified Look-Locker inversion recovery (MOLLI) for high-resolution T1 mapping of the heart. Magn. Reson. Med., 52(1), pp.141–146.\n", "
\n", "\n", "\n", "Piechnik, S.K. et al., 2010. Shortened Modified Look-Locker Inversion recovery (ShMOLLI) for clinical myocardial T1-mapping at 1.5 and 3 T within a 9 heartbeat breathhold. J. Cardiovasc. Magn. Reson., 12, p.69.\n", "
\n", "\n", "\n", "Pykett, I.L. et al., 1983. Measurement of spin-lattice relaxation times in nuclear magnetic resonance imaging. Physics in medicine and biology, 28(6), pp.723–729.\n", "
\n", "\n", "\n", "Pykett, I.L. & Mansfield, P., 1978. A line scan image study of a tumorous rat leg by NMR. Physics in medicine and biology, 23(5), pp.961–967.\n", "
\n", "\n", "\n", "Steen, R.G. et al., 1994. Precise and accurate measurement of proton T1 in human brain in vivo: validation and preliminary clinical application. J. Magn. Reson. Imaging, 4(5), pp.681–691.\n", "
\n", "\n", "\n", "Stikov, N. et al., 2015. On the accuracy of T1 mapping: Searching for common ground. Magn. Reson. Med., 73(2), pp.514–522.\n", "
\n", "