Differences between revisions 6 and 11 (spanning 5 versions)
Revision 6 as of 2006-05-19 14:04:46
Size: 11524
Editor: JenniPacheco
Comment:
Revision 11 as of 2006-05-22 22:56:43
Size: 7738
Editor: JenniPacheco
Comment:
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
= Fixing a bad Skull Strip =
Occasionally, the skull stripping step either removes more than just the skull, causing part of the brain to be removed as well, or too little, leaving behind portions of the skull. Both of these problems need to be corrected before continuing to the next step, either by manually editing the volumes or by adjusting input parameters to the skull stripping step, and running the skull strip again until a good result is obtained. Often the sagittal view reveals skull strip failures. Note that the inflated 2D surface is a less reliable gauge of skull strip failure unless large portions of the brain are missing, or lots of skull is retained. 
= Fixing a bad skull strip =
Occasionally, the skull stripping step either removes more than just the skull, causing part of the brain to be removed as well, or too little, leaving behind portions of the skull. Both of these problems need to be corrected before continuing to the next step, either by manually editing the volumes or by adjusting input parameters to the skull stripping step, and running the skull strip again until a good result is obtained. Often the sagittal view reveals skull strip failures. Note that the inflated 2D surface is a less reliable gauge of skull strip failure unless large portions of the brain are missing, or lots of skull is retained.
Line 12: Line 12:
In general there are two ways to fix a volume when there is something missing from the cortex or cerebellum, you can clone the missing pieces in manually or you can adjust the parameters of mri_watershed to do it automatically. For this case, because there is such a lot missing on so many slices you should adjust the parameters of mri_watershed.   In general there are two ways to fix a volume when there is something missing from the cortex or cerebellum, you can clone the missing pieces in manually or you can adjust the parameters of mri_watershed to do it automatically. For this case, because there is such a lot missing on so many slices you should adjust the parameters of mri_watershed.
Line 14: Line 14:
== 1.0 Adjusting Watershed Parameters == == 1.0 Adjusting watershed parameters ==
Line 18: Line 18:
{{{
recon-all -skullstrip -wsthresh <h> -subjid <subject name>
}}}
'''recon-all -skullstrip -wsthresh <h> -subjid <subject name>''' where <h> is replaced with the preflooding height you'd like to use and <subject name> is replaced with your subject.
Line 30: Line 29:
Take a look at your output volume (brainmask.mgz has been changed) along with the original T1 volume (T1.mgz), and verify the result of the new skull stripping is correct.  Take a look at your output volume (brainmask.mgz has been changed) along with the original T1 volume (T1.mgz), and verify the result of the new skull stripping is correct.
Line 36: Line 35:
it should look like this: [[BR]] It should look like this: [[BR]]
Line 38: Line 37:
Line 46: Line 44:
and you should see this:[[BR]]  and you should see this:[[BR]]
Line 49: Line 47:
Now we will take another look at the second volume we looked at, where part of the cerebellum had been removed. For this example, since there is so much skull remaining, we want to lower the watershed threshold, so use the command: For this example, since there is so much skull remaining, we want to lower the watershed threshold, so you could use the command:
Line 51: Line 50:
recon-all -skullstrip -wsthresh 5  -subjid 111_watershed_before recon-all -skullstrip -wsthresh 5 -subjid 111_watershed_before
Line 54: Line 53:
Take a look at your output volume (brain.mgz has been changed) along with the original T1 volume (T1.mgz), and verify the result of the new skull stripping is correct.  Take a look at your output volume (brainmask.mgz has been changed) along with the original T1 volume (T1.mgz), and verify the result of the new skull stripping is correct.
Line 62: Line 61:
'''2.3 Other watershed options''' [[BR]] '''1.3 Other watershed options''' [[BR]]
Line 68: Line 67:
'''2.4 Reprocessing the data''' [[BR]] '''1.4 Reprocessing the data''' [[BR]]
Line 70: Line 69:
If you make changes to the brain.mgz volume, you can re-start the recon-all process here using the following command:

{{{
recon-all -autorecon2 -subjid <subject name>
}}}

'''1.2 Some skull still remains''' [[BR]]

Sometimes the skull strip will leave pieces of skull in the brainmask volume. Subject 111 is an extreme example of this, it can be the case that there is just a bit of skull left. To fix this you would

Open the output volume and T1 from 111_before simultaneously:
If you make changes to the brainmask.mgz volume, you can re-start the recon-all process from this point by using the following command:
Line 83: Line 72:
tkmedit 111_watershed_before brain.mgz -aux T1.mgz recon-all -autorecon2 -subjid <subject name>
Line 86: Line 75:
Make sure that the "Edit Voxels" button is still selected. Removing voxels is very similar to painting in voxels, except you use the right mouse button instead of the middle button. Use Ctrl-1 and Ctrl-2 to cycle between the volumes. Find a place in the image where skull remains. Use the right mouse button to delete the voxels. Continue on the other slices until all skull is removed. Save your volume.

Ctrl-z and '''Edit -> Undo Last Edit''' in tkmedit only allow you to go back one edit. If you need to erase a mistake made when painting in voxels, you can use the right mouse button to delete them again. If you remove too many voxels, you can use the clone tool to paint areas back in from the original T1 volume, similar to painting in voxels in section 1.1.

=== 1.0 Manual Editing ===
== 2.0 Manual editing ==
Line 94: Line 79:
'''1.1 Part of the brain is missing'''  '''2.1 Part of the brain is missing'''
Line 96: Line 81:
If part of the brain is missing, it is typically missing one hemisphere or the entire cerebellum. Open the output volume from the skull stripping step (brain.mgz) and the original T1 volume (T1.mgz) simultaneously: Sometimes there will be small regions missing from the pons or cerebellum, or from part of the cortex itself. To fix these you'd need to open the output volume from the skull stripping step (brainmask.mgz) and the original T1 volume (T1.mgz) simultaneously.

'''For this following example we will use a subject with a missing cerebellum to demonstrate the tools, but in reality this is not an example of something you would want to edit by hand.'''
Line 99: Line 86:
tkmedit 091_watershed_before brain.mgz -aux T1.mgz tkmedit 091_watershed_before brainmask.mgz -aux T1.mgz
Line 102: Line 89:
Switch back and forth between the two volumes a few times with Ctrl-1 and Ctrl-2, and use the arrow keys to view the different slices. Notice that a large part of the cerebellum has been stripped away along with the skull around slice 89.   Switch back and forth between the two volumes a few times with Ctrl-1 and Ctrl-2, and use the arrow keys to view the different slices. Notice that a large part of the cerebellum has been stripped away along with the skull around slice 91.
Line 104: Line 91:
attachment:watershedsm.jpg

In the tkmedit toolbar, go to: 
In the tkmedit toolbar, go to:
Line 110: Line 95:
Set Mode to "Clone", and Clone Source to "Aux Volume". Click the Close button to close the configuration window. Go to: Set Mode to "Clone", and Clone Source to "Aux Volume". Click the Close button to close the configuration window. You can also change the size and shape of your brush, to do this go to:
Line 114: Line 99:
Set Radius to 4, and Shape to "Circle". Select a radius and shape that you are comfortable using. Close the configuration menu, and click the "Edit Voxels" button in tkmedit toolbar.
Line 116: Line 101:
Close the configuration menu, and click the "Edit Voxels" button in tkmedit toolbar. Use Ctrl-1 and Ctrl-2 to cycle between the two volumes. Find a place in the image where the cerebellum is missing in the output volume, then use the middle button on the mouse to paint in cerebellum from the auxiliary volume. Cycle back and forth between the volumes frequently so you know where you are.
Line 118: Line 103:
Use Ctrl-1 and Ctrl-2 to cycle between the two volumes. Find a place in the image where the cerebellum is missing in the output volume, then use the middle button on the mouse to paint in cerebellum from the auxiliary volume. Cycle back and forth between the volumes frequently so you know where you are.

attachment:watershed2.jpg

Continue painting until the slice is no longer missing part of the brain. Repeat for the other slices in the output volume. Go to '''File -> Save Main Volume As...''' and save your output. You can check your results by looking at the brain.mgz volume in the 091_after directory with tkmedit.

'''1.2 Some skull still remains''' [[BR]]

For this example, there is far to much skull remaining to remove it with manual edits, so we will use this simply as an example to demonstrate how the skull would be removed. The manual intervention should be used only when there are a few slices with extra skull remaining.

Open the output volume and T1 from 111_before simultaneously:

{{{
tkmedit 111_watershed_before brain.mgz -aux T1.mgz
}}}

Make sure that the "Edit Voxels" button is still selected. Removing voxels is very similar to painting in voxels, except you use the right mouse button instead of the middle button. Use Ctrl-1 and Ctrl-2 to cycle between the volumes. Find a place in the image where skull remains. Use the right mouse button to delete the voxels. Continue on the other slices until all skull is removed. Save your volume.

Ctrl-z and '''Edit -> Undo Last Edit''' in tkmedit only allow you to go back one edit. If you need to erase a mistake made when painting in voxels, you can use the right mouse button to delete them again. If you remove too many voxels, you can use the clone tool to paint areas back in from the original T1 volume, similar to painting in voxels in section 1.1.

=== 2.0 Adjusting Watershed Parameters ===

The watershed algorithm is used during the skull stripping step to find a boundary between the brain and skull. The mri_watershed program uses a default preflooding height of 25 percent. If we want the algorithm to be more conservative (i.e. if part of the brain has been removed), you will want to make that number larger than 25. If you want the algorithm to be more aggressive (i.e. part of the skull has been left behind), you will want to make the height less than 25. There aren't any hard and fast rules about how to select your height value. You can adjust the preflooding height by passing the following flag to recon-all:

{{{
recon-all -skullstrip -wsthresh <h> -subjid <subject name>
}}}

'''2.1 Part of the brain is missing'''

Now we will take another look at the first volume we looked at, where part of the cerebellum had been removed. You can adjust the watershed threshold by passing the -wsthresh flag to recon-all. In this instance, since too much was removed, we want to raise the watershed threshold so use the command:

{{{
recon-all -skullstrip -wsthresh 35 -subjid 091_watershed_before
}}}

Take a look at your output volume (brain.mgz has been changed) along with the original T1 volume (T1.mgz), and verify the result of the new skull stripping is correct.

{{{
tkmedit 091_watershed_before brain.mgz -aux T1.mgz
}}}
Continue painting until the slice is no longer missing part of the brain. Repeat for the other slices in the output volume. Go to '''File -> Save Main Volume As...''' and save your output.
Line 161: Line 106:
Now we will take another look at the second volume we looked at, where part of the cerebellum had been removed. For this example, since there is so much skull remaining, we want to lower the watershed threshold, so use the command:
{{{
recon-all -skullstrip -wsthresh 5 -subjid 111_watershed_before
}}}
If there are small pieces of skull still remaining on only a few slices you can manually remove the voxels. To do this make sure that the "Edit Voxels" button is still selected. Removing voxels is very similar to painting in voxels, except you use the right mouse button instead of the middle button. Use Ctrl-1 and Ctrl-2 to cycle between the volumes. Find a place in the image where skull remains. Use the right mouse button to delete the voxels. Continue on the other slices until all skull is removed. Save your volume.
Line 166: Line 108:
Take a look at your output volume (brain.mgz has been changed) along with the original T1 volume (T1.mgz), and verify the result of the new skull stripping is correct.

{{{
tkmedit 111_watershed_before brain.mgz -aux T1.mgz
}}}

You can compare this to the brain volume in 111_watershed_after to see that your changes look the same.

'''2.3 Other watershed options''' [[BR]]
To inform mri_watershed to use an atlas:
{{{
recon-all -skullstrip -wsatlas -subjid 111_watershed_before
}}}

'''2.4 Reprocessing the data''' [[BR]]

If you make changes to the brain.mgz volume, you can re-start the recon-all process here using the following command:

{{{
recon-all -autorecon2 -subjid <subject name>
}}}
Ctrl-z and '''Edit -> Undo Last Edit''' in tkmedit only allow you to go back one edit. If you need to erase a mistake made when painting in voxels, you can use the right mouse button to delete them again. If you remove too many voxels, you can use the clone tool to paint areas back in from the original T1 volume, similar to painting in voxels in section 2.1.
  • To follow this exercise exactly be sure you've downloaded the [wiki:FsTutorial/Data tutorial data set] before you begin. If you choose not to download the data set you can follow these instructions on your own data, but you will have to substitute your own specific paths and subject names.

Fixing a bad skull strip

Occasionally, the skull stripping step either removes more than just the skull, causing part of the brain to be removed as well, or too little, leaving behind portions of the skull. Both of these problems need to be corrected before continuing to the next step, either by manually editing the volumes or by adjusting input parameters to the skull stripping step, and running the skull strip again until a good result is obtained. Often the sagittal view reveals skull strip failures. Note that the inflated 2D surface is a less reliable gauge of skull strip failure unless large portions of the brain are missing, or lots of skull is retained.

Subject 1 has a poor skull strip, an entire hemisphere of the cerebellum has been stripped away along with the skull. This page will walk you through the process of fixing this particular subject and also offer suggestions for fixing other common skull stripping problems.

If you look at coronal slice 91 for subject1_before you can see that the brainmask.mgz volume (the left picture) is missing the right hemisphere of the cerebellum and that it is present in the T1.mgz volume (the right picture):

attachment:subj1_brainmask.jpg attachment:subj1_T1.jpg

In general there are two ways to fix a volume when there is something missing from the cortex or cerebellum, you can clone the missing pieces in manually or you can adjust the parameters of mri_watershed to do it automatically. For this case, because there is such a lot missing on so many slices you should adjust the parameters of mri_watershed.

1.0 Adjusting watershed parameters

The watershed algorithm is used during the skull stripping step to find a boundary between the brain and skull. The mri_watershed program uses a default preflooding height of 25 percent. If we want the algorithm to be more conservative (i.e. if part of the brain has been removed), you will want to make that number larger than 25. If you want the algorithm to be more aggressive (i.e. part of the skull has been left behind), you will want to make the height less than 25. There aren't any hard and fast rules about how to select your height value. You can adjust the preflooding height by passing the following flag to recon-all:

recon-all -skullstrip -wsthresh <h> -subjid <subject name> where <h> is replaced with the preflooding height you'd like to use and <subject name> is replaced with your subject.

1.1 Part of the brain is missing

Now we will take another look at the first volume we looked at, where part of the cerebellum had been removed. You can adjust the watershed threshold by passing the -wsthresh flag to recon-all. In this instance, since too much was removed, we want to raise the watershed threshold so use the command:

recon-all -skullstrip -wsthresh 35 -subjid subject1_before

Take a look at your output volume (brainmask.mgz has been changed) along with the original T1 volume (T1.mgz), and verify the result of the new skull stripping is correct.

tkmedit subject1_before brainmask.mgz -aux T1.mgz

It should look like this: BR attachment:subj1_bm_after.jpg

1.2 Some skull still remains BR Sometimes the skull strip will leave pieces of skull in the brainmask volume. Subject 111 is an extreme example of this, it can be the case that there is just a bit of skull left. Open subject 111 to see what it looks like

tkmedit 111_watershed_before brainmask.mgz

and you should see this:BR attachment:111_watershed_before.jpg

For this example, since there is so much skull remaining, we want to lower the watershed threshold, so you could use the command:

recon-all -skullstrip -wsthresh 5 -subjid 111_watershed_before

Take a look at your output volume (brainmask.mgz has been changed) along with the original T1 volume (T1.mgz), and verify the result of the new skull stripping is correct.

tkmedit 111_watershed_before brain.mgz -aux T1.mgz

You can compare this to the brain volume in 111_watershed_after to see that your changes look the same.

1.3 Other watershed options BR To inform mri_watershed to use an atlas:

recon-all -skullstrip -wsatlas -subjid 111_watershed_before

1.4 Reprocessing the data BR

If you make changes to the brainmask.mgz volume, you can re-start the recon-all process from this point by using the following command:

recon-all -autorecon2 -subjid <subject name>

2.0 Manual editing

When the skull stripping process has left just a few slices with either missing brain regions or too much skull you can edit these manually using tkmedit.

2.1 Part of the brain is missing

Sometimes there will be small regions missing from the pons or cerebellum, or from part of the cortex itself. To fix these you'd need to open the output volume from the skull stripping step (brainmask.mgz) and the original T1 volume (T1.mgz) simultaneously.

For this following example we will use a subject with a missing cerebellum to demonstrate the tools, but in reality this is not an example of something you would want to edit by hand.

tkmedit 091_watershed_before brainmask.mgz -aux T1.mgz

Switch back and forth between the two volumes a few times with Ctrl-1 and Ctrl-2, and use the arrow keys to view the different slices. Notice that a large part of the cerebellum has been stripped away along with the skull around slice 91.

In the tkmedit toolbar, go to:

Tools -> Configure Volume Brush...

Set Mode to "Clone", and Clone Source to "Aux Volume". Click the Close button to close the configuration window. You can also change the size and shape of your brush, to do this go to:

Tools -> Configure Brush Info...

Select a radius and shape that you are comfortable using. Close the configuration menu, and click the "Edit Voxels" button in tkmedit toolbar.

Use Ctrl-1 and Ctrl-2 to cycle between the two volumes. Find a place in the image where the cerebellum is missing in the output volume, then use the middle button on the mouse to paint in cerebellum from the auxiliary volume. Cycle back and forth between the volumes frequently so you know where you are.

Continue painting until the slice is no longer missing part of the brain. Repeat for the other slices in the output volume. Go to File -> Save Main Volume As... and save your output.

2.2 Some skull still remains BR If there are small pieces of skull still remaining on only a few slices you can manually remove the voxels. To do this make sure that the "Edit Voxels" button is still selected. Removing voxels is very similar to painting in voxels, except you use the right mouse button instead of the middle button. Use Ctrl-1 and Ctrl-2 to cycle between the volumes. Find a place in the image where skull remains. Use the right mouse button to delete the voxels. Continue on the other slices until all skull is removed. Save your volume.

Ctrl-z and Edit -> Undo Last Edit in tkmedit only allow you to go back one edit. If you need to erase a mistake made when painting in voxels, you can use the right mouse button to delete them again. If you remove too many voxels, you can use the clone tool to paint areas back in from the original T1 volume, similar to painting in voxels in section 2.1.

FsTutorial/SkullStripFix_tktools (last edited 2014-03-31 04:38:38 by 130)