Making Edits to the White Matter

Sometimes the white matter is not segmented correctly: sometimes voxels that should be white matter are excluded, and other times voxels that should not be white matter are included in error. Either of these occurences can be fixed with simple manual edits. Below you will find examples of a few of the common problems and how to fix them. For some people it is easiest to see these problems when looking at the inflated surface in tksurfer. Others can pick them out while viewing the volumes in tkmedit. Either method is fine for identifying these problems. However they can only be fixed using tkmedit with the wm.mgz volume.

Geometric inaccuracy due to brain lesion

Subject 2 is an example of white matter being excluded from the wm.mgz volume due to the presence of a brain lesion. This page will walk you through fixing this specific example as well as other common problems with the wm.mgz volume.

First, make sure you have subject 2 loaded in tkmedit:

setenv SUBJECTS_DIR $FREESURFER_HOME/subjects/buckner_data/tutorial_subjs
tkmedit subject2_before brainmask.mgz lh.white -aux T1.mgz -aux-surface rh.white

If you look at coronal slice 155 you will notice an area as you get to the anterior horn of the lateral ventricle where the white surface (yellow line) does not follow the surface of the brain, but in fact cuts into it. This geometric inaccuracy is caused by a lesion near the lateral ventricle where white matter has been marked as non-white matter. In this case, the autofill routine has already filled the ventricles, but the brain pathology resulted in an incorrect segmentation causing this hole in the surfaces.

attachment:008_before_brainlesion2.jpg

You can see this as a dimple or hole on the inflated surface in tksurfer too (see next image). If not already open, in a second terminal window, open the lh surface in tksurfer:

setenv SUBJECTS_DIR $FREESURFER_HOME/subjects/buckner_data/tutorial_subjs
tksurfer subject2_before lh inflated &

attachment:008_before_lesion_surfer2.jpg

With the wm/mgz volume loaded into tkmedit you can see that this area has been left out of the wm volume completely.

attachment:008_before_brainlesionWM2.jpg

To fix this problem you will need to fill in the missing voxels in the wm.mgz volume. First, it's a good idea to use the arrow keys to scroll through the individual slices in the volume until you get a good idea of where the problem starts and ends. You will want to start filling in voxels when the inaccuracy appears, and keep filling them in slice by slice until the problem is no longer visible. The coronal view and a brush radius of one or two are good settings for painting in voxels. Zoom In and Out either by using the icons in the [wiki:FsTutorial/Tools tkmedit] Tool window or by Ctrl-right mouse button (Zoom In) and Ctrl-left mouse button (Zoom Out) to help you see the inaccuracy.

To begin editing voxels, click on the Edit Voxels Tool button attachment:icon_edit_volume.gif, then go to Tools -> Configure Brush Info... Set the radius to 2, and Shape to be Circle. Use the middle button on your mouse to begin painting in the voxels. If you fill in too many voxels, the right mouse button acts as an eraser. Start with slice 155, when you are done filling the region, your slice should look like this:

attachment:lesion-fixed.jpg

Go to the next slice, and fill in this slice in the same way. You will notice that the hole is not completely enclosed. To see where the boundary should be, switch back and forth between the brainmask.mgz and wm.mgz volume with Ctrl-1 and Ctrl-2. Use the brainmask.mgz volume as a guide, and make the boundary of the voxels that you paint in correspond as closely as possible to the boundaries suggested in the brain volume. You will need to continue filling in slices in this fashion until the region is completely filled in. If you would like to compare your edits to ones that have been done for you you can open a second tkmedit with the subject2_after wm.mgz volume, and for each slice check your results with the corresponding slice in the subject2_after volume. The subject2_after volume has the region filled in both the right and left hemispheres. At any time, you can save the changes you’ve made to the wm volume by selecting ‘Save Volume’ in [wiki:FsTutorial/Tools tkmedit]’s ‘File’ menu, and clicking ‘OK’. You can verify your results by viewing the changes made to the subject2_after wm volume

Tips:BR

After you have saved all of your edits, you could recreate the final surfaces with the command:

recon-all -autorecon2-wm -subjid subject2_before

This will take a long time to run, so there is no need for you to run it now.

Non-white matter classified as white matter

Sometimes non-white matter (i.e., skull) is included as white matter. To load in the example use this command:

tkmedit 111_manual_edits_before wm.mgz lh.white -aux brainmask.mgz -aux-surface rh.white

Scroll through the brainmask.mgz volume slices and as you get towards the frontal lobe you will see a group of voxels included as white matter. They are surrounded by the white surface (yellow line). This group lies outside of the pial surface (red line) and is clearly not white matter. In order to correct this inaccuracy it is necessary to delete the voxels which are not part of the white matter.

attachment:111_before_frontallobeBRAIN.jpg

attachment:frontlobe1.jpg

Using Ctrl-1 and Ctrl-2 to switch back and forth between the brain and wm volumes, you can clearly see that this region should not be labeled as white matter. To delete these voxels, click the Edit Voxels Tool attachment:icon_edit_volume.gif button in the tkmedit toolbar, and put your mouse cursor over the voxels you want to delete. Delete them with the right mouse button. This is what slice 179 should look like after you have deleted the errant voxels:

attachment:frontlobe2.jpg

Go through the slices with the up and down arrows, continuing to delete voxels until the inaccuracy is no longer there. (It spans approximately 30 slices.) You can check your results by looking at the 111_manual_edits_after wm.mgz volume in tkmedit. Note that in this volume, only a few of the voxels have been removed from each slice, instead of removing the entire inaccuracy. This is because you only need to remove as many voxels as is necessary for the segmentation to classify this region as non-white matter. Until you are more comfortable with editing inaccuracies, go ahead and remove all of the voxels. More practice will give you a better feel for how many voxels need to be removed.

Once you have made all the edits to the wm.mgz volume you would regenerate the surfaces using the following command:

recon-all -autorecon2-wm -autorecon3 -subjid 111_manual_edits_before

Lateral Ventricle

The automatic edits made to to wm volume will fill the lateral ventricles. On occasion they are not filled entirely. Continue looking at 111_manual_edits_before in tkmedit, with the lh.white surface loaded on top. As you scroll to the posterior portions of the brainmask.mgz you will see the white surface (yellow line) start to follow the edge of the ventricle (look around coronal slice 53).

attachment:111_before_ventricleBRAIN.jpg

When you toggle between wm and the brain volume, you can see that this portion of the ventricle should be filled in. This inaccuracy can be corrected in the same fashion as the inaccuracies above, using the Edit Voxels tool to fill in the missing voxels.

attachment:occlobe1.jpg

When you are finished filling in slice 53, it should look like this:

attachment:occlobe2.jpg

Continue filling in this region until the hole disappears. The geometric inaccuracy is present from slices 50 through 168. Once you have fully edited the wm.mgz volume you would regenerate the surfaces with the following command:

recon-all -autorecon2-wm -autorecon3 -subjid 111_manual_edits_before

The remaining inaccuracies are other examples of commonly seen problems with brain topology. You may choose to correct these on your own, using the 111_manual_edits_after volume as a guide for what your finished result should look like.