How to Segment a Pancreas CT

A guide for finding and tracing pancreas on contrast-enhanced abdominal CT

Alexander Weston, PhD
Towards Data Science

--

Special thanks to my good friend Dr. Megan Engels, for helping me with this post.

Introduction — what is segmentation?

CT scans contain a wealth of information that can help us understand a patient’s health. As data scientists, our role is to extract the information so it can be measured, or quantified.

The first step to analyzing CT or MRI scans is usually segmentation. By this, I mean tracing — segmenting — important structures from background. From segmentations, we extract important features like organ volume, surface area, brightness, and texture patterns that tell us about various aspects of the disease.

Segmentation can be a time-consuming process and is one of the first tasks we are trying to automate using deep-learning. For example, our lab has developed a U-Net model to segment thirty-four unique organs from abdominal CT (paper).

In this tutorial, I’ll demonstrate how to segment the pancreas from abdominal CT. I’ll focus on using ITK-Snap which is a simple, free tool that you can use to get started. I’m including some basics of anatomy, but if you intend to embark on your own research project I highly recommend that you connect with clinical expert such as a radiologist to understand what the specific needs are for your task.

TCIA Dataset

For this demo, I’m using The Cancer Imaging Archive (TCIA) dataset, which is a publicly available dataset of medical images provided by the NIH. The full dataset contains 85 scans taken from healthy patients. The dataset also provides segmentations, although I’ll be showing you how to trace from scratch.

ITK-Snap

There are many tools available that can view and annotate DICOM images (for a background on the DICOM file format, see my other article). A quick way to get started is with ITK-Snap, which is easy to download and use. It’s perfect for smaller datasets.

A quick plug — for more complicated projects (for example, projects that involve multiple tracers or repeated scans) our group at Mayo Clinic developed our own open-source software tool, RIL-Contour. RIL-Contour has advanced features to make segmentation faster and more accurate, and even data versioning, which can help with quality control when you have multiple individuals working on the same project.

Viewing Images

ITK-Snap supports images in both the NIFTI and DICOM formats. Figure 1 shows what the ITK-Snap interface looks like after you import a file.

Figure 1. Importing a file into ITK-Snap

This is a 3D scan which is shown in 3 views — axial (also called “transverse”) (upper left), sagittal (upper right), and coronal (lower right). You’ll notice each view is labeled anterior (A), posterior (P), superior (S), inferior (I), right (R) and left (L).

Right and left may appear backward to the reader —it’s given from the perspective of the patient who would be facing us.

You can segment in any plane, but it’s common to do most of the segmentation in the axial plane. This is because slice thickness in CT is usually larger in the axial plane (3–5mm, vs. 0.5–0.8mm), so you end up having to trace fewer slices.

Windowing

Before we start, we need to adjust the contrast of the scan. This is called “windowing”. CT contrast is measured in Hounsfield Units, which are normalized to air (HU = -1000) and water (HU = 0). To adjust the windowing in ITK-Snap, go to Tools > Image Contrast > Contrast Adjustment. There’s a slider bar, but it’s more accurate just to type in the numbers. For abdominal soft tissue, the level is 50, and the window is 400, which means that the image pixels are clipped between -350 and +450.

Figure 2. CT Abdomen before (left) and after windowing (right). Settings are Level=50, Window=400.

These CTs are contrast-enhanced, which means that iodine contrast agent was injected into the bloodstream. This will make the blood vessels appear brighter than the surrounding tissue. Additionally, the patient has digestive contrast in the form of a barium swallow, which makes the contents of the stomach and small intestine also appear bright.

Abdominal Anatomy

Before we find the pancreas, it’s helpful to understand a bit of abdominal anatomy. I’ve labeled a few landmarks in the scans below. If you consult an anatomy textbook, you’ll see that the pancreas is tucked under the liver and behind the stomach, usually adjacent to the spine.

Figure 3. Anatomy of the abdomen in the coronal (left) and axial plane (right)

Pancreas Anatomy

Just like other organs, there’s considerable variation in the location, size, and shape of the pancreas which can make it difficult to segment. The pancreas can be especially tricky to segment for several reasons —

  1. It’s less attached than other solid organs, and tends to shift around
  2. It directly interfaces other surrounding organs (especially the bowel wall)
  3. It has a heterogenous appearance even in healthy patients.

Below, I’ve copied a cartoon from Wikipedia. The pancreas organ is differentiated into three regions, the head, the body, and the tail. The pancreas has a soft, lobed appearance, and is organized around a central pancreatic duct, which carries the digestive juices excreted by the pancreas into the small intestine.

Figure 4. Diagram of the pancreas, from Wikipedia

On CT, this lobed appearance manifests as a soft, lumpy texture. The pancreatic duct may or may not be visible (it tends to be less visible in younger patients). Be aware that the pancreas may contain cysts — some estimations put this number as high as 50%. Obesity also impacts the pancreas’ appearance, causing fatty deposits that may make the pancreas appear darker. Finally, pancreatic atrophy is also common in the elderly; it can be a sign of disease, or just a normal variation in older adults.

Figure 5. Closeup of pancreas in the axial plane. Key landmarks include the soft, lobed texture, and the dark pancreatic duct.

Tracing the pancreas, step by step

I usually think it’s easiest to find the pancreas body because of the distinctive texture and location. I’ll trace this structure first, and then follow it up and down.

The pancreas tends to be wrapped around several blood vessels including the aorta, vena cava, and renal arteries/veins. These vessels typically show up as bright circular structures on contrast-enhanced CT (non-contrast CT these distinctions are barely visible — and much harder to segment). Be sure to avoid accidentally including vessels in your segmentation which can introduce bias into your measurements.

Finally, it can be hard to separate the head and tail of the pancreas when they are touching nearby organs. One trick I like to use is to segment 4–5 obvious slices on the coronal plane, and then use this as a guide for axial segmentation. This makes it easy to find the “corners” of the pancreas organ.

After you’ve finished, be sure to double-check your work. The most common mistake I tend to make is accidentally skipping over a slice or two.

Figure 6. Finished pancreas segmentation in the axial (left), sagittal (middle), and coronal (right) planes. This segmentation took me about 20 minutes using ITK-Snap

Conclusion

Like other things, segmentation is a learning process (and a bit of an art form). In our paper, we found that when multiple tracers outlined the same pancreas, their agreement was only about 80%, so it’s expected that your work might not be perfect.

One thing that I like to tell students is that when you’re uncertain, just take your best guess. You’re probably more accurate than you realize!

--

--