Segmenting a Contrast-Enhanced CT Volume
Medical image segmentation is the process of dividing a medical image into regions or segments that represent different tissue types or categories. The goal is to identify areas of interest, such as tumors, lesions, or other abnormalities. In this module, we use 3D Slicer to segment one of its sample datasets: the CTACardio Sample dataset.
Background information
Before we segment, we should have a reasonable understanding of the methodology used to acquire the volume:
What is a CT Angiogram?
Computed tomography angiography (also called CT angiography or CTA) is a CT technique used for angiography (blood vessel imaging). For CTA, you inject a contrast agent (e.g. iodine) into the patient's bloodstream to better visualize the arteries and veins throughout the human body.
For this segmentation project, we will take advantage of the added contrast to segment the kidneys and aorta.
Load Volume and Review
-
Click on "Download Sample Data" button:
-
Select "Download CTACardio"
-
Switch to the
Volumes
module -
Set the Active Volume to "CTACardio"
Volume Information for CTACardio
Volume and Voxel sizes: How many voxels in the volume and how large is each voxel?
- Volume Size: \(512 * 512 * 321 = 84,148,224\) voxels (~84 million)
- Voxel Size: \(0.93 * 0.93 * 1.25 = 1.08 mm^3\)
Are the voxels isotropic or anisotropic?
anisotropic
What is the dynamic range of the volume?
-1024 to 3532
Adjust Volume Display
In the Volumes module, under the Display Tab, select the CT-Abdomen preset:
Volume rendering
Volume rendering is a great way to determine which parts of the volume have high contrast
- Bring up the
Volume Rendering
module. - Select "CTACardio" volume in the Volume menu
- Click open the
eye
icon to render the volume
Volume Rendering Controls for CTACardio
Adjust Rendering
- Slide the Shift slider back and forth to reveal different aspects of the volume
- Notice how bright the veins are in the patients arm
- Slide the Shift slider to the left to reveal the oxygen tank sitting atop the patient's chest
- Select the "CT-Chest Contrast Enhanced" Preset
- Slide the Shift slider to the right to reveal the kidneys
Notice that the kidneys, heart, vasculature, bones all segment out at the similar intensity mappings. This means that it will not be possible to use a simple threshold to segment these organs individually
Optional: Crop volume down to the Right Kidney
Adjust the ROI to capture just the right kidney:
1. In the `Volume Rendering` module, Check "Enable" crop and click on "Display ROI"
2. Adjust the ROI to encompass just the right kidney
3. Under the Advanced Tab, click on the "Scalar Opacity Mapping" function to adjust the transparency of the volume
4. Hide the Crop ROI
You should see something that looks like this:
The kidney is surrounded by ribs and the spinal column which imaged with similar levels of intensity. So, if we use basic thresholding, we will need to clean up a lot of the segmentation surrounding the kidney
Before continuing, turn off the 3D render by clicking the eye icon closed
Inspect Voxel Intensities
The most basic segmentation techniques involve thresholding, in which an intensity cut-off value is used to create a mask. For this exercise, we want to first segment the cortex of the kidneys, so let's inspect the intensity inside the kidney and in the tissue surrounding the kidneys.
Let's start with Right kidney. Remember, we should look at the right kidney in all three views. To help align the views, we will turn on the Crosshair
tool ( ), which adds crosshairs to each view to show the center of the alignment.
-
In the top toolbar, hold down the Crosshair tool menu and make sure the following menu items are selected:
-
Click on the Crosshair tool to activate
- In the 2D viewers, scrub to the slices that show the right kidney.
-
Hold shift while you hover the mouse pointer over one kidney view to align all three views. The slice iteration lines will jump to the mouse when you hold shift. There should be yellow crosshairs in all three views to indicate the center of the alignments
-
Release shift and move the mouse pointer over the kidney and surrounding tissue inspect the intensity values of the voxels
- Compare the intensity value of the kidney to the tissue surrounding the kidney and to the spinal column. Make note of these intensity values:
- Kidney:
~245
- Surrounding Tissue,
~80
- Vertebrae:
~300-1000
.
- Kidney:
Segmentation
For this exercise, we will segment the Kidneys, the Aorta, and the Lungs. When you segment, you actually create a new volume that is the same size as the original volume (same number of voxels). This segmentation volume is said to mask the original volume. Segmentation volumes can be either binary volumes (true or false) or label maps, which use whole numbers to indicate connected regions. For this exercise, for example, we will create a segmentation of the Right Kidney. In this segmentation volume, all voxels pertaining to the right kidney will be labeled with a value, like 1. This is not an intensity value, but a label — that's why they are called label maps. We will also segment the Left Kidneys — all those voxels will be labeled with a different value, like 2. And so on. Everywhere that is not segmented will have a label of 0.
Crop Volume
Segmentation projects are often memory intensive. So, is often useful to crop the volume down to the bare minimum needed for the segmentation project. For analysis of the segmentations, it is also useful to resample the voxels so that they are isotropic.
Create ROI
- Switch to the
Volume Rendering
module - Enable and display the crop ROI
- If the crop is still specific to the right kidney, click on the "Fit to Volume" icon so the ROI covers the entire volume
- Crop out the table and as much of the wires as you can manage
Crop Module
Switch to the Crop
module by searching for the module using the magnifying glass
In the crop module, use the following settings:
- Input volume: "CTACardio"
- Input ROI: "Volume rendering ROI" - this is the ROI that we created in the
Volume Rendering
module - Output Volume: Create a new volume as "CTACardioCrop"
- Check on "Interpolated cropping"
- Reveal the Volume Information tab
CTACardio Crop settings
Notice that the new, cropped volume will have isotropic voxels
To crop:
- Click Apply ( you have to scroll down from Volume Information)
- The new cropped volume (CTACardioCrop) should appear in the viewers
Before continuing:
- Return to the
Volume Rendering
module - Turn off Volume Rendering (click eye icon closed)
- Hide the ROI (click Display ROI off)
Filter Volume
You should also filter a volume before you segment.
- Open the
Median Image Filter
module - Use the default settings (Neighborhood Size
1,1,1
) - Input Volume: CTACardioCrop
- Output Volume: CTACardioCrop
- Click
APPLY
Median Filter Settings
This will overwrite the cropped volume with a filtered version of the volume
Segment Editor
The Segment Editor module organizes a set of tools to create and manage segmentations.
First, be sure to reset the volume look-up table by clicking on the CT-Abdomen present under the display tab in the Volumes module.
Segment the Right Kidney Using Grow from Seeds
We start by creating a segmentation of the Right Kidney. Here is a video overview of the Grow from Seeds method: PERKlab - Grow from seeds
Add a Segmentation volume to Segmentation table
- Bring up the Segment Editor Module:
- Master volume: Make sure the master volume is the "CTACardioCrop" volume
- Click on the add button ![segment editor add button][segment editor add button]
- A Segmentation row should appear in the Segmentations table. The name should be "Segment_1" (or something similar)
- Rename this row "Right Kidney" by clicking on "Segment_1" name
This table dictates what we add to our segmentation volume. Right now, we just have one segmentation, 'Right Kidney'. As we progress through this exercise, we will add the left kidney and the aorta. Each item in the table will have a different label in the segmentation volume (like a 1, a 2, or a 3). As we segment, we will add the segmentation color to the image cross-sections. When we do this, we are actually adding the label (1,2, or 3) to the corresponding location in the segmentation volume.
Center Viewers on right kidney
- In the green viewer, scrub to the center of kidneys.
- Notice that the kidneys have a lighter outer area (the cortex) and a darker interior area (the medulla). We will capture the cortex in this exercise.
- Make sure the coronal section (green viewer) is showing a slice near the center of the kidney.
- Align all three views to the center of the right kidney (hold shift while moving and point the mouse at the right kidney in the green viewer)
- All three views should now be showing the right kidney
Set Threshold
We can use the threshold tool to segment the kidney, but that would also segment some of the vasculature and parts of the skeletal system. Instead, we will use the threshold tool to set the Masking, which are the editable intensities in the volume (the voxels that we can mask).
- Click on the Threshold tool
- You should see a gray flashing color overlaid on the grayscale images in the 2D viewer
- You should see a gray flashing color overlaid on the grayscale images in the 2D viewer
- Adjust the Threshold range:
150
to300
. Kidney, some vasculature, and bone cortex should light up. - Click on "Use for Masking"
- This turns on the "Editable intensity range" and switches over to the Paint Tool
Threshold Masking Settings
Hand Paint The Green Slice
The previous step should have switched you to the Paint Tool
Paint Tool Settings
Notice Under the Masking Tab that the "Editable Intensity Range" has been checked on and the range is the threshold values that we set in the threshold tool (150 - 300)
- Move the mouse over the kidney and click-drag to paint
- Notice that we can only paint inside of the cortex of the kidney.
- This is because of the "Editable Intensity Range" setting.
- If you uncheck that setting, then the paint tool will paint everywhere you click-drag (so, don't do that)
- Paint the Right kidney in all three views. Only paint the current slice in each viewer (don't scrub through the slices)
- You should now have three orthogonal segmentations of the kidney cortex.
- To visualize these slices in 3D, click on the Show 3D button
Manual Segmentation of Right Kidney
We could repeat this process and painstakingly trace every single slice of the kidney, slice by slice, until we have the entire kidney cortex segmented. But this dataset has enough contrast between the kidney and the surrounding tissue to automate instead. For example, we can use the grow from seeds method...
Grow from Seeds
The Grow from Seeds tool segments by searching for voxels sharing a similar intensity range that are adjacent. First, though, you have to establish which voxels are kidney (the 'seeds') and which voxels are definitely not kidney (background).
We start the process starts by creating a new segmentation layer for the background
- Click on the "Add" button in the segment editor module
-
In the segmentations table, a new row should appear under the Left Kidney row. Rename that row "background".
-
Paint Tool Click on the "Paint tool".
- Select the background segmentation row in the segmentations table.
- Uncheck "Editable intensity range" so you can paint everywhere
- Set the Editable Area to "Outside all segments"
- Paint around the kidney in all three Slice Views.
- You shouldn't be able to overwrite the green (due to the Editable area setting)
- Be sure that you painting the background color (mustard in this case) and not the kidney color (green)
- Be sure to sample as many different regions of the volume that are NOT kidney, but that immediately surround the kidney.
- Be sure to also paint inside the kidney in the medulla areas
Manual Segmentation of Background surrounding Right Kidney
- Grow From Seeds. Click on the "Grow from Seeds" icon
- Critical! Reselect "Right Kidney" in the Segmentations table
- Use the following settings:
- Click "Initialize"
- Scrub through the slices to make sure that the segmentation worked. Use to the paint tool to clean up any errors. After patching up, click on the "Update" button.
- Click on "Apply" - it may seem like Slicer crashed. Just wait
- After a while, you should get something like this
Output after apply from Grow from Seeds
- Notice that the Background is now a large Cube. Grow from seeds extends the background from your background paintings into a 3D cube. Inside this cube, is the kidney.
- Delete the "Background" segmentation (mustard box).
- Select the "background" row in the segmentation table
- Click on the "Remove" button
- You should now see a fully segmented kidney, in all its glory, in the 3D viewer
Segmentation Cleanup
After segmentation, you typically use some morphological operations to clean up the segmentation. The Segment Editor
contains many useful tools, such as the Islands Tool, which can remove small noise.
Islands Tool
- Click on the Islands icon.
- Select "Remove small islands"
- Set "Editable area" to "Everywhere"
- Use the default setting of 1000
- Click Apply
- Small noise should be removed
Smoothing
You can remove extrusions or close holes using the smoothing tool
- Click on the Smoothing icon
- Try the default settings for Closing (fill holes) and Opening (remove extrusions)
- Click "Apply" to apply the smoothing effect
Save Data
Time to save your hard work!
- Click on the save icon:
- In the dialog, Click on the "Change directory…" button
- In the file dialog that appears, create a new folder called 'CTACardio' and then click Choose
- Back in the Save Dialog, Choose "Save"
- Everything in the table that is checked will be saved.
Segment the Left kidney
Repeat the segmentation steps for the Left Kidney
- Create a new Segmentation Called Left Kidney. Set the color to Blue
- Settings for Grow From Seeds - Masking: Editable area: Outside all visible segments - Overwrite other segments: "none"
SAVE YOUR WORK!
Segment the Aorta
For the Aorta, we will use a different segmentation method. First, though, we need to create the segmentation volume.
- In the
Segment Editor
module, Click on the Add Button - Rename the new segmentation "Aorta"
- Change the color of the Aorta to red by double-clicking on the color tile to bring up the color selector
- choose "Artery" red
- Make sure that the Aorta segmentation is selected for the following steps
Local Threshold
The local threshold tool is an add-on tool included with the "SegmentEditorExtraEffects" extension. Make sure you have that extension installed before continuing. Local threshold works by setting an intensity range and then clicking on the image to add a starting point for the segmentation. The algorithm will segment any connected voxels with the same intensity range.
- Switch to the Local Threshold tool
- Set the threshold Range to:
300-600
- Under the Masking tab, set the Editable area to "Outside all segments"
- For Modifying other segments, choose "Overwrite visible"
You should see a flashing color indicating what will be segmented. Notice that kidney is outside of the threshold range
- Once you have these settings, Ctrl- or Command- click on the descending aorta and watch the magic happen
So, we also got the ventricles of the heart, but no matter, we can clean that up
Clean up Aorta
- Maximize the 3D viewer
- Switch to the Scissors tool
- Make sure Aorta is selected in the Segmentation table
- Position the 3D view so you can see the blue background behind the aortic arch
- Cut the arch by drawing an oval using the scissor tool
- Use the arrow keys to rotate the segmentation and ensure that you have separated the arch from the heart
- Switch to the Islands Tool
- Select "Remove selected island"
- In the 2D view of the segmentation, click on a segmentation in the heart to remove that portion of the segmentation
Notice that the pointer icon shows the island tool when pointing to the segmentation in the 2D view only (not the the 3D viewer)
- Select "Remove small islands" using a minimum size of 1000 voxels
- Click apply and enjoy your segmented aorta
- Save your work!
Segmented Aorta (and Right Kidney)
Segment the Lungs
This requires the Lung CT Analyzer & Segmenter extension to be installed.
Change Window/Level of CTACardio
- Switch to the
Volumes
module - Set the Active Volume to "CTACardioCrop"
- Select the CTLung Preset
Lung CT Segmenter
Open the Lung CT Segmenter:
This menu item is only available after you have installed the extension
Lung CT Segmenter Module
- Make sure that your Input volume is "CTACardioCrop"
- Otherwise, don't change any of the settings
- Click Start
- You will be present with an axial slice and Prompted to add three points to the right lung
- Scrub to the middle of the lungs
- Click on three points in the right lung, followed by three points in the left lung
- Once you have added the points, you will then be presented with a coronal plane
- Again, scrub to a region near the middle of the lungs
- Click on three points in the right lung, followed by three points in the left lung
- Once you have added the points, you be prompted to add a point to the trachea. If you don't see the trachea, scrub through the coronal planes until you do.
- Add a point to the trachea
- If everything looks good, click Apply
- Enjoy segmentations of the lung and trachea
Final Lung Segmentations
Review Data module
Notice that a new Segmentation Node has been added: "Lung Segmentation". There are also some segmentations in there not being displayed
Notes: models will be added in a future step
Save your work!