Home

Basis Simulation

This mini practical covers the following example box in Chapter 4: "Simulating a basis". The box appears on Page 105.
As with all these mini-practicals, instructions on how to run FSL commands can be found on the Getting Started page.

Please download the dataset for this example here:

Data download

Once it is downloaded, move it to your preferred working directory and unzip it there.

unzip data_ch4_basis.zip
cd  data_ch4_basis

Simulating basis spectra typically requires three steps:

Sequence description
Creating a JSON text file that describes the MRS sequence.
Simulation
Running the FSL-MRS basis simulator.
Macromolecules
Adding a macromolecule spectrum to the basis.

Sequence description

To create high-quality basis spectra, the simulator must be provided with an accurate description of the MRS sequence. The description contains:

All of this is contained in a simply formatted and human-readable JSON file. An example sequence description is packaged with the practical. We will go through it section by section to illustrate how it was created.

cd basis_creation
cat steam.json

The JSON file contains the following important fields that we will tackle in turn. For a full reference see the online documentation.

The STEAM sequence

To understand this file, first we must understand the structure of the STEAM sequence. For reference in this process we have included a schematic STEAM sequence diagram.

STEAM sequence diagram

The diagram has a black line denoting RF events (RF pulses and the echo that is formed), and three coloured gradient axes: x, y, and z. In this simple sequence the same 90-degree pulse is repeated three times to form a 'stimulated' echo. Each pulse has an associated slice select gradient, one for each axis, all with the same gradient strength (the voxel has equal dimensions in x, y, and z). Before, or after, the slice-select gradient is a rephasing gradient (dark shaded area) with area equal to half the slice select gradient (light shaded area).

Sequence blocks

At the core of the sequence description format, an MRS sequence is split up into blocks containing a single RF pulse, associated gradients, and a time delay. The next three diagrams show each of the three sequence blocks in this STEAM sequence. In the sequence description we will describe the RF and gradients in each of the highlighted areas.

First block

Second block

Third block

RF, delays, & rephaseAreas

Three fields define the majority of the sequence information in the JSON file. These are RF, delays, & rephaseAreas. Try inspecting the packaged sequence description file in a text editor. Take a look at each of those parameters and what data they contain.

You will find that RF contains three blocks of almost identical information. Each block encodes one of the three RF pulses (Pulse 1, Pulse 2, and Pulse 3) using the following fields:

The delays field is a list with a single delay value per block. In this sequence we have three blocks with three delay times as marked in the figures above.

The rephaseAreas field is a 3 (x, y, z) by Nblocks array. This array encodes the areas of the rephase gradients. During the first block there are two rephase gradients of equal area on the x and y axes([-5.145e-03, -5.145e-03, 0.000e+00]), in the second block there are no rephase areas ([ 0.000e+00, 0.000e+00, 0.000e+00]), in the third block there is a single rephase gradient on the z axis ([ 0.000e+00, 0.000e+00, -5.145e-03]). Note that the areas are negative as the slice selection gradients all have positive magnitude.

CoherenceFilter

Typically as SVS sequences are repeated to build up temporal averages a series of 'spoiler' gradients are changed incrementally to ensure that unwanted coherence pathways are prevented from appearing in the final averaged spectrum (for example due to imperfect pulses). To copy this approach in simulation would require multiple (tens of) repeated simulations to be run, each with complex gradient structure. Instead FSL-MRS implements a coherence filter to select only the desired coherence pathway.

A discussion of coherence pathways goes beyond this practical, but in brief we want to select a single sequence-dependent pathway from the many that are generated by multiple RF pulses. For STEAM and spin-1/2 systems this corresponds to the [1, 0, -1] pathway. An excellent resource for this is Landheer & Juchem's work. For this, and all other, STEAM sequences we set the coherenceFilter field to [1, 0, -1]. This means that after each RF pulse and delay only the coherence in the filter is allowed to proceed.

STEAM coherence selection

What coherence filter should be used for the PRESS sequence (90-180-180)?

Incorrect! After the first 90 pulse, we apply a 180, which means the desired pathway is now also rotating, so the middle part should be +/-1
Correct! This could also have been [1,-1,1], but by convention, the last part should be -1, i.e. counter-clockwise rotation in the transverse plane.
Incorrect! The last number cannot be zero, as this means no signal!

Spatial resolution parameters (x, y, z, resolution)

For accurate basis spectra, the simulation must be carried out over a fine grid of spatial points, before summation in a final step. We therefore tell the simulation over what spatial grid to simulate. A good recommendation is to set the grid in each dimension (x, y, & z) to twice the voxel size. Here the voxel size was 25 mm isotropic, thefore we set each field to [-25,25] so that simulations take place 25 mm around the centre in each direction (50 mm in total).

The resolution parameter then sets how coarse or fine the grid is for simulation. Always start with a coarse grid (e.g. 5-10) for debugging and tests, as this will speed up the process. A final simulation should be carried out with many points in each direction; in the 40-60 point range.

B0 & centralShift

The B0 parameter sets the main magnetic field strength, which should match the field strength of your scanner. Note that many scanners are not quite the field strength advertised. A 3 tesla scanner might actually be 2.89 T, or a 7 tesla 6.98 T. This information can be found by inspecting the data which the simulation is being carried out for i.e. by running mrs_tools info on the raw data.

The centralShift parameter indicates where the central frequency of the scanner was set during any acquisition. Typically, for proton MRS this would be set to the water frequency. Hence to reference between the chemical shift scale - with a somewhat arbitrary zero reference - and the one used experimentally we set this parameter to the chemical shift of water: 4.65 ppm.

Rx_* parameters

There are four parameters which are used to control the appearance of the simulated basis spectra. These are as follows:

The total simulated time (Rx_Points * 1/Rx_SW) should be high, so that the spectra can be interpolated down to the actual acquisition parameters. Here we have set Rx_SW to 6000 Hz and Rx_Points to 8192 for a total simulated time of 1.37 s.

Other parameters

Some of the remaining parameters, sequenceName and description, allow free form text description of the sequence being simulated.

The units parameters: RFUnits, GradUnits, and spaceUnits, allow the user to specify what units some of the parameters are defined in. See the online documentation for more information.

Open up the provided sequence description in an editor and turn down the simulation resolution from [30, 30, 30] to [5, 5, 5]. This should make the next step faster, but more inaccurate; fine for this demo.


Simulation

Compared to the previous section running the simulator is simple. The simulator is called using fsl_mrs_sim. The user must supply the sequence description and a list of metabolites (or custom described spin systems) to the simulator. The simulator knows about a predefined list of metabolites, meaning the user can just specify their name.

fsl_mrs_sim -b metabs.txt -p -2.0 -o my_steam_basis steam.json

In addition to a text list of metabolites supplied in metabs.txt we have added a -p -2.0 flag and -o my_steam_basis. The first automatically phases the spectra (which otherwise would have arbitrary phase) using a peak at -2.0 ppm from the central shift (I.e. 4.65 - 2.0 = 2.65 ppm). The second -o specifies an output location. Try looking at the created basis spectrum, using mrs_tools vis.

mrs_tools vis my_steam_basis/

Now let us compare the basis under different settings. First, we will look at the effect of the simulation grid. We will then look at what happens for different echo times.

Create a copy of the JSON file but change the grid resolution to 40x40x40. Save it under a different name (e.g. steam_40res.json). To save time, we will only simulate a few metabolites (using the -m option instead of -b):

fsl_mrs_sim -m Glu,Lac -p -2.0 -o my_steam_basis steam.json
fsl_mrs_sim -m Glu,Lac -p -2.0 -o my_steam_basis_40res steam_40res.json
We chose Lactate in this example as it is at the edge of the spectrum away from the central frequency, and thus more likely to show this coarse-gridding chemical shift artefacts.

Compare the two results using mri_tools vis.

Now create another JSON file but this time with a longer echo time. Looking at the sequence diagram at the top, you should be able to see that the echo time is composed of the first and last delays, plus half of the first pulse duration, half of the second, and the full duration of the third pulse, adding up to TE=11ms. Let's make this a 50ms echo time by increasing the first and last delays by the same amount ((50-11)/2=19.5ms=0.0195s). Save the result in a file called steam_TE50.json.

fsl_mrs_sim -m Glu,Lac -p -2.0 -o my_steam_basis_50ms steam_50ms.json

Compare the two results using mri_tools vis.



Why does the appearance of the spectra change so much when we change the echo time?

Incorrect! T2 decay can affect the amplitude of the signal. T2* decay also results in line broadening, but here the most visible effect is peak splitting.
Correct! J-evolution and J-coupling are MRS phenomena that result in splitting of the peaks over time due to interactions between nuclei. The longer the echo time, the more J-evolution affects the spectra.
Incorrect! Maybe you have run the simulation with the wrong sequence descriptions?

Macromolecules

Macromolecular basis sets are typically created by empirical measurement of metabolite-nulled spectra. The spectra should be measured using a very similar sequence to the target sequence, in a similar population to the study population, and from a similar anatomical region. The full process is beyond the scope of this practical. However, fsl_mrs_sim can be easily made to incorporate a pre-measured macromolecule basis into one that it is simulating.

Re-run the above command but add -MM MM.json. MM.json contains a single MM basis spectrum.

fsl_mrs_sim -b metabs.txt -p -2.0 --MM MM.json -o my_steam_basis_with_mm steam.json

Once again look at the result using mrs_tools vis. The basis set should now contain a MM spectrum.

If you don't have access to a measured MM spectrum, you can use the default one in FSL_MRS, which consists of several broad peaks at specific frequencies and with predefined relative amplitudes

To do this, you can first use the simulator to create your basis, then use basis_tools add_set to add a MM basis file to your basis folder:

fsl_mrs_sim -b metabs.txt -p -2.0 -o my_steam_basis steam.json
basis_tools add_set --add_MM my_steam_basis my_steam_basis_withMM

Look at the new basis and try to identify the new MM spectrum. Compare that with the measured MM spectrum (MM.json). You should be able to see that the default MM consists of separate peaks.


The End!