Structural Analysis Extras Practical

This practical contains an overview of some advanced structural analysis methods. It leads you through some of the more advanced usage and concepts in FAST, FIRST and SIENA. Feel free to do the sections in a different order if you are particularly interested in any of them.

Contents:

Multi-Channel FAST
An introduction to the multi-channel version of FAST - for use with multiple acquisitions (e.g. T1-wt, T2-wt, PD, ...).
FIRST Revisited
Looking at the "uncorrected" FIRST outputs.
FIRST Vertex analysis
An introduction to vertex analysis using fsl_utils.
SIENA "LOOK AT YOUR DATA"
Investigate some problem cases.

Multi-Channel FAST

cd ~/fsl_course_data/seg_struc/fast

Multi-channel segmentation is useful for when the contrast or quality of a single image is insufficient to give a good segmentation. Typically, this type of segmentation is not needed for healthy controls with good T1-weighted images, as the single channel results are good and are often even better than the multi channel results. However, when pathological tissues/lesions are present, or when the T1-weighted image quality is not good, multi-channel segmentation can take advantage of the extra contrast between tissue types in the different images and give better results.

In sub2_t1 and sub2_t2 are T1-weighted and T2-weighted images of the same subject. Are they well aligned? You can get an easy non-interactive combined view of two images (which must have the same image dimensions) with slices:

slices sub2_t1 sub2_t2

They look reasonably aligned in sagittal and coronal view, but axial views clearly show misalignment between scans (if you cannot clearly see the axial slices, open the same two images in FSLeyes). Before running multi-channel FAST it is necessary to use FLIRT to register the data. Start by running Bet on each image to remove the non-brain structures, producing sub2_t1_brain and sub2_t2_brain. Note that it is OK if one of the brain extraction results includes non-brain matter (e.g. eyeballs) but the other is accurate, since the brain mask used by FAST will be the intersection of the two masks.

Start the FLIRT GUI:

Flirt &

For this example use the following settings:

All the other FLIRT defaults should be fine, but you could save some processing time by telling FLIRT that the images are Already virtually aligned (in Advanced > Search > Images). FLIRT will take a minute or two to run.

Load sub2_t1_brain and sub2_t2_to_t1_brain into FSLeyes to check the result of the registration. Change the colour map for the higher image in the list to Red-Yellow and increase its transparency so that you can see how good the overlap is.

You can now forget sub2_t2.

Run Fast (with the Number of input channels set to 2) on the multi-channel brain-extracted images sub2_t1_brain and sub2_t2_to_t1_brain (or whatever you called these BET outputs). Asking for the default number of classes (3 - assumed to be GM/WM/CSF) gives poor results because bits of other tissues outside of the brain are given a class - so you should run with 4 classes; then results should be good. This takes a few minutes; move on to the next part of the practical and view the results once fast has finished running.

Advanced: FAST - Other Options

If you have time to spare after finishing the other practical parts then you can come back and test the effect of various FAST options, obtained by typing:

fast -h

You could also work out how to colour-overlay segmentation results onto the input image using the overlay command.


FIRST Revisited

Uncorrected segmentation output

cd ~/fsl_course_data/seg_struc/first

This follows on from the initial part of the FIRST practical above and assumes that run_first_all has been successfully run. Having considered the boundary corrected segmentation previously, we now turn to look at the uncorrected segmentation.

The uncorrected segmentation shows two types of voxels: ones that the underlying surface mesh passes through (boundary voxels) and ones that are completely inside the surface mesh (interior voxels). FIRST uses a mesh to model the structure when doing the segmentation, so converting this to a volume requires it to be split into boundary and interior regions like this.

We will now look at the uncorrected volumetric segmentations:

fsleyes con0047_brain con0047_all_fast_origsegs &

To view the segmentation better change the colourmap of the segmented image to Red-Yellow and make the Max display range value to 100 for this image. Note that you see the interior voxels and the boundary voxels in different colours. This is because the boundary voxels are labeled with a value equal to 100 plus that of the interior voxels. That is, the interior and boundary voxels for the left hippocampus are labeled 17 (the CMA label designation for left hippocampus) and 117 respectively.

The volume con0047_all_fast_origsegs is a 4D file containing each structure's segmentation in a separate 3D file. If you change the Volume control on FSLeyes to go from 0 to 1 then you will see the left amygdala result. These are separated in case these uncorrected segmentations overlap. Play with the opacity settings (or turn the segmentation on and off) to see how good the segmentation is.

These images require boundary correction which is done automatically by run_first_all. However, there are alternative methods for doing the boundary correction which you can specify with run_first_all or as a post-processing on the uncorrected image with first_boundary_corr, although the settings used by run_first_all have been chosen as the optimal ones based on empirical testing.


Vertex Analysis using first_utils

cd ~/fsl_course_data/seg_struc/first/shapeAnalysis

Vertex analysis (or shape analysis) looks at how a structure may differ in shape between two groups (e.g., patients and controls). It looks at the differences directly in the meshes, on a vertex by vertex basis. This is different from using a whole-structure summary measure like volume, as it allows us to visualise the region of the shape that differs as well as the type of shape difference.

first_utils tests the differences in vertex location - here we will look at the difference in the mean vertex location between two groups of subjects, but it can also look for correlations. It projects the vertex locations onto the normal vectors of the average surface, so that it is sensitive to changes in the boundary location.

Here we will use an example dataset consisting of 8 subjects (5 controls and 3 Alzheimer's patients) which we will do an analysis on. As the numbers are low it will have fairly low statistical power, but in this case it still shows a clear effect. A full analysis, on a larger set of subjects, would proceed in exactly the same way.

List the files in this directory - we have already run FIRST on each subject in order to get a segmentation of the left hippocampus. So you will see files such as:

con0047_brain.nii.gz
con0047_brain_to_std_sub.mat
con0047_brain_to_std_sub.nii.gz
con0047.com
con0047-L_Hipp_corr.nii.gz
con0047-L_Hipp_first.bvars
con0047-L_Hipp_first.nii.gz
con0047-L_Hipp_first.vtk
con0047.logs

Most of them should be familiar from the previous example. Because only a single structure was run, the uncorrected segmentation is saved as con0047-L_Hipp_first and the boundary corrected segmentation is saved as con0047-L_Hipp_corr (rather than the names used before in the case of multiple structures). However, for vertex analysis we will be using the .bvars files as they contain the information about the sub-voxel mesh coordinates.

digraph G { rankdir=LR node [shape=box]; 1 [label="Each subject's .bvars file"]; 2 [label="concat_bvars"]; 3 [label="Combined 4D .bvars file"]; 4 [label="Design matrix (design.mat)"]; 5 [label="first_utils"]; 6 [label="4D output image of all subject meshes"]; 1 -> 2; 2 -> 3; 3 -> 5; 4 -> 5; 5 -> 6; }

Running vertex analysis

In general, to run shape analysis, you need to do the following:

  1. To begin with, run FIRST on all subjects (this has already been done for you to save time). If you were running this yourself you would do it in the same way that we did in the previous section, specifying what structure(s) you are interested in (to do all 17 structures just leave out the -s option). We then use the .bvars files for the vertex analysis.
  2. Check that the segmentations worked. In order to visualise the segmentation outputs of FIRST on a large number of subjects it is useful to generate summary reports that can be assessed efficiently. This can be easily done using first_roi_slicesdir, which shows an ROI (with 10 voxel padding) around the structure of interest for each subject, summarised into a single webpage. In this case run:

    first_roi_slicesdir *brain.nii.gz *L_Hipp_first.nii.gz
    

    and then view the output index.html in a web browser (it will be created in a subdirectory called slicesdir/). Check that none of the segmentations have failed; make sure that you look at the axial, coronal and sagittal slices.

  3. Combine all the mode parameters (.bvars file) into a single file. Each structure (model) that is fit with FIRST will generate a separate .bvars file. For a given structure (e.g. hippocampus) combine all the relevant .bvars files using the concat_bvars script. Note that the order here is very important, as it must correspond to the order specified in the design matrix to be used later for statistical testing. For this example, combine the .bvars files (all of the left hippocampi) using the command:

    concat_bvars all.bvars *L_Hipp*.bvars
    
    This command should be run in the directory containing the bvars files, not the slicesdir subdirectory created in the previous step.

    which (due to alphabetical ordering) puts the 5 control subjects first, followed by the 3 subjects with the disease.

  4. Create a design matrix (Don't worry if you don't fully understand this part, we will cover this in more detail later in the course).The subject order should match the order in which the .bvars were combined in the concat_bvars call. The design matrix is most easily created using FSL's Glm tool (a single column file). To do this, start the Glm GUI (Glm_gui on mac). First, choose the Higher-level/non-timeseries design option from the top pull down menu in the small window. Next, set the # inputs option to be 8 (the number of subjects we have in this example).

    In the bigger window (of the Glm GUI) set the values of the EV (the numbers in the second column) to be -1 for the first five entries (our five controls) and +1 for the next three entries (our three patients). This will allow us probe the difference between groups. Leave the 'group' column as all ones. Once you've done this, go to the Contrasts and F-tests tab. Rename the t-contrast (C1) to 'group difference', but leave the value set for EV1 as 1. We also need to add an F-test. Change the number in the F-tests box to 1, and then highlight the button on the right hand side (under F1) to select an F-test that operates on the single t-contrast.This F-test will be the main contrast of interest for our vertex analysis as it allows us to test for differences in either direction.

    When this is all set up correctly, save everything using the Save button in the smaller Glm window. Choose the current directory and use the name design_con1_dis2 (as we will assume this is the name used below, although for your own studies you can use any name of your choice). Now exit the Glm GUI.

We are now ready to run first_utils and perform the vertex analysis.

We will do the analysis using --useReconMNI to reconstruct the surfaces in MNI152 space (though note that an alternative would be to reconstruct the surfaces in the native space using --useReconNative).

Perform the first part of vertex analysis using the command:

first_utils --usebvars --vertexAnalysis -i all.bvars \
  -o diff_con1_dis2_L_Hipp_mni -d design_con1_dis2.mat --useReconMNI
If you are running the first_utils command on a personal install of FSL, it may fail unless FSL is installed at /usr/local/fsl.

This first_utils command uses the combined bvars input, created above with concat_bvars, and the design matrix design_con1_dis2.mat. The other options specify that this command is to prepare an output for vertex analysis (since it can also do other things) in standard space (--useReconMNI).

Once first_utils has run you are now ready to carry out the cross-subject statistics. We will use randomise for this, as the FIRST segmentations are unlikely to have nice, indepedent Gaussian errors in them. Normally it is recommended to run at least 5000 permutations (to end up with accurate p-values), but with a small set of subjects like this there is a limit to how many unique permutations are available, so in this analysis all unique permutations will be run.

For multiple-comparison correction there are several options available in randomise and we will use the cluster-based one here (-F), although other options may be better alternatives in many cases. The call to randomise (using the outputs from first_utils, which includes a mask defining the boundary of the appropriate structure, as well as the design matrix and contrasts formed above) is:

randomise -i diff_con1_dis2_L_Hipp_mni.nii.gz \
  -m diff_con1_dis2_L_Hipp_mni_mask.nii.gz \
  -o con1_dis2_L_Hipp_rand -d design_con1_dis2.mat \
  -t design_con1_dis2.con -f design_con1_dis2.fts \
  --fonly -D -F 3
digraph G { rankdir=LR node [shape=box]; 1 [label="4D output image of all subject meshes (diff_con1_dis2_L_Hipp_mni.nii.gz)"]; 2 [label="Mask of ROI (boundary of structure; diff_con1_dis2_L_Hipp_mni_mask.nii.gz)"]; 3 [label="Design matrix (design_con1_dis2.mat)"]; 4 [label="Design t-test contrasts (design_con1_dis2.con)"]; 5 [label="Design f-test contrasts (design_con1_dis2.fts)"]; 6 [label="Statistical options (--fonly -D -F 3)"]; 7 [label="randomise"]; 8 [label="Statistics of interest (basename of con1_dis2_L_Hipp_rand)"]; 1 -> 7; 2 -> 7; 3 -> 7; 4 -> 7; 5 -> 7; 6 -> 7; 7 -> 8; }

Viewing vertex analysis output

The most useful output of randomise is a corrected p-value image, where the values are stored as 1-p (so that the interesting, small p-values appear "bright"). The corrected p-value file is the one containing corrp in the name. This correction is the multiple-comparison correction, and it is only this output which is statistically valid for imaging data - uncorrected p-values should not be reported in general, although they can be useful to look at to get a feeling for what is in your data. The statistically significant results are therefore the ones with values greater than 0.95 (p<0.05), and in this case the file is called: con1_dis2_L_Hipp_rand_clustere_corrp_fstat1.

To view the data in FSLeyes, on top of the standard brain, do the following:

fsleyes -std1mm \
  con1_dis2_L_Hipp_rand_clustere_corrp_fstat1 -cm red-yellow -dr 0.95 1 &

Note that this specifies the display range (0.95 to 1.0) and a useful colourmap (Red-Yellow) in order to easily see the results.

Find the hippocampus in this image and look to see where the significant differences in shape have been found using this vertex analysis. Normally we would not expect to find much in a group of 8 subjects, but these were quite severe AD cases and so the differences are very marked.

Some notes for running vertex analysis in practice


"LOOK AT YOUR DATA" - SIENA Problem Cases

We now look at 4 examples of "problem cases" - these were real cases that occurred in one study; they illustrate some of the problems/mistakes that sometimes occur.

Example 1

cd ~/fsl_course_data/seg_struc/siena_problems/eg1/S2_032_ax_to_S2_164_ax_siena

Open report.html in a web browser.

Look at the FLIRT A-to-B registration results. Can you tell what's wrong? If you're unsure, click here.

Example 2

cd ~/fsl_course_data/seg_struc/siena_problems/eg2/S2_039_ax_to_S2_142r_ax_siena

Open report.html in a web browser.

Look at the FLIRT A-to-B registration results. Can you tell what's wrong? If you're unsure, click here.

Example 3

cd ~/fsl_course_data/seg_struc/siena_problems/eg3/S2_080_ax_to_S2_121_ax_siena

Open report.html in a web browser.

Look at the FLIRT A-to-B registration results. Can you tell what's wrong? If you're unsure, click here.

Example 4

cd ~/fsl_course_data/seg_struc/siena_problems/eg4/S2_002_ax_to_S2_162_ax_siena

Open report.html in a web browser.

Look at the FLIRT A-to-B registration results. Can you tell what's wrong? If you're unsure, click here.


The End.